您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ H5Dopen2函数代码示例

51自学网 2021-06-01 21:20:08
  C++
这篇教程C++ H5Dopen2函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中H5Dopen2函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Dopen2函数的具体用法?C++ H5Dopen2怎么用?C++ H5Dopen2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了H5Dopen2函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: region_origin

int ErrorData::readH5(hid_t group_id) {  // Read all the data  hid_t dataset_id;  vector<unsigned int> region_origin(2,0);  dataset_id = H5Dopen2(group_id,"region_origin",H5P_DEFAULT);  H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &region_origin[0]);  H5Dclose(dataset_id);  vector<unsigned int> region_dim(2,0);  dataset_id = H5Dopen2(group_id,"region_dim",H5P_DEFAULT);  H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &region_dim[0]);  H5Dclose(dataset_id);  vector<unsigned int> error_data_dim(2,0);  dataset_id = H5Dopen2(group_id,"error_data_dim",H5P_DEFAULT);  H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &error_data_dim[0]);  H5Dclose(dataset_id);  if(error_data_dim[0] != ERROR_DATA_N_ROWS)    return(EXIT_FAILURE);  vector<uint64_t> error_data(error_data_dim[0]*error_data_dim[1],0);  dataset_id = H5Dopen2(group_id,"error_data",H5P_DEFAULT);  H5Dread(dataset_id, H5T_NATIVE_UINT_LEAST64, H5S_ALL, H5S_ALL, H5P_DEFAULT, &error_data[0]);  H5Dclose(dataset_id);  // Store data in object  Initialize(region_origin,region_dim,error_data_dim,error_data);  return(EXIT_SUCCESS);}
开发者ID:Brainiarc7,项目名称:TS,代码行数:29,


示例2: H5Fopen

void Fast5Files::convertFasta(QString outfile){	hid_t fast5id;	hid_t fastq;	for(int i = 0; i < filenames.size(); ++i){		fast5id = H5Fopen(filenames.at(i).toLatin1().data(), H5F_ACC_RDONLY, H5P_DEFAULT);		fastq   = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_template/Fastq", H5P_DEFAULT);		if(fastq > 0){			getFastq(fastq);		}		fastq = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_complement/Fastq", H5P_DEFAULT);		if(fastq > 0){			getFastq(fastq);		}		fastq    = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_2D/Fastq", H5P_DEFAULT);		if(fastq > 0){			getFastq(fastq);		}		H5Fclose(fast5id);	}}
开发者ID:TravisCG,项目名称:Fast5-Studio,代码行数:25,


示例3: test_read_with_filters

/*------------------------------------------------------------------------- * Function:	test_read_with_filters * * Purpose:	Tests reading dataset created with dynamically loaded filters * * Return:	Success:	0 *		Failure:	-1 * * Programmer:	Raymond Lu *              14 March 2013 * *------------------------------------------------------------------------- */static herr_ttest_read_with_filters(hid_t file){    hid_t	dset;                 /* Dataset ID */    /*----------------------------------------------------------     * STEP 1: Test deflation by itself.     *----------------------------------------------------------     */#ifdef H5_HAVE_FILTER_DEFLATE    TESTING("Testing deflate filter");    if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR    if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR    if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR    if(H5Dclose(dset) < 0) TEST_ERROR    /* Clean up objects used for this test */#else /* H5_HAVE_FILTER_DEFLATE */    TESTING("deflate filter");    SKIPPED();    puts("    Deflate filter not enabled");#endif /* H5_HAVE_FILTER_DEFLATE */    /*----------------------------------------------------------     * STEP 2: Test DYNLIB1 by itself.     *----------------------------------------------------------     */    TESTING("Testing DYNLIB1 filter");    if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR    if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR    if(H5Dclose(dset) < 0) TEST_ERROR    /*----------------------------------------------------------     * STEP 3: Test Bogus2 by itself.     *----------------------------------------------------------     */    TESTING("Testing DYNLIB2 filter");    if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR    if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR    if(H5Dclose(dset) < 0) TEST_ERROR    return 0;error:    return -1;}
开发者ID:schwehr,项目名称:hdf5,代码行数:69,


示例4: loadHdf5Input

/* Read and load coefficients Knlm and scale radius a */int loadHdf5Input(char *filename, struct Indata *var){    hid_t   hdf_file,hdf_group,hdf_data;    herr_t  status;    double  temp[NMAX][LMAX][LMAX][2];    fprintf(stdout,"Reading file %s ...",filename);    hdf_file = H5Fopen(filename,H5F_ACC_RDONLY,H5P_DEFAULT);    if (hdf_file < 0){        return -1;    }        if ( (hdf_group=H5Gopen2(hdf_file,"/",H5P_DEFAULT)) < 0){        H5Gclose(hdf_file);        return -1;    }    if ( (hdf_data=H5Dopen2(hdf_file,"/Knlm",H5P_DEFAULT)) < 0){        H5Dclose(hdf_data);        return -1;    }    //status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, var->Knlm);    status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp);    for (int n=0; n<NMAX; n++){        for (int l=0; l<LMAX; l++){            for (int m=0; m<LMAX; m++){                var->Knlm[l][m][n][0]=temp[n][l][m][0]; // I reorder the matrix since the summation                var->Knlm[l][m][n][1]=temp[n][l][m][1]; // over n is done first                                                        // [0]/[1] -> cosine/sine terms            }        }    }        /* Read virial radius (not really needed) */    if ( (hdf_data=H5Dopen2(hdf_file,"/Rvir",H5P_DEFAULT)) < 0){        H5Dclose(hdf_data);        return -1;    }    status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &var->virialrad);    /* Read Hernquist scale radius needed to normalize positions */    if ( (hdf_data=H5Dopen2(hdf_file,"/a",H5P_DEFAULT)) < 0){        H5Dclose(hdf_data);        return -1;    }    status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &var->scalerad);    //H5Gclose(hdf_group);    H5Fclose(hdf_file);    H5Dclose(hdf_data);    fprintf(stdout," file read successfully!/n");    return 0;}
开发者ID:edjocute,项目名称:Orbit,代码行数:54,


示例5: H5IMread_image

herr_t H5IMread_image( hid_t loc_id,                       const char *dset_name,                       unsigned char *buf ){    hid_t   did;    /* check the arguments */    if (dset_name == NULL)       return -1;    /* Open the dataset. */    if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)        return -1;    /* Read */    if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0)        goto out;    /* End access to the dataset and release resources used by it. */    if ( H5Dclose( did ) )        return -1;    return 0;out:    H5Dclose( did );    return -1;}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:29,


示例6: read_vector

int read_vector(hid_t loc_id,const char *name,T *value,int len){  hid_t space_id,dset_id,dti_file;  int hdferr,ndims;  hsize_t dims[2], maxdims[2];  printf("Attempting to read vector '%s'/n",name);  dset_id= H5Dopen2(loc_id,name,H5P_DEFAULT);  space_id= H5Dget_space(dset_id);  ndims= H5Sget_simple_extent_ndims(space_id);  if(ndims!=1) return -1;  H5Sget_simple_extent_dims(space_id,dims,maxdims);  if(dims[0]>len) return -1;  hdferr= H5Dread(dset_id,TypeTraits<T>::hdf5Type(),H5S_ALL,H5S_ALL,H5P_DEFAULT,value);  if(hdferr<0) return -1;  H5Sclose(space_id);  H5Dclose(dset_id);  return dims[0];}
开发者ID:sidjana,项目名称:lsms-shmem,代码行数:25,


示例7: test_duplicatelong_attachscales

static int test_duplicatelong_attachscales(const char *filename){    hid_t   fid = -1;    hid_t   did = -1;    char    dsname[32];    char    scalename[32];    strcpy(dsname, DATASET_NAME);    strcat(dsname, "al2");    TESTING2("test_duplicatelong_attachscales");    if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)        goto out;    /* make a dataset 2 */    if(create_long_dataset(fid, dsname, "al2") < 0)        goto out;    if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {        strcpy(scalename, DS_1_NAME);        strcat(scalename, "al");        if(test_attach_scale(fid, did, scalename, DIM0) < 0)            goto out;        strcpy(scalename, DS_2_NAME);        strcat(scalename, "al");        if(test_attach_scale(fid, did, scalename, DIM1) < 0)            goto out;        strcpy(scalename, DS_3_NAME);        strcat(scalename, "al");        if(test_attach_scale(fid, did, scalename, DIM2) < 0)            goto out;        strcpy(scalename, DS_4_NAME);        strcat(scalename, "al");        if(test_attach_scale(fid, did, scalename, DIM3) < 0)            goto out;        if(H5Dclose(did) < 0)            goto out;    }    else        goto out;    PASSED();    H5Fclose(fid);    return SUCCEED;out:    H5E_BEGIN_TRY  {        H5Dclose(did);        H5Fclose(fid);    } H5E_END_TRY;    H5_FAILED();    return FAIL;}
开发者ID:herr-biber,项目名称:hdf5,代码行数:60,


示例8: h5dopen_c

/****if* H5Df/h5dopen_c * NAME *  h5dopen_c * PURPOSE *  Call H5Dopen2 to open a dataset * INPUTS *  loc_id - file or group identifier *  name - name of the dataset *  namelen - name length *  dapl_id	- Dataset access property list * OUTPUTS *  dset_id - dataset identifier * RETURNS *  0 on success, -1 on failure * AUTHOR *  Elena Pourmal *  Wednesday, August 4, 1999 * HISTORY *  Added 1.8 parameter: dapl_id * SOURCE*/int_fh5dopen_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *dapl_id, hid_t_f *dset_id)/******/{     char *c_name = NULL;     hid_t c_dset_id;     int ret_value = -1;     /*      * Convert FORTRAN name to C name      */     if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))         goto DONE;     /*      * Call H5Dopen2 function.      */     if((c_dset_id = H5Dopen2((hid_t)*loc_id, c_name, (hid_t)*dapl_id)) < 0)         goto DONE;     *dset_id = (hid_t_f)c_dset_id;     ret_value = 0;DONE:     if(c_name)         HDfree(c_name);     return ret_value;}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:49,


示例9: test_filter_error

/*------------------------------------------------------------------------- * Function:	test_filter_error * * Purpose:	Make sure the error message prints out the filter name *              when the existent file is opened but the filter isn't  *              registered. The existent file was created with  *              gen_filters.c.  * * Return:	Success:	0 * *		Failure:	-1 * * Programmer:	Raymond Lu *		2 June 2011 * *------------------------------------------------------------------------- */static herr_ttest_filter_error(const char *fname){    const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */    hid_t       file, dataset;         /* handles */    int         buf[20];    HDfprintf(stderr, "/nTesting error message during data reading when filter isn't registered/n");    /* Open the file */    if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)        TEST_ERROR;    /* Open the regular dataset */    if((dataset = H5Dopen2(file, DSET_FILTER_NAME, H5P_DEFAULT)) < 0)        TEST_ERROR;    if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) >= 0)	TEST_ERROR;    /* Close/release resources */    if(H5Dclose(dataset) < 0)        TEST_ERROR    if(H5Fclose(file) < 0)        TEST_ERROR    return 0;error:    return -1;}
开发者ID:adasworks,项目名称:hdf5,代码行数:49,


示例10: test_noread_with_filters

/*------------------------------------------------------------------------- * Function:	test_noread_with_filters * * Purpose:	Tests reading dataset created with dynamically loaded filters disabled * * Return:	Success:	0 *		Failure:	-1 * *------------------------------------------------------------------------- */static herr_ttest_noread_with_filters(hid_t file){    hid_t	dset;                 /* Dataset ID */    unsigned     plugin_state;         /* status of plugins */    TESTING("Testing DYNLIB1 filter with plugins disabled");    /* disable filter plugin */    if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR    plugin_state = plugin_state & ~H5PL_FILTER_PLUGIN;    if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR    if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR    if(test_noread_data(dset) < 0) TEST_ERROR    if(H5Dclose(dset) < 0) TEST_ERROR    /* re-enable filter plugin */    plugin_state = plugin_state | H5PL_FILTER_PLUGIN;    if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR    return 0;error:    /* re-enable filter plugin */    plugin_state = plugin_state | H5PL_FILTER_PLUGIN;    if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR    return -1;}
开发者ID:adasworks,项目名称:hdf5,代码行数:40,


示例11: test_cmp_scalename

herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx){    herr_t  ret_value = FAIL;    hid_t   dsid = -1;    ssize_t name_len;    char    *name_out=NULL;    if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {        if(H5DSis_attached(did, dsid, idx) == 1) {            if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {                name_out = (char*)malloc((size_t)name_len * sizeof (char));                if(name_out != NULL) {                    if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {                        if(strcmp(scalename,name_out)==0) {                            ret_value = SUCCEED;                        }                        free(name_out);                        name_out=NULL;                    }                }            }        }        if(H5Dclose(dsid) < 0)            ret_value = FAIL;    }    return ret_value;}
开发者ID:herr-biber,项目名称:hdf5,代码行数:28,


示例12: H5IMread_imagef

herr_t H5IMread_imagef(hid_t loc_id,                        const char *dset_name,                        int_f *buf){    hid_t   did;    hid_t   tid;    /* open the dataset */    if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)        return -1;    /* determine appropriate datatype to use */    if(sizeof(int_f) == sizeof(int))        tid = H5T_NATIVE_INT;    else if(sizeof(int_f) == sizeof(long))        tid = H5T_NATIVE_LONG;    else if(sizeof(int_f) == sizeof(long long))        tid = H5T_NATIVE_LLONG;    else        goto out;    /* read to memory */    if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)        goto out;    /* close */    if(H5Dclose(did))        return -1;    return 0;out:    H5Dclose(did);    return -1;}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:35,


示例13: ls2_hdf5_read_anchors

ls2_hdf5_read_anchors(hid_t file, vector2** anchors, size_t *no_anchors){    hid_t dataset, dataspace, memspace;    hsize_t dims[2];    int rank;    dataset = H5Dopen2(file, "/Anchors", H5P_DEFAULT);    dataspace = H5Dget_space(dataset);    rank = H5Sget_simple_extent_ndims(dataspace);    if (rank != 2) {        fprintf(stderr, "/Anchors wrong rank %d/n", (int) rank);        return -1;    }    H5Sget_simple_extent_dims(dataspace, dims, NULL);    if (dims[1] != 2) {        fprintf(stderr, "/Anchors dimension (%d, %d)/n",                (int) dims[0], (int) dims[1]);        return -1;    }    *no_anchors = (size_t) dims[0];    *anchors = (vector2 *) calloc(*no_anchors, sizeof(vector2));    memspace = H5Screate_simple(2, dims, NULL);    H5Dread(dataset, H5T_NATIVE_FLOAT, memspace, dataspace, H5P_DEFAULT,            *anchors);    H5Dclose(dataset);    H5Sclose(dataspace);    H5Sclose(memspace);    return 0;}
开发者ID:madcowpp,项目名称:LS2,代码行数:30,


示例14: H5Gopen2

void pyne::Material::_load_comp_protocol0(hid_t db, std::string datapath, int row) {  hid_t matgroup = H5Gopen2(db, datapath.c_str(), H5P_DEFAULT);  hid_t nucset;  double nucvalue;  ssize_t nuckeylen;  std::string nuckey;  // get the number of members in the material group  H5G_info_t group_info;   H5Gget_info(matgroup, &group_info);  hsize_t matG = group_info.nlinks;  // Iterate over datasets in the group.  for (int matg = 0; matg < matG; matg++) {    nuckeylen = 1 + H5Lget_name_by_idx(matgroup, ".", H5_INDEX_NAME, H5_ITER_INC, matg,                                         NULL, 0, H5P_DEFAULT);    char * nkey = new char[nuckeylen];    nuckeylen = H5Lget_name_by_idx(matgroup, ".", H5_INDEX_NAME, H5_ITER_INC, matg,                                     nkey, nuckeylen, H5P_DEFAULT);    nuckey = nkey;    nucset = H5Dopen2(matgroup, nkey, H5P_DEFAULT);    nucvalue = h5wrap::get_array_index<double>(nucset, row);    if (nuckey == "Mass" || nuckey == "MASS" || nuckey == "mass")      mass = nucvalue;    else      comp[pyne::nucname::id(nuckey)] = nucvalue;    H5Dclose(nucset);    delete[] nkey;  };  // Set meta data  atoms_per_molecule = -1.0;};
开发者ID:crbates,项目名称:pyne,代码行数:35,


示例15: path_

hdf5_dataset::hdf5_dataset(    hdf5_file const& file,    std::string const& path)    :      path_(path){    // Check if name exists in this file.    htri_t status = H5Lexists(file.get_id(), path.c_str(), H5P_DEFAULT);    if(status > 0) { // Full path exists.        // Attempt to open it as a dataset        set_id(H5Dopen2(file.get_id(), path.c_str(), H5P_DEFAULT));        if(get_id() < 0) {            boost::serialization::throw_exception(                hdf5_archive_exception(                    hdf5_archive_exception::hdf5_archive_dataset_access_error,                    path.c_str()                )            );        }    }    else { // path does not exist, or other error        boost::serialization::throw_exception(            hdf5_archive_exception(                hdf5_archive_exception::hdf5_archive_bad_path_error,                path.c_str()            )        );    }}
开发者ID:warn-naught,项目名称:serialization,代码行数:30,


示例16: H5Fopen

 int64_t GWriteHDFFile::WriteBlock(std::string BlockName, int type, void *data, int partlen, uint32_t np_write, uint32_t begin) {           herr_t herr;           hid_t handle = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);           hid_t group = H5Gopen2(handle, g_name[type], H5P_DEFAULT);           if(group < 0)               return group;           hsize_t size[2];           int rank=1;           //Get type           char b_type = get_block_type(BlockName);           hid_t dtype;           if(b_type == 'f') {               size[1] = partlen/sizeof(float);               dtype=H5T_NATIVE_FLOAT;           }else if (b_type == 'i') {               size[1] = partlen/sizeof(int64_t);               //Hopefully this is 64 bits; the HDF5 manual is not clear.               dtype = H5T_NATIVE_LLONG;           }           else{               return -1000;           }           if (size[1] > 1) {                   rank = 2;           }           /* I don't totally understand why the below works (it is not clear to me from the documentation).            * I gleaned it from a posting to the HDF5 mailing list and a related stack overflow thread here:            * http://stackoverflow.com/questions/24883461/hdf5-updating-a-cell-in-a-table-of-integers            * http://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2014-July/007966.html            * The important thing seems to be that we have a dataspace for the whole array and create a hyperslab on that dataspace.            * Then we need another dataspace with the size of the stuff we want to write.*/           //Make space in memory for the whole array           //Create a hyperslab that we will write to           size[0] = npart[type];           hid_t full_space_id = H5Screate_simple(rank, size, NULL);           //If this is the first write, create the dataset           if (begin==0) {               H5Dcreate2(group,BlockName.c_str(),dtype, full_space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);           }           hid_t dset = H5Dopen2(group,BlockName.c_str(),H5P_DEFAULT);           if (dset < 0)               return dset;           size[0] = np_write;           hid_t space_id = H5Screate_simple(rank, size, NULL);           hsize_t begins[2]={begin,0};           //Select the hyperslab of elements we are about to write to           H5Sselect_hyperslab(full_space_id, H5S_SELECT_SET, begins, NULL, size, NULL);           /* Write to the dataset */           herr = H5Dwrite(dset, dtype, space_id, full_space_id, H5P_DEFAULT, data);           H5Dclose(dset);           H5Sclose(space_id);           H5Sclose(full_space_id);           H5Gclose(group);           H5Fclose(handle);           if (herr < 0)               return herr;           return np_write; }
开发者ID:sbird,项目名称:GadgetReader,代码行数:59,


示例17: H5Dopen2

void H5Dataset::init(){    dataset = H5Dopen2(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);    if (dataset < 0)    {        throw H5Exception(__LINE__, __FILE__, _("Cannot open the given dataset %s."), name.c_str());    }}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:8,


示例18: test_rowmaj

/*------------------------------------------------------------------------- * Function:	test_rowmaj * * Purpose:	Reads the entire dataset using the specified size-squared *		I/O requests in row major order. * * Return:	Efficiency: data requested divided by data actually read. * * Programmer:	Robb Matzke *              Thursday, May 14, 1998 * * Modifications: * *------------------------------------------------------------------------- */static doubletest_rowmaj (int op, size_t cache_size, size_t io_size){    hid_t	file, dset, mem_space, file_space;    signed char	*buf = calloc (1, (size_t)(SQUARE(io_size)));    hsize_t	i, j, hs_size[2];    hsize_t	hs_offset[2];    int		mdc_nelmts;    size_t	rdcc_nelmts;    double	w0;    H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);#ifdef RM_W0    w0 = RM_W0;#endif#ifdef RM_NRDCC    rdcc_nelmts = RM_NRDCC;#endif    H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,		  cache_size*SQUARE (CH_SIZE), w0);    file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g);    dset = H5Dopen2(file, "dset", H5P_DEFAULT);    file_space = H5Dget_space(dset);    nio_g = 0;    for (i=0; i<CH_SIZE*DS_SIZE; i+=io_size) {#if 0	fprintf (stderr, "%5d/b/b/b/b/b", (int)i);	fflush (stderr);#endif	for (j=0; j<CH_SIZE*DS_SIZE; j+=io_size) {	    hs_offset[0] = i;	    hs_size[0] = MIN (io_size, CH_SIZE*DS_SIZE-i);	    hs_offset[1] = j;	    hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-j);	    mem_space = H5Screate_simple (2, hs_size, hs_size);	    H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset,				 NULL, hs_size, NULL);	    if (READ==op) {		H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,			 H5P_DEFAULT, buf);	    } else {		H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,			  H5P_DEFAULT, buf);	    }	    H5Sclose (mem_space);	}    }    free (buf);    H5Sclose (file_space);    H5Dclose (dset);    H5Fclose (file);    return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g;}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:72,


示例19: test_foreign_scaleattached

static int test_foreign_scaleattached(const char *filename){    herr_t  ret_value = FAIL;    hid_t   fid = -1;    hid_t   did = -1;    hid_t   dsid = -1;    TESTING2("test_foreign_scaleattached");    if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)        goto out;    if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {        if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {            if(H5DSis_attached(did, dsid, 3) == 1) {                ret_value = SUCCEED;            }            if(H5Dclose(dsid) < 0)                goto out;        }        if(H5Dclose(did) < 0)            goto out;    }    else        goto out;    if(ret_value == FAIL)        goto out;    PASSED();    H5Fclose(fid);    return 0;out:    H5E_BEGIN_TRY  {        H5Dclose(did);        H5Fclose(fid);    } H5E_END_TRY;    H5_FAILED();    return FAIL;}
开发者ID:herr-biber,项目名称:hdf5,代码行数:44,


示例20: test_diag

/*------------------------------------------------------------------------- * Function:	test_diag * * Purpose:	Reads windows diagonally across the dataset.  Each window is *		offset from the previous window by OFFSET in the x and y *		directions.  The reading ends after the (k,k) value is read *		where k is the maximum index in the dataset. * * Return:	Efficiency. * * Programmer:	Robb Matzke *              Friday, May 15, 1998 * * Modifications: * *------------------------------------------------------------------------- */static doubletest_diag (int op, size_t cache_size, size_t io_size, size_t offset){    hid_t	file, dset, mem_space, file_space;    hsize_t	i, hs_size[2];    hsize_t	nio = 0;    hsize_t	hs_offset[2];    signed char	*buf = calloc (1, (size_t)(SQUARE (io_size)));    int		mdc_nelmts;    size_t	rdcc_nelmts;    double	w0;    H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);#ifdef DIAG_W0    w0 = DIAG_W0;#endif#ifdef DIAG_NRDCC    rdcc_nelmts = DIAG_NRDCC;#endif    H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,		  cache_size*SQUARE (CH_SIZE), w0);    file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g);    dset = H5Dopen2(file, "dset", H5P_DEFAULT);    file_space = H5Dget_space(dset);    nio_g = 0;    for (i=0, hs_size[0]=io_size; hs_size[0]==io_size; i+=offset) {	hs_offset[0] = hs_offset[1] = i;	hs_size[0] = hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-i);	mem_space = H5Screate_simple (2, hs_size, hs_size);	H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset, NULL,			     hs_size, NULL);	if (READ==op) {	    H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,		     H5P_DEFAULT, buf);	} else {	    H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,		      H5P_DEFAULT, buf);	}	H5Sclose (mem_space);	nio += hs_size[0]*hs_size[1];	if (i>0) nio -= SQUARE (io_size-offset);    }    free (buf);    H5Sclose (file_space);    H5Dclose (dset);    H5Fclose (file);    /*     * The extra cast in the following statement is a bug workaround for the     * Win32 version 5.0 compiler.     * 1998-11-06 ptl     */    return (double)(hssize_t)nio/(hssize_t)nio_g;}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:73,


示例21: test_dangle_dataset

/*------------------------------------------------------------------------- * Function:    test_dangle_dataset * * Purpose:    Check for dangling dataset IDs causing problems on library *              shutdown * * Return:    Success:    zero *        Failure:    non-zero * * Programmer:    Quincey Koziol *              Tuesday, May 13, 2003 * * Modifications: * *------------------------------------------------------------------------- */static inttest_dangle_dataset(H5F_close_degree_t degree){    char    filename[1024];    hid_t fid;  /* File ID */    hid_t fapl; /* File access property list */    hid_t dsid; /* Dataset ID */    hid_t sid;  /* Dataspace ID */    unsigned u; /* Local index variable */    TESTING("    dangling dataset IDs");    if(H5open() < 0)        TEST_ERROR;    /* Create file access property list */    if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)        TEST_ERROR;    /* Set file close degree */    if(H5Pset_fclose_degree(fapl, degree) < 0)        TEST_ERROR;    h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename);    if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)        TEST_ERROR;    if((sid = H5Screate(H5S_SCALAR)) < 0)        TEST_ERROR;    if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)        TEST_ERROR;    if(H5Dclose(dsid) < 0)        TEST_ERROR;    /* Try creating duplicate dataset */    H5E_BEGIN_TRY {        if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0)            TEST_ERROR;    } H5E_END_TRY;    if(H5Sclose(sid) < 0)        TEST_ERROR;    /* Leave open a _lot_ of objects */    for(u = 0; u < MAX_DANGLE; u++)        if((dsid = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0)            TEST_ERROR;    if(degree == H5F_CLOSE_SEMI) {        H5E_BEGIN_TRY {            if(H5Fclose(fid) >= 0)                TEST_ERROR;        } H5E_END_TRY;    } /* end if */
开发者ID:Starlink,项目名称:hdf5,代码行数:72,


示例22: H5Eset_auto2

/**   Traverse the path of an object in HDF5 file, checking existence of   groups in the path and creating them if required.  */hid_t HDF5DataWriter::getDataset(string path){    if (filehandle_ < 0){        return -1;    }    herr_t status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);    // Create the groups corresponding to this path    string::size_type lastslash = path.find_last_of("/");    vector<string> pathTokens;    moose::tokenize(path, "/", pathTokens);    hid_t prev_id = filehandle_;    hid_t id = -1;    for ( unsigned int ii = 0; ii < pathTokens.size()-1; ++ii ){        // check if object exists        htri_t exists = H5Lexists(prev_id, pathTokens[ii].c_str(),                                  H5P_DEFAULT);        if (exists > 0){            // try to open existing group            id = H5Gopen2(prev_id, pathTokens[ii].c_str(), H5P_DEFAULT);        } else if (exists == 0) {            // If that fails, try to create a group            id = H5Gcreate2(prev_id, pathTokens[ii].c_str(),                            H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);        }        if ((exists < 0) || (id < 0)){            // Failed to open/create a group, print the            // offending path (for debugging; the error is            // perhaps at the level of hdf5 or file system).            cerr << "Error: failed to open/create group: ";            for (unsigned int jj = 0; jj <= ii; ++jj){                cerr << "/" << pathTokens[jj];            }            cerr << endl;            prev_id = -1;        }        if (prev_id >= 0  && prev_id != filehandle_){            // Successfully opened/created new group, close the old group            status = H5Gclose(prev_id);            assert( status >= 0 );        }        prev_id = id;    }    string name = pathTokens[pathTokens.size()-1];    htri_t exists = H5Lexists(prev_id, name.c_str(), H5P_DEFAULT);    hid_t dataset_id = -1;    if (exists > 0){        dataset_id = H5Dopen2(prev_id, name.c_str(), H5P_DEFAULT);    } else if (exists == 0){        dataset_id = createDoubleDataset(prev_id, name);    } else {        cerr << "Error: H5Lexists returned "             << exists << " for path /""             << path << "/"" << endl;    }    return dataset_id;}
开发者ID:hrani,项目名称:moose-core,代码行数:59,


示例23: restoreField3D

void restoreField3D(char *fileName,char *dataName,float ***data,int nx,int ny,int nz,int offsetY){  hid_t file_id,dset_id,dataspace,memspace;  hsize_t dimsf[3],offset[3],count[3],offset_out[3],count_out[3];  herr_t status;  float *field;  int start,i,j,k;  file_id=H5Fopen(fileName,H5F_ACC_RDONLY,H5P_DEFAULT);  //define memory dataspace  dimsf[1]=nx;  dimsf[0]=ny;  dimsf[2]=nz;  filespace=H5Screate_simple(3,dimsf,NULL);   dset_id=H5Dopen2(file_id,dataName,H5P_DEFAULT);  dataspace=H5Dget_space(dset_id);  //define hyperslab in dataset  offset[1]=0;		//x  offset[0]=offsetY;	//y  offset[2]=0;		//z  count[1]=nx;  count[0]=1;  count[2]=nz;  memspace=H5Screate_simple(3,count,NULL);  status=H5Sselect_hyperslab(dataspace,H5S_SELECT_SET,offset,NULL,count,NULL);  field=(float *)malloc(nx*1*nz*sizeof(float));        //define memory hyperslab  //  offset_out[0]=0;//  offset_out[1]=0;//  count_out[0]=nx;//  count_out[1]=ny;//  status=H5Sselect_hyperslab(memspace,H5S_SELECT_SET,offset_out,NULL,count_out,NULL);  //read data from hyperslab in the file into the hyperslab in memory and display   status=H5Dread(dset_id,H5T_NATIVE_FLOAT,memspace,dataspace,H5P_DEFAULT,field);  start=0;  j=offsetY;  for(i=0; i<nx; i++)  {    for(k=0; k<nz; k++)      data[i][j][k]=field[start+k];    start+=nz;  }         free(field);  H5Dclose(dset_id);  H5Sclose(dataspace);  H5Sclose(memspace);  H5Fclose(file_id);}
开发者ID:scienter,项目名称:postprocess,代码行数:55,


示例24: check_dataset

/*------------------------------------------------------------------------- * Function:    check_dataset * * Purpose:     For a given dataset, checks to make sure that the stated *              and actual sizes are the same.  If they are not, then *              we have an inconsistent dataset due to a SWMR error. * * Parameters:  hid_t fid *              The SWMR test file's ID. * *              unsigned verbose *              Whether verbose console output is desired. * *              const symbol_info_t *symbol *              The dataset from which to read (the ID is in the struct). *              Must be pre-allocated. * *              symbol_t *record *              Memory for the record.  Must be pre-allocated. * *              hid_t rec_sid *              The memory dataspace for access.  It's always the same so *              there is no need to re-create it every time this function *              is called. * * Return:      Success:    0 *              Failure:    -1 * *------------------------------------------------------------------------- */static intcheck_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t *record,    hid_t rec_sid){    hid_t dsid;                 /* Dataset ID */    hid_t file_sid;             /* Dataset's space ID */    hsize_t start[2] = {0, 0};  /* Hyperslab selection values */    hsize_t count[2] = {1, 1};  /* Hyperslab selection values */    HDassert(fid >= 0);    HDassert(symbol);    HDassert(record);    HDassert(rec_sid >= 0);    /* Open dataset for symbol */    if((dsid = H5Dopen2(fid, symbol->name, H5P_DEFAULT)) < 0)        return -1;    /* Get the dataset's dataspace */    if((file_sid = H5Dget_space(dsid)) < 0)        return -1;    /* Choose the random record in the dataset (will be the same as chosen by     * the writer) */    start[1] = (hsize_t)HDrandom() % symbol->nrecords;    if(H5Sselect_hyperslab(file_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0)        return -1;    /* Emit informational message */    if(verbose)        HDfprintf(stderr, "Symbol = '%s', location = %lld/n", symbol->name, (long long)start);    /* Read record from dataset */    record->rec_id = (uint64_t)ULLONG_MAX;    if(H5Dread(dsid, symbol_tid, rec_sid, file_sid, H5P_DEFAULT, record) < 0)        return -1;    /* Verify record value */    if(record->rec_id != start[1]) {        HDfprintf(stderr, "*** ERROR ***/n");        HDfprintf(stderr, "Incorrect record value!/n");        HDfprintf(stderr, "Symbol = '%s', location = %lld, record->rec_id = %llu/n", symbol->name, (long long)start, (unsigned long long)record->rec_id);        return -1;    } /* end if */    /* Close the dataset's dataspace */    if(H5Sclose(file_sid) < 0)        return -1;    /* Close dataset for symbol */    if(H5Dclose(dsid) < 0)        return -1;    return 0;} /* end check_dataset() */
开发者ID:aleph7,项目名称:HDF5Kit,代码行数:85,


示例25: saveMetaData

void saveMetaData(char *fileName,char *dataName,int *data){  hid_t file_id,dset_id,filespace;  hsize_t metaDim[1];  herr_t status;  file_id=H5Fopen(fileName,H5F_ACC_RDWR,H5P_DEFAULT);  filespace=H5Screate_simple(1,metaDim,NULL);  dset_id=H5Dopen2(file_id,dataName,H5P_DEFAULT);  status=H5Dread(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,data);  H5Dclose(dset_id);  H5Sclose(filespace);  H5Fclose(file_id);}
开发者ID:scienter,项目名称:postprocess,代码行数:14,


示例26: H5Dopen2

//--------------------------------------------------------------------------// Function:	CommonFG::openDataSet////brief	Opens an existing dataset at this location.////param	name  - IN: Name of the dataset to open////return	DataSet instance////exception	H5::FileIException or H5::GroupIException// Programmer	Binh-Minh Ribler - 2000//--------------------------------------------------------------------------DataSet CommonFG::openDataSet( const char* name ) const{   // Call C function H5Dopen2 to open the specified dataset, giving   // the location id and the dataset's name   hid_t dataset_id = H5Dopen2( getLocId(), name, H5P_DEFAULT );   // If the dataset's opening failed, throw an exception   if(dataset_id < 0)      throwException("openDataSet", "H5Dopen2 failed");   // No failure, create and return the DataSet object   DataSet dataset( dataset_id );   return( dataset );}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:22,


示例27: get_max_id

static herr_t get_max_id( hid_t group_id,                           const char* subgroup,                           const char* datatable,                          unsigned long* data ){  unsigned long id;  hid_t elem_id, conn_id, attr_id, space_id;  herr_t rval;  int rank;  hsize_t dims[2];  #if defined(H5Gopen_vers) && H5Gopen_vers > 1    elem_id = H5Gopen2( group_id, subgroup, H5P_DEFAULT );#else  elem_id = H5Gopen( group_id, subgroup );#endif  if (elem_id < 0) return (herr_t)-1;  #if defined(H5Dopen_vers) && H5Dopen_vers > 1    conn_id = H5Dopen2( elem_id, datatable, H5P_DEFAULT );#else  conn_id = H5Dopen( elem_id, datatable );#endif  H5Gclose( elem_id );  if (conn_id < 0) return (herr_t)-1;    space_id = H5Dget_space( conn_id );  if (space_id < 0) { H5Dclose( conn_id ); return -1; }    rank = H5Sget_simple_extent_ndims( space_id );  if (rank <= 0 || rank > 2) { H5Dclose(conn_id); H5Sclose(space_id); return -1; }    rval = H5Sget_simple_extent_dims( space_id, dims, NULL );  H5Sclose( space_id );  if (rval < 0) { H5Dclose( conn_id ); return -1; }    attr_id = H5Aopen_name( conn_id, START_ID_ATTRIB );  H5Dclose( conn_id );  if (attr_id < 0) return (herr_t)-1;    rval = H5Aread( attr_id, H5T_NATIVE_ULONG, &id );  H5Aclose( attr_id );  if (rval < 0) return rval;    id += dims[0];  if (id > *data)    *data = id;  return 0;}
开发者ID:chrismullins,项目名称:moab,代码行数:49,


示例28: test_no_read_when_plugins_disabled

/*------------------------------------------------------------------------- * Function:  test_no_read_when_plugins_disabled * * Purpose:   Ensures we can't read data from a dataset that requires a *            filter located in a plugin. * * Return:    SUCCEED/FAIL * *------------------------------------------------------------------------- */static herr_ttest_no_read_when_plugins_disabled(hid_t fid){    hid_t       did = -1;               /* Dataset ID */    unsigned    plugin_flags;           /* Plugin access flags */    TESTING("filter plugin 1 with filter plugins disabled");    /* Get the existing plugin flags */    if (H5PLget_loading_state(&plugin_flags) < 0)        TEST_ERROR;    /* Disable filter plugins and use the new flags */    plugin_flags &= (unsigned)(~H5PL_FILTER_PLUGIN);    if (H5PLset_loading_state(plugin_flags) < 0)        TEST_ERROR;    /* Open a dataset that requires a filter plugin to read the data */    if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0)        TEST_ERROR;    /* Make sure we can't read the data */    if (ensure_data_read_fails(did) < 0)        TEST_ERROR;    /* Close down */    if (H5Dclose(did) < 0)        TEST_ERROR;    /* Re-enable filter plugins */    plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN;    if (H5PLset_loading_state(plugin_flags) < 0)        TEST_ERROR;    return SUCCEED;error:    /* Clean up objects used for this test */    H5E_BEGIN_TRY {        plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN;        H5PLset_loading_state(plugin_flags);        H5Dclose(did);    } H5E_END_TRY    return FAIL;} /* end test_no_read_when_plugins_disabled() */
开发者ID:Starlink,项目名称:hdf5,代码行数:56,



注:本文中的H5Dopen2函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ H5Dread函数代码示例
C++ H5Dopen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。