这篇教程C++ H5Gopen函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中H5Gopen函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Gopen函数的具体用法?C++ H5Gopen怎么用?C++ H5Gopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了H5Gopen函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: H5Fopenvoid CheMPS2::DMRG::loadMPS(const std::string name, TensorT ** MPSlocation, bool * isConverged){ //The hdf5 file hid_t file_id = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); //Whether the MPS was converged or not hid_t group_id = H5Gopen(file_id, "/Convergence", H5P_DEFAULT); hid_t dataset_id = H5Dopen(group_id, "Converged_yn", H5P_DEFAULT); int toRead; H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toRead); isConverged[0] = (toRead==0)?false:true; H5Dclose(dataset_id); H5Gclose(group_id); //The MPS for (int site=0; site<L; site++){ std::stringstream sstream; sstream << "/MPS_" << site; hid_t group_id3 = H5Gopen(file_id, sstream.str().c_str(), H5P_DEFAULT); hid_t dataset_id3 = H5Dopen(group_id3, "Values", H5P_DEFAULT); H5Dread(dataset_id3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, MPSlocation[site]->gStorage()); H5Dclose(dataset_id3); H5Gclose(group_id3); } H5Fclose(file_id);}
开发者ID:SebWouters,项目名称:CheMPS2,代码行数:35,
示例2: out_dir_H5Converter::H5Converter(const std::string& h5_fname, const std::string& out_dir) : out_dir_(out_dir){ file_id_ = H5Fopen(h5_fname.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); root_ = H5Gopen(file_id_, "/", H5P_DEFAULT); aux_ = H5Gopen(file_id_, "/aux", H5P_DEFAULT); // <aux info> // read target ids read_dataset(aux_, "ids", targ_ids_); std::cerr << "[h5dump] number of targets: " << targ_ids_.size() << std::endl; n_targs_ = targ_ids_.size(); read_dataset(aux_, "lengths", lengths_); assert( n_targs_ == lengths_.size() ); read_dataset(aux_, "eff_lengths", eff_lengths_); assert( n_targs_ == eff_lengths_.size() ); // read bootstrap info std::vector<int> n_bs_vec; read_dataset(aux_, "num_bootstrap", n_bs_vec); n_bs_ = n_bs_vec[0]; std::cerr << "[h5dump] number of bootstraps: " << n_bs_ << std::endl; // </aux info> if (n_bs_ > 0) { bs_ = H5Gopen(file_id_, "/bootstrap", H5P_DEFAULT); } std::vector<std::string> tmp; read_dataset(aux_, "kallisto_version", tmp); kal_version_ = tmp[0]; tmp.clear(); std::cerr << "[h5dump] kallisto version: " << kal_version_ << std::endl; std::vector<int> idx_version; read_dataset(aux_, "index_version", idx_version); idx_version_ = static_cast<size_t>(idx_version[0]); std::cerr << "[h5dump] index version: " << idx_version_ << std::endl; read_dataset(aux_, "start_time", tmp); start_time_ = tmp[0]; tmp.clear(); std::cerr << "[h5dump] start time: " << start_time_ << std::endl; read_dataset(aux_, "call", tmp); call_ = tmp[0]; tmp.clear(); std::cerr << "[h5dump] shell call: " << call_ << std::endl; alpha_buf_.resize( n_targs_, 0.0 ); assert( n_targs_ == alpha_buf_.size() ); tpm_buf_.resize( n_targs_, 0.0 ); assert( n_targs_ == tpm_buf_.size() );}
开发者ID:FriendlyNeighborhoodNematode,项目名称:kallisto,代码行数:59,
示例3: test_misc/*------------------------------------------------------------------------- * Function: test_misc * * Purpose: Test miscellaneous group stuff. * * Return: Success: 0 * * Failure: number of errors * * Programmer: Robb Matzke * Tuesday, November 24, 1998 * * Modifications: * Robb Matzke, 2002-03-28 * File is opened by parent instead of here. *------------------------------------------------------------------------- */static inttest_misc(hid_t file){ hid_t g1=-1, g2=-1, g3=-1; char comment[64]; /* Test current working groups */ TESTING("miscellaneous group tests"); /* Create initial groups for testing, then close */ if ((g1=H5Gcreate(file, "test_1a", 0))<0) goto error; if ((g2=H5Gcreate(g1, "sub_1", 0))<0) goto error; if ((g3=H5Gcreate(file, "test_1b", 0))<0) goto error; if (H5Gset_comment(g3, ".", "hello world")<0) goto error; if (H5Gclose(g1)<0) goto error; if (H5Gclose(g2)<0) goto error; if (H5Gclose(g3)<0) goto error; /* Open all groups with absolute names to check for exsistence */ if ((g1=H5Gopen(file, "/test_1a"))<0) goto error; if ((g2=H5Gopen(file, "/test_1a/sub_1"))<0) goto error; if ((g3=H5Gopen(file, "/test_1b"))<0) goto error; if (H5Gget_comment(g3, "././.", sizeof comment, comment)<0) goto error; if (strcmp(comment, "hello world")) { H5_FAILED(); puts(" Read the wrong comment string from the group."); printf(" got: /"%s/"/n ans: /"hello world/"/n", comment); goto error; } if (H5Gclose(g1)<0) goto error; if (H5Gclose(g2)<0) goto error; if (H5Gclose(g3)<0) goto error; /* Check that creating groups with no-op names isn't allowed */ H5E_BEGIN_TRY { g1=H5Gcreate(file, "/", 0); } H5E_END_TRY if(g1 >= 0) goto error; H5E_BEGIN_TRY { g1=H5Gcreate(file, "./././", 0); } H5E_END_TRY if(g1 >= 0) goto error; PASSED(); return 0; error: H5E_BEGIN_TRY { H5Gclose(g1); H5Gclose(g2); H5Gclose(g3); } H5E_END_TRY; return 1;}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:72,
示例4: _extract_all_tasksstatic void _extract_all_tasks(FILE *fp, hid_t gid_step, hid_t gid_nodes, int nnodes, int stepx){ hid_t gid_tasks, gid_task = 0, gid_node = -1, gid_level = -1; H5G_info_t group_info; int ntasks, itx, len, task_id; char task_name[MAX_GROUP_NAME+1]; char* node_name; char buf[MAX_GROUP_NAME+1]; bool hd = true; gid_tasks = get_group(gid_step, GRP_TASKS); if (gid_tasks < 0) fatal("No tasks in step %d", stepx); H5Gget_info(gid_tasks, &group_info); ntasks = (int) group_info.nlinks; if (ntasks <= 0) fatal("No tasks in step %d", stepx); for (itx = 0; itx<ntasks; itx++) { // Get the name of the group. len = H5Lget_name_by_idx(gid_tasks, ".", H5_INDEX_NAME, H5_ITER_INC, itx, buf, MAX_GROUP_NAME, H5P_DEFAULT); if ((len > 0) && (len < MAX_GROUP_NAME)) { gid_task = H5Gopen(gid_tasks, buf, H5P_DEFAULT); if (gid_task < 0) fatal("Failed to open %s", buf); } else fatal("Illegal task name %s",buf); task_id = get_int_attribute(gid_task, ATTR_TASKID); node_name = get_string_attribute(gid_task, ATTR_NODENAME); sprintf(task_name,"%s_%d", GRP_TASK, task_id); gid_node = H5Gopen(gid_nodes, node_name, H5P_DEFAULT); if (gid_node < 0) fatal("Failed to open %s for Task_%d", node_name, task_id); gid_level = get_group(gid_node, GRP_SAMPLES); if (gid_level < 0) fatal("Failed to open group %s for node=%s task=%d", GRP_SAMPLES,node_name, task_id); _extract_series(fp, stepx, hd, gid_level, node_name, task_name); hd = false; xfree(node_name); H5Gclose(gid_level); H5Gclose(gid_node); H5Gclose(gid_task); } H5Gclose(gid_tasks);}
开发者ID:FredHutch,项目名称:slurm,代码行数:52,
示例5: _merge_node_step_datastatic void _merge_node_step_data(hid_t fid_job, char* file_name, int nodeIndex, char* node_name, hid_t jgid_nodes, hid_t jgid_tasks){ hid_t fid_nodestep, jgid_node, nsgid_root, nsgid_node; char *start_time; char group_name[MAX_GROUP_NAME+1]; jgid_node = H5Gcreate(jgid_nodes, node_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (jgid_node < 0) { error("Failed to create group %s",node_name); return; } put_string_attribute(jgid_node, ATTR_NODENAME, node_name); // Process node step file // Open the file and the node group. fid_nodestep = H5Fopen(file_name, H5F_ACC_RDONLY, H5P_DEFAULT); if (fid_nodestep < 0) { H5Gclose(jgid_node); error("Failed to open %s",file_name); return; } nsgid_root = H5Gopen(fid_nodestep,"/", H5P_DEFAULT); sprintf(group_name, "/%s_%s", GRP_NODE, node_name); nsgid_node = H5Gopen(nsgid_root, group_name, H5P_DEFAULT); if (nsgid_node < 0) { H5Gclose(fid_nodestep); H5Gclose(jgid_node); error("Failed to open node group"); return;; } start_time = get_string_attribute(nsgid_node,ATTR_STARTTIME); if (start_time == NULL) { info("No %s attribute", ATTR_STARTTIME); } else { put_string_attribute(jgid_node, ATTR_STARTTIME, start_time); xfree(start_time); } _merge_node_totals(jgid_node, nsgid_node); _merge_task_totals(jgid_tasks, nsgid_node, node_name); _merge_series_data(jgid_tasks, jgid_node, nsgid_node); H5Gclose(nsgid_node); H5Fclose(fid_nodestep); H5Gclose(jgid_node); if (!params.keepfiles) remove(file_name); return;}
开发者ID:jsollom,项目名称:slurm,代码行数:51,
示例6: read_new/*------------------------------------------------------------------------- * Function: read_new * * Purpose: Test reading a file with "new style" (compact) groups * * Return: Success: 0 * * Failure: -1 * * Programmer: Quincey Koziol * Monday, October 24, 2005 * *------------------------------------------------------------------------- */static intread_new(hid_t fapl){ hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group ID */ char *srcdir = HDgetenv("srcdir"); /*where the src code is located*/ char filename[512]=""; /* test file name */ TESTING("reading new groups"); /* Generate correct name for test file by prepending the source path */ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_NEW_GROUPS) + 1) < sizeof(filename))) { HDstrcpy(filename, srcdir); HDstrcat(filename, "/"); } HDstrcat(filename, FILE_NEW_GROUPS); /* Open file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; /* Attempt to open root group */ if((gid = H5Gopen(fid, "/")) < 0) TEST_ERROR; /* Attempt to open new "empty" group (should fail) */ H5E_BEGIN_TRY { if(H5Gopen(gid, "empty") >= 0) TEST_ERROR; } H5E_END_TRY; /* Attempt to open new group with link messages (should fail) */ H5E_BEGIN_TRY { if(H5Gopen(gid, "links") >= 0) TEST_ERROR; } H5E_END_TRY; /* Close root group */ if(H5Gclose(gid) < 0) TEST_ERROR; /* Close first file */ if(H5Fclose(fid)<0) TEST_ERROR; PASSED(); return 0;error: H5E_BEGIN_TRY { H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; return 1;} /* end read_new() */
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:63,
示例7: fast5_get_channel_paramsfast5_raw_scaling fast5_get_channel_params(fast5_file& fh, const std::string& read_id){ // from scrappie fast5_raw_scaling scaling = { NAN, NAN, NAN, NAN }; std::string scaling_path = fh.is_multi_fast5 ? "/read_" + read_id + "/channel_id" : "/UniqueGlobalKey/channel_id"; hid_t scaling_group = H5Gopen(fh.hdf5_file, scaling_path.c_str(), H5P_DEFAULT); if (scaling_group < 0) {#ifdef DEBUG_FAST5_IO fprintf(stderr, "Failed to open group %s/n", scaling_path.c_str());#endif return scaling; } scaling.digitisation = fast5_read_float_attribute(scaling_group, "digitisation"); scaling.offset = fast5_read_float_attribute(scaling_group, "offset"); scaling.range = fast5_read_float_attribute(scaling_group, "range"); scaling.sample_rate = fast5_read_float_attribute(scaling_group, "sampling_rate"); H5Gclose(scaling_group); return scaling;}
开发者ID:jts,项目名称:nanopolish,代码行数:25,
示例8: PYTABLE_open_group/*+++++++++++++++++++++++++.IDENTifer PYTABLE_open_group.PURPOSE Open/Create a group in an exsisting HDF5-file.INPUT/OUTPUT call as grpID = PYTABLE_open_group( locID, name, sz_hint ); input: hid_t locID : HDF5 object id char name[] : name of the group.RETURNS A negative value is returned on failure. .COMMENTS none-------------------------*/hid_t PYTABLE_open_group( hid_t locID, const char *name ){ hid_t grpID;/* * check if the group exists, if not create it */ H5E_BEGIN_TRY { if ( (grpID = H5Gopen( locID, name, H5P_DEFAULT )) < 0 ) { grpID = H5Gcreate( locID, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); (void) H5LTset_attribute_string( locID, name, "CLASS", PY_GROUP_CLASS ); (void) H5LTset_attribute_string( locID, name, "PYTABLES_FORMAT_VERSION", PY_FORMAT_VERSION ); (void) H5LTset_attribute_string( locID, name, "TITLE", name ); (void) H5LTset_attribute_string( locID, name, "VERSION", PY_GROUP_VERSION ); } } H5E_END_TRY;/* * return id of the group */ return grpID;}
开发者ID:rmvanhees,项目名称:nadc_tools,代码行数:39,
示例9: foreach// -----------------------------------------------------------------------------//// -----------------------------------------------------------------------------void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, QString h5InternalPath){ QList<QString> dataContainers; QH5Utilities::getGroupObjects(dcArrayGroupId, H5Utilities::H5Support_GROUP, dataContainers); foreach(QString dataContainerName, dataContainers) { if(__SHOW_DEBUG_MSG__) { std::cout << "Data Container:" << dataContainerName.toStdString() << std::endl; } hid_t containerGid = H5Gopen(dcArrayGroupId, dataContainerName.toLatin1().constData(), H5P_DEFAULT); if (containerGid < 0) { continue; } HDF5ScopedGroupSentinel sentinel(&containerGid, false); DataContainerProxy dcProxy(dataContainerName); dcProxy.name = dataContainerName; dcProxy.flag = Qt::Checked; QString h5Path = h5InternalPath + "/" + dataContainerName; // Read the Attribute Matricies for this Data Container AttributeMatrix::ReadAttributeMatrixStructure(containerGid, dcProxy, h5Path); // Insert the DataContainerProxy proxy into the DataContainerArrayProxy proxy.dataContainers.insert(dcProxy.name, dcProxy); }}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:31,
示例10: get_groupextern hid_t get_group(hid_t parent, const char *name){ char buf[MAX_GROUP_NAME]; hsize_t nobj; hid_t gid; int i, len; H5G_info_t group_info; if (parent < 0) { debug3("PROFILE: parent is not HDF5 object"); return -1; } H5Gget_info(parent, &group_info); nobj = group_info.nlinks; for (i = 0; (nobj>0) && (i<nobj); i++) { // Get the name of the group. len = H5Lget_name_by_idx(parent, ".", H5_INDEX_NAME, H5_ITER_INC, i, buf, MAX_GROUP_NAME, H5P_DEFAULT); if ((len > 0) && (len < MAX_GROUP_NAME)) { if (strcmp(buf, name) == 0) { gid = H5Gopen(parent, name, H5P_DEFAULT); if (gid < 0) error("PROFILE: Failed to open %s", name); return gid; } } } return -1;}
开发者ID:diorsman,项目名称:slurm,代码行数:32,
示例11: copyToBuffervoid MultiChain::record() { //h_config = H5Gopen(h_file,"MultiChain"); typedef Bead::RealType PosType; typedef Bead::Buffer_t Buffer_t; Buffer_t chain_buffer,bead_buffer; (*(this->begin()))->registerData(bead_buffer); chain_buffer.rewind(); copyToBuffer(chain_buffer); HDFAttribIO<Buffer_t> mcout(chain_buffer); mcout.overwrite(h_config,"state"); std::deque<Bead*>::iterator bead_it(this->begin()); std::deque<Bead*>::iterator bead_end(this->end()); //create the group and increment counter char GrpName[128]; int ibead=0; while(bead_it != bead_end) { sprintf(GrpName,"bead%04d",ibead); hid_t bead_id = H5Gopen(h_config,GrpName); bead_buffer.rewind(); Bead& bead(**bead_it); bead.copyToBuffer(bead_buffer); HDFAttribIO<Buffer_t> bout(bead_buffer); bout.overwrite(bead_id,"state"); H5Gclose(bead_id); ++bead_it; ++ibead; }}
开发者ID:digideskio,项目名称:qmcpack,代码行数:32,
示例12: H5Lexists_safeint H5Lexists_safe(hid_t base, char *path)// -----------------------------------------------------------------------------// The HDF5 specification only allows H5Lexists to be called on an immediate// child of the current object. However, you may wish to see whether a whole// relative path exists, returning false if any of the intermediate links are// not present. This function does that.// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-Exists// -----------------------------------------------------------------------------{ hid_t last = base, next; char *pch; char pathc[2048]; strcpy(pathc, path); pch = strtok(pathc, "/"); while (pch != NULL) { int exists = H5Lexists(last, pch, H5P_DEFAULT); if (!exists) { if (last != base) H5Gclose(last); return 0; } else { next = H5Gopen(last, pch, H5P_DEFAULT); if (last != base) H5Gclose(last); last = next; } pch = strtok(NULL, "/"); } if (last != base) H5Gclose(last); return 1;}
开发者ID:geoffryan,项目名称:calvis,代码行数:30,
示例13: scan_for_max_idstatic intscan_for_max_id( FileHandle* file_ptr, mhdf_Status* status ){ hid_t group_id; herr_t rval; /* Check for new format, with max_id as attrib of root group */#if defined(H5Gopen_vers) && H5Gopen_vers > 1 group_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );#else group_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );#endif if (group_id < 0) { mhdf_setFail( status, "Internal error - invalid file."); return 0; } if (mhdf_read_scalar_attrib( group_id, MAX_ID_ATTRIB, H5T_NATIVE_ULONG, &file_ptr->max_id, status )) { H5Gclose( group_id ); return 1; } /* Didn't find it, scan the elements group */ rval = H5Giterate( group_id, ELEMENT_GROUP_NAME, 0, &max_id_iter, &file_ptr->max_id ); if (rval) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check node table too */ rval = get_max_id( group_id, NODE_GROUP_NAME, "coordinates", (unsigned long*)(&file_ptr->max_id) ); if (rval) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check set table, if it exists */ rval = mhdf_is_in_group( group_id, SET_GROUP_NAME, status ); if (rval < 1) { H5Gclose( group_id ); return !rval; } rval = get_max_id( group_id, SET_GROUP_NAME, SET_META_NAME, (unsigned long*)(&file_ptr->max_id) ); H5Gclose( group_id ); if (rval) { mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } return 1;}
开发者ID:chrismullins,项目名称:moab,代码行数:60,
示例14: h5_value_doublesvoid h5_value_doubles(hid_t file_id, char *group, char *name, double **values, int *numValues){ int kk; hid_t group_id = H5Gopen(file_id, group, H5P_DEFAULT); hid_t data_id = H5Dopen(group_id, name, H5P_DEFAULT); hid_t data_space = H5Dget_space(data_id); int rank = H5Sget_simple_extent_ndims(data_space); hsize_t dims[H5S_MAX_RANK], maxdim[H5S_MAX_RANK]; H5Sget_simple_extent_dims(data_space, dims, maxdim); hid_t data_type = H5Dget_type(data_id); H5T_class_t data_class = H5Tget_native_type(data_type, H5T_DIR_DEFAULT); size_t data_size = H5Tget_size(data_class); hsize_t elements = 1; for (kk=0; kk<rank; kk++) elements *= dims[kk]; void *buf = (void *) MALLOC((size_t)(elements*data_size)); H5Dread(data_id, data_class, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); *values = buf; *numValues = elements; H5Tclose(data_type); H5Tclose(data_class); H5Sclose(data_space); H5Dclose(data_id); H5Gclose(group_id); }
开发者ID:khogenso,项目名称:ASF_MapReady,代码行数:26,
示例15: F77_FUNC_/* write eigen value and eigen vector for (ibnd, ispin) */void F77_FUNC_(pwhdf_write_band,PWHDF_WRITE_BAND)(const int* ibnd, const int* ispin, const double* e, const double* eigv, const int* ngtot){ char spinname[16]; sprintf(spinname,"band%i/spin%i",(*ibnd)-1,(*ispin)-1); hid_t h_spin = H5Gopen(h_twist,spinname); hsize_t dim=1; hid_t dataspace= H5Screate_simple(1, &dim, NULL); hid_t dataset= H5Dcreate(h_spin, "eigenvalue", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT); hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,e); H5Sclose(dataspace); H5Dclose(dataset); hsize_t dims[2]; dims[0] = *ngtot; dims[1] = 2; dataspace = H5Screate_simple(2, dims, NULL); dataset = H5Dcreate(h_spin, "eigenvector", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT); ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,eigv); H5Sclose(dataspace); H5Dclose(dataset); H5Gclose(h_spin);}
开发者ID:digideskio,项目名称:qmcpack,代码行数:26,
示例16: cxi_open_dataCXI_Data * cxi_open_data(CXI_Data_Reference * ref){ cxi_debug("opening data"); char buffer[1024]; if(!ref){ return NULL; } CXI_Data * data = calloc(sizeof(CXI_Data),1); if(!data){ return NULL; } data->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT); if(data->handle < 0){ free(data); return NULL; } ref->data = data; if(H5Lexists(data->handle,"data",H5P_DEFAULT)){ data->data = calloc(sizeof(CXI_Dataset_Reference),1); data->data->parent_handle = data->handle; data->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(data->data->group_name,"data"); } if(H5Lexists(data->handle,"errors",H5P_DEFAULT)){ data->errors = calloc(sizeof(CXI_Dataset_Reference),1); data->errors->parent_handle = data->handle; data->errors->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(data->errors->group_name,"errors"); } return data;}
开发者ID:cxidb,项目名称:libcxi,代码行数:32,
示例17: _series_datastatic int _series_data(void){ FILE *fp; bool hd = false; hid_t fid_job; hid_t jgid_root; hid_t jgid_step; int nsteps; int stepx; char jgrp_step_name[MAX_GROUP_NAME + 1]; fp = fopen(params.output, "w"); if (fp == NULL) { error("Failed open file %s -- %m", params.output); return -1; } fid_job = H5Fopen(params.input, H5F_ACC_RDONLY, H5P_DEFAULT); if (fid_job < 0) { fclose(fp); error("Failed to open %s", params.input); return -1; } jgid_root = H5Gopen(fid_job, "/", H5P_DEFAULT); if (jgid_root < 0) { fclose(fp); H5Fclose(fid_job); error("Failed to open root"); return -1; } nsteps = get_int_attribute(jgid_root, ATTR_NSTEPS); for (stepx = 0; stepx < nsteps; stepx++) { if ((params.step_id != -1) && (stepx != params.step_id)) continue; sprintf(jgrp_step_name, "%s_%d", GRP_STEP, stepx); jgid_step = get_group(jgid_root, jgrp_step_name); if (jgid_step < 0) { error("Failed to open group %s", jgrp_step_name); return -1; } if (strncmp(params.series,GRP_TASK,strlen(GRP_TASK)) == 0) _get_all_task_series(fp,hd,jgid_step, stepx); else _get_all_node_series(fp,hd,jgid_step, stepx); hd = true; H5Gclose(jgid_step); } H5Gclose(jgid_root); H5Fclose(fid_job); fclose(fp); return 0;}
开发者ID:FredHutch,项目名称:slurm,代码行数:60,
示例18: cxi_open_imageCXI_Image * cxi_open_image(CXI_Image_Reference * ref){ cxi_debug("opening image"); char buffer[1024]; if(!ref){ return NULL; } CXI_Image * image = calloc(sizeof(CXI_Image),1); if(!image){ return NULL; } image->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT); if(image->handle < 0){ free(image); return NULL; } /* Search for Detector groups */ int n = find_max_suffix(image->handle, "detector"); image->detector_count = n; image->detectors = calloc(sizeof(CXI_Detector_Reference *),n); for(int i = 0;i<n;i++){ image->detectors[i] = calloc(sizeof(CXI_Detector_Reference),1); sprintf(buffer,"detector_%d",i+1); image->detectors[i]->parent_handle = image->handle; image->detectors[i]->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(image->detectors[i]->group_name,buffer); } ref->image = image; if(H5Lexists(image->handle,"data",H5P_DEFAULT)){ image->data = calloc(sizeof(CXI_Dataset_Reference),1); image->data->parent_handle = image->handle; image->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(image->data->group_name,"data"); } if(H5Lexists(image->handle,"data_error",H5P_DEFAULT)){ image->data_error = calloc(sizeof(CXI_Dataset_Reference),1); image->data_error->parent_handle = image->handle; image->data_error->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(image->data_error->group_name,"data_error"); } if(H5Lexists(image->handle,"mask",H5P_DEFAULT)){ image->mask = calloc(sizeof(CXI_Dataset_Reference),1); image->mask->parent_handle = image->handle; image->mask->group_name = malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(image->mask->group_name,"mask"); } // try_read_string(image->handle, "data_space",&image->data_space); // try_read_string(image->handle, "data_type",&image->data_type); image->dimensionality_valid = try_read_int(image->handle, "dimensionality",&image->dimensionality); image->image_center_valid = try_read_float_array(image->handle, "image_center",image->image_center,3); return image;}
开发者ID:cxidb,项目名称:libcxi,代码行数:60,
示例19: cxi_open_attenuatorCXI_Attenuator * cxi_open_attenuator(CXI_Attenuator_Reference * ref){ cxi_debug("opening attenuator"); if(!ref){ return NULL; } CXI_Attenuator * attenuator = calloc(sizeof(CXI_Attenuator),1); if(!attenuator){ return NULL; } attenuator->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT); if(attenuator->handle < 0){ free(attenuator); return NULL; } ref->attenuator = attenuator; attenuator->distance_valid = try_read_float(attenuator->handle, "distance",&attenuator->distance); attenuator->thickness_valid = try_read_float(attenuator->handle, "thickness",&attenuator->thickness); attenuator->attenuator_transmission_valid = try_read_float(attenuator->handle, "attenuator_transmission", &attenuator->attenuator_transmission); try_read_string(attenuator->handle, "type",&attenuator->type); return attenuator;}
开发者ID:cxidb,项目名称:libcxi,代码行数:25,
示例20: mainintmain(){ printf("/n*** Checking HDF5 file c0.nc./n"); printf("*** Checking HDF5 objcts..."); { hid_t fileid, grpid; hsize_t num_obj, i; char obj_name[MAX_NAME]; if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; if ((grpid = H5Gopen(fileid, "/")) < 0) ERR; /* Find the variables. Read their metadata and attributes. */ if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR; for (i=0; i<num_obj; i++) { /* Get the class (i.e. group, dataset, etc.), and the name of * the object. */ if (H5Gget_objtype_by_idx(grpid, i) < 0) ERR; if (H5Gget_objname_by_idx(grpid, i, obj_name, MAX_NAME) < 0) ERR; } if (H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; FINAL_RESULTS;}
开发者ID:BJangeofan,项目名称:netcdf-c,代码行数:31,
示例21: HDF5DatasetGDALDataset *HDF5Dataset::Open( GDALOpenInfo *poOpenInfo ){ if( !Identify(poOpenInfo) ) return nullptr; // Create datasource. HDF5Dataset *const poDS = new HDF5Dataset(); poDS->SetDescription(poOpenInfo->pszFilename); // Try opening the dataset. poDS->hHDF5 = H5Fopen(poOpenInfo->pszFilename, H5F_ACC_RDONLY, H5P_DEFAULT); if( poDS->hHDF5 < 0 ) { delete poDS; return nullptr; } poDS->hGroupID = H5Gopen(poDS->hHDF5, "/"); if( poDS->hGroupID < 0 ) { poDS->bIsHDFEOS = false; delete poDS; return nullptr; } poDS->bIsHDFEOS = true; poDS->ReadGlobalAttributes(true); poDS->SetMetadata(poDS->papszMetadata); if ( CSLCount(poDS->papszSubDatasets) / 2 >= 1 ) poDS->SetMetadata(poDS->papszSubDatasets, "SUBDATASETS"); // Make sure we don't try to do any pam stuff with this dataset. poDS->nPamFlags |= GPF_NOSAVE; // If we have single subdataset only, open it immediately. int nSubDatasets = CSLCount(poDS->papszSubDatasets) / 2; if( nSubDatasets == 1 ) { CPLString osDSName = CSLFetchNameValue(poDS->papszSubDatasets, "SUBDATASET_1_NAME"); delete poDS; return (GDALDataset *)GDALOpen(osDSName, poOpenInfo->eAccess); } else { // Confirm the requested access is supported. if( poOpenInfo->eAccess == GA_Update ) { delete poDS; CPLError(CE_Failure, CPLE_NotSupported, "The HDF5 driver does not support update access to " "existing datasets."); return nullptr; } } return poDS;}
开发者ID:ksshannon,项目名称:gdal,代码行数:60,
示例22: PetscViewerHDF5OpenGroupPetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer viewer, hid_t *fileId, hid_t *groupId){ hid_t file_id, group; const char *groupName = NULL; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerHDF5GetFileId(viewer, &file_id);CHKERRQ(ierr); ierr = PetscViewerHDF5GetGroup(viewer, &groupName);CHKERRQ(ierr); /* Open group */ if (groupName) { PetscBool root; ierr = PetscStrcmp(groupName, "/", &root);CHKERRQ(ierr); if (!root && !H5Lexists(file_id, groupName, H5P_DEFAULT)) {#if (H5_VERS_MAJOR * 10000 + H5_VERS_MINOR * 100 + H5_VERS_RELEASE >= 10800) group = H5Gcreate2(file_id, groupName, 0, H5P_DEFAULT, H5P_DEFAULT);#else /* deprecated HDF5 1.6 API */ group = H5Gcreate(file_id, groupName, 0);#endif if (group < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Could not create group %s", groupName); ierr = H5Gclose(group);CHKERRQ(ierr); }#if (H5_VERS_MAJOR * 10000 + H5_VERS_MINOR * 100 + H5_VERS_RELEASE >= 10800) group = H5Gopen2(file_id, groupName, H5P_DEFAULT);#else group = H5Gopen(file_id, groupName);#endif if (group < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Could not open group %s", groupName); } else group = file_id; *fileId = file_id; *groupId = group; PetscFunctionReturn(0);}
开发者ID:feelpp,项目名称:debian-petsc,代码行数:35,
示例23: dat1GetParentIDhid_tdat1GetParentID( hid_t objid, hdsbool_t allow_root, int * status ) { hid_t parent_id = -1; ssize_t lenstr = 0; char * tempstr = NULL; if (*status != SAI__OK) return parent_id; /* Not sure if there is a specific API for this. For now, get the full name of the object and then open the group with the lowest part of the path removed */ tempstr = dat1GetFullName( objid, 0, &lenstr, status ); if (*status == SAI__OK && lenstr <= 1) { *status = DAT__OBJIN; emsRep("datParen_0", "Object is the HDF5 root group and has no parent " "group (possible programming error).", status); goto CLEANUP; } /* Now walk through the name in reverse and nul out the first "/" we encounter. */ if (*status == SAI__OK) { ssize_t iposn; ssize_t i; for (i = 0; i < lenstr; i++) { iposn = lenstr - (i+1); if (tempstr[iposn] == '/') { tempstr[iposn] = '/0'; break; } } } /* if this seems to be the root group we rewrite it to be "/" else, optionally return an error. */ if (tempstr[0] == '/0') { if (allow_root) { tempstr[0] = '/'; tempstr[1] = '/0'; } else if (*status == SAI__OK) { *status = DAT__OBJIN; emsRep("datParen_1", "Object is a top-level object and has no parent " "structure (possible programming error).", status); goto CLEANUP; } } /* It seems you can open a group on an arbitrary item (group or dataset) if you use a fully specified path. This means you do not need to get an explicit file_id to open the group */ CALLHDFE( hid_t, parent_id, H5Gopen(objid, tempstr, H5P_DEFAULT), DAT__HDF5E, emsRepf("datParen_2", "Error opening parent structure '%s'", status, tempstr ); );
开发者ID:Starlink,项目名称:hds-v5,代码行数:60,
示例24: luaC_h5_open_groupint luaC_h5_open_group(lua_State *L){ const char *gname = luaL_checkstring(L, 1); const char *mode = luaL_checkstring(L, 2); hid_t grp = 0; if (PresentFile < 0) { luaL_error(L, "need an open file to open group/n"); } else if (strcmp(mode, "w") == 0) { if (H5Lexists(PresentFile, gname, H5P_DEFAULT)) { H5Ldelete(PresentFile, gname, H5P_DEFAULT); } grp = H5Gcreate(PresentFile, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } else if (strcmp(mode, "r+") == 0) { if (H5Lexists(PresentFile, gname, H5P_DEFAULT)) { grp = H5Gopen(PresentFile, gname, H5P_DEFAULT); } else { grp = H5Gcreate(PresentFile, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } } else { luaL_error(L, "invalid group access mode '%s'/n", mode); } lua_pushnumber(L, grp); return 1;}
开发者ID:jzrake,项目名称:luview,代码行数:31,
示例25: H5Gopen// -----------------------------------------------------------------------------//// -----------------------------------------------------------------------------int DataContainer::writeAttributeMatricesToHDF5(hid_t parentId){ int err; hid_t attributeMatrixId; for(QMap<QString, AttributeMatrix::Pointer>::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) { err = QH5Utilities::createGroupsFromPath(iter.key(), parentId); if(err < 0) { return err; } attributeMatrixId = H5Gopen(parentId, iter.key().toLatin1().data(), H5P_DEFAULT); HDF5ScopedGroupSentinel gSentinel(&attributeMatrixId, false); err = QH5Lite::writeScalarAttribute(parentId, iter.key(), DREAM3D::StringConstants::AttributeMatrixType, (*iter)->getType()); if(err < 0) { return err; } hsize_t size = (*iter)->getTupleDimensions().size(); err = QH5Lite::writePointerAttribute(parentId, iter.key(), DREAM3D::HDF5::TupleDimensions, 1, &size, (*iter)->getTupleDimensions().data()); if(err < 0) { return err; } err = (*iter)->writeAttributeArraysToHDF5(attributeMatrixId); if(err < 0) { return err; } } return 0;}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:36,
示例26: H5PcreateasynStatus NDFileHDF5AttributeDataset::createHDF5Dataset(){ asynStatus status = asynSuccess; cparm_ = H5Pcreate(H5P_DATASET_CREATE); H5Pset_fill_value(cparm_, datatype_, ptrFillValue_); H5Pset_chunk(cparm_, rank_, chunk_); dataspace_ = H5Screate_simple(rank_, dims_, maxdims_); // Open the group by its name hid_t dsetgroup; if (groupName_ != ""){ dsetgroup = H5Gopen(file_, groupName_.c_str(), H5P_DEFAULT); } else { dsetgroup = file_; } // Now create the dataset dataset_ = H5Dcreate2(dsetgroup, dsetName_.c_str(), datatype_, dataspace_, H5P_DEFAULT, cparm_, H5P_DEFAULT); if (groupName_ != ""){ H5Gclose(dsetgroup); } memspace_ = H5Screate_simple(rank_, elementSize_, NULL); return status;}
开发者ID:ukaea,项目名称:epics,代码行数:34,
示例27: H5Fcreatevoid H5Writer::init(const std::string& fname, int num_bootstrap, uint compression, size_t index_version, const std::string& shell_call, const std::string& start_time){ primed_ = true; num_bootstrap_ = num_bootstrap; compression_ = compression; file_id_ = H5Fcreate(fname.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root_ = H5Gopen(file_id_, "/", H5P_DEFAULT); aux_ = H5Gcreate(file_id_, "/aux", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (num_bootstrap_ > 0) { bs_ = H5Gcreate(file_id_, "/bootstrap", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } std::vector<int> n_bs {num_bootstrap}; vector_to_h5(n_bs, aux_, "num_bootstrap", false, compression_); // info about run std::vector<std::string> kal_version{ KALLISTO_VERSION }; vector_to_h5(kal_version, aux_, "kallisto_version", true, compression_); std::vector<int> idx_version{ static_cast<int>(index_version) }; vector_to_h5(idx_version, aux_, "index_version", false, compression_); std::vector<std::string> call{ shell_call }; vector_to_h5(call, aux_, "call", true, compression_); std::vector<std::string> s_time{ start_time }; vector_to_h5(s_time, aux_, "start_time", true, compression_);}
开发者ID:FriendlyNeighborhoodNematode,项目名称:kallisto,代码行数:29,
示例28: avoid ESHDFIonsParser::readESHDF(){ int nspecies=0; { HDFAttribIO<int> a(nspecies); a.read(hfile_id,"atoms/number_of_species"); } SpeciesSet& tspecies(ref_.getSpeciesSet()); int icharge= tspecies.addAttribute("charge");//use charge int iatnumber= tspecies.addAttribute(atomic_number_tag); int massind= tspecies.addAttribute(mass_tag); //add charge //atomic_number is optional for(int i=0; i<nspecies; ++i) { ostringstream o; o << "atoms/species_"<<i; hid_t g=H5Gopen(hfile_id,o.str().c_str()); string aname; HDFAttribIO<string> a(aname); a.read(g,"name"); int ii=tspecies.addSpecies(aname); int q=-1; HDFAttribIO<int> b(q); b.read(g,charge_tag.c_str()); tspecies(icharge,ii)=q; int atnum=0; HDFAttribIO<int> c(atnum); c.read(g,atomic_number_tag.c_str()); tspecies(iatnumber,ii)=atnum; //close the group H5Gclose(g); } for(int ig=0; ig<nspecies; ++ig) tspecies(massind,ig)=1.0; //just for checking // tspecies(icharge,0)=15.0; // tspecies(icharge,1)=6.0; { //get the unit cell Tensor<double,3> alat; HDFAttribIO<Tensor<double,3> > a(alat); a.read(hfile_id,"supercell/primitive_vectors"); ref_.Lattice.set(alat); } { //get the unit cell int natoms=0; HDFAttribIO<int> a(natoms); a.read(hfile_id,"atoms/number_of_atoms"); ref_.create(natoms); ref_.R.InUnit=PosUnit::CartesianUnit; HDFAttribIO<ParticleSet::ParticlePos_t> b(ref_.R); b.read(hfile_id,"atoms/positions"); HDFAttribIO<ParticleSet::ParticleIndex_t> c(ref_.GroupID); c.read(hfile_id,"atoms/species_ids"); } ref_.resetGroups();}
开发者ID:digideskio,项目名称:qmcpack,代码行数:59,
注:本文中的H5Gopen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ H5Gopen2函数代码示例 C++ H5Gcreate2函数代码示例 |