当前位置: 首页>>代码示例>>C++>>正文


C++ H5Dopen2函数代码示例

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


在下文中一共展示了H5Dopen2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:ionstats_data.cpp

示例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,代码来源:fast5files.cpp

示例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_t
test_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,代码来源:plugin.c

示例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,代码来源:readfile.cpp

示例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,代码来源:H5IM.c

示例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,代码来源:HDF5io.hpp

示例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,代码来源:gen_test_ds.c

示例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_f
h5dopen_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,代码来源:H5Df.c

示例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_t
test_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,代码来源:error_test.c

示例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_t
test_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,代码来源:plugin.c

示例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,代码来源:gen_test_ds.c

示例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,代码来源:H5IMcc.c

示例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,代码来源:be_hdf5.c

示例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,代码来源:material.cpp

示例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,代码来源:hdf5_dataset.cpp


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