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


C++ H5Dget_space函数代码示例

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


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

示例1: H5VLARRAYmodify_records

herr_t H5VLARRAYmodify_records( hid_t dataset_id,
                                hid_t type_id,
                                hsize_t nrow,
                                int nobjects,
                                const void *data )
{

    hid_t    space_id;
    hid_t    mem_space_id;
    hsize_t  start[1];
    hsize_t  dims_new[1] = {1};    /* Only a record on each update */
    hvl_t    wdata;   /* Information to write */

    /* Initialize VL data to write */
    wdata.p=(void *)data;
    wdata.len=nobjects;

    /* Create a simple memory data space */
    if ( (mem_space_id = H5Screate_simple( 1, dims_new, NULL )) < 0 )
        return -1;

    /* Get the file data space */
    if ( (space_id = H5Dget_space( dataset_id )) < 0 )
        return -1;

    /* Define a hyperslab in the dataset */
    start[0] = nrow;
    if ( H5Sselect_hyperslab( space_id, H5S_SELECT_SET, start, NULL, dims_new, NULL) < 0 )
        goto out;

    if ( H5Dwrite( dataset_id, type_id, mem_space_id, space_id, H5P_DEFAULT, &wdata ) < 0 )
        goto out;

    /* Terminate access to the dataspace */
    if ( H5Sclose( space_id ) < 0 )
        goto out;

    if ( H5Sclose( mem_space_id ) < 0 )
        goto out;

    return 1;

out:
    return -1;

}
开发者ID:r0k3,项目名称:PyTables,代码行数:46,代码来源:H5VLARRAY.c

示例2: H5Sclose

int H5mdfile::H5_Dextend(int argc, char **argv, Tcl_Interp *interp)
{
    /* Extend dataset to higher dimensions */
    H5Sclose(dataspace_id);
    for(int i=0;i<dataset_rank;i++)
    {

     if(atoi(argv[3+i])>(int)dims[i])
     {
         dims[i]=atoi(argv[3+i])-dimstotal[i];
     }
     dimstotal[i] = atoi(argv[3+i]);
    }
    status = H5Dset_extent(dataset_id, dimstotal);
    dataspace_id = H5Dget_space(dataset_id);
    return TCL_OK;
}
开发者ID:Clemson-MSE,项目名称:espresso,代码行数:17,代码来源:h5mdfile_tcl.cpp

示例3: main

int main (int argc, char ** argv) 
{
    char        filename [256];
    int         rank, size, i, j;
    uint64_t start[2], count[2], bytes_read = 0;
    int ndims, nsf;
    hid_t file;
    hid_t dataset;
    hid_t filespace;
    hid_t memspace;

    int data_out[size];

    struct timeval t1;
    gettimeofday (&t1, NULL);

        file = H5Fopen("write_test.h5", H5F_ACC_RDONLY, H5P_DEFAULT);
        dataset = H5Dopen(file, "index");
        filespace = H5Dget_space(dataset);    /* Get filespace handle first. */
        ndims     = H5Sget_simple_extent_ndims(filespace);

        hsize_t dims[ndims];
        herr_t status_n  = H5Sget_simple_extent_dims(filespace, dims, NULL);
/*
    printf("dataset(temperature) rank %d, dimensions %lux%lu\n",
               ndims, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
*/
    /*
     * Define the memory space to read dataset.
     */
        memspace = H5Screate_simple(ndims,dims,NULL);

        double data[dims[0]];
    /*
     * Read dataset back and display.
     */
        herr_t status = H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, filespace,
                         H5P_DEFAULT, data);

    struct timeval t2;
    gettimeofday (&t2, NULL);

    printf ("read time = %f\n", t2.tv_sec + t2.tv_usec/1000000.0 - t1.tv_sec - t1.tv_usec/1000000.0); 
    return 0;
}
开发者ID:qliu21,项目名称:read-aio,代码行数:45,代码来源:test_read.c

示例4: freeStringMatrix

int freeStringMatrix(int _iDatasetId, char** _pstData)
{
    herr_t status;
    hid_t typeId;
    hid_t space;

    if (_iDatasetId == -1)
    {
        return 0;
    }

    typeId = H5Tcopy(H5T_C_S1);
    status = H5Tset_size(typeId, H5T_VARIABLE);
    if (status < 0)
    {
        return -1;
    }

    space = H5Dget_space (_iDatasetId);
    status = H5Dvlen_reclaim (typeId, space, H5P_DEFAULT, _pstData);
    if (status < 0)
    {
        return -1;
    }

    status = H5Sclose(space);
    if (status < 0)
    {
        return -1;
    }

    status = H5Tclose(typeId);
    if (status < 0)
    {
        return -1;
    }

    status = H5Dclose(_iDatasetId);
    if (status < 0)
    {
        return -1;
    }

    return 0;
}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:45,代码来源:h5_readDataFromFile.c

示例5: H5Fopen

void FWSingle::readInLong(int step, string IDstring, vector<long>& data_out)
{
  int RANK=1;
  hid_t       dataset;
  hid_t       filespace;
  hid_t       memspace;
  hid_t       cparms;
  hsize_t     dims[1];                     /* dataset and chunk dimensions*/
  hsize_t     chunk_dims[1];
  herr_t      status, status_n;
  int         rank, rank_chunk;
  hsize_t hi, hj;
  c_file = H5Fopen(fname.str().c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
  stringstream gname("");
  gname<<"Block_"<< step;
  hid_t d_file = H5Gopen(c_file,gname.str().c_str());
  dataset = H5Dopen(d_file, IDstring.c_str());
  filespace = H5Dget_space(dataset);
  rank = H5Sget_simple_extent_ndims(filespace);
  status_n  = H5Sget_simple_extent_dims(filespace, dims, NULL);
  //     if (verbose>1) printf("dataset ",IDstring.c_str(),"rank %d, dimensions %lu x %lu\n", rank, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
  data_out.resize(dims[0]);
  cparms = H5Dget_create_plist(dataset);
  if (H5D_CHUNKED == H5Pget_layout(cparms))
  {
    rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims);
    //       if (verbose>1) printf("chunk rank %d, dimensions %lu \n", rank_chunk, (unsigned long)(chunk_dims[0]) );
  }
  memspace = H5Screate_simple(RANK,dims,NULL);
  status = H5Dread(dataset, H5T_NATIVE_LONG, memspace, filespace, H5P_DEFAULT, &(data_out[0]));
  //     if(verbose>2)
  //     {
  //       printf("\n");
  //       app_log()<<IDstring.c_str()<<" Dataset: \n"<<endl;
  //       for (int j = 0; j < dims[0]; j++) app_log()<<data_out[j]<<" ";
  //       app_log()<<endl;
  //     }
  H5Pclose(cparms);
  H5Dclose(dataset);
  H5Sclose(filespace);
  H5Sclose(memspace);
  H5Gclose(d_file);
  H5Fclose(c_file);
}
开发者ID:jyamu,项目名称:qmc,代码行数:44,代码来源:FWSingle.cpp

示例6: gridReaderHDF5_readIntoPatchForVar

extern void
gridReaderHDF5_readIntoPatchForVar(gridReader_t reader,
                                   gridPatch_t  patch,
                                   int          idxOfVar)
{
	assert(reader != NULL);
	assert(reader->type = GRIDIO_TYPE_HDF5);
	assert(patch != NULL);
	assert(idxOfVar >= 0 && idxOfVar < gridPatch_getNumVars(patch));

	hid_t             dataSet;
	hid_t             dataSpaceFile, dataTypeFile;
	hid_t             dataSpacePatch, dataTypePatch;
	gridPointUint32_t idxLoPatch, dimsPatch;
	dataVar_t         var   = gridPatch_getVarHandle(patch, idxOfVar);
	void              *data = gridPatch_getVarDataHandle(patch, idxOfVar);

	gridPatch_getIdxLo(patch, idxLoPatch);
	gridPatch_getDims(patch, dimsPatch);

	dataSet        = H5Dopen(((gridReaderHDF5_t)reader)->file,
	                         dataVar_getName(var), H5P_DEFAULT);
	dataTypeFile   = H5Dget_type(dataSet);
	dataSpaceFile  = H5Dget_space(dataSet);

	dataTypePatch  = dataVar_getHDF5Datatype(var);
	dataSpacePatch = gridUtilHDF5_getDataSpaceFromDims(dimsPatch);

	gridUtilHDF5_selectHyperslab(dataSpaceFile, idxLoPatch, dimsPatch);

	if (H5Tequal(dataTypeFile, dataTypePatch)) {
		H5Dread(dataSet, dataTypeFile, dataSpacePatch,
		        dataSpaceFile, H5P_DEFAULT, data);
	} else {
		fprintf(stderr, "ERROR: Datatype in memory differs from file.\n");
		diediedie(EXIT_FAILURE);
	}

	H5Sclose(dataSpacePatch);
	H5Tclose(dataTypePatch);
	H5Sclose(dataSpaceFile);
	H5Tclose(dataTypeFile);
	H5Dclose(dataSet);
} /* gridReaderHDF5_readIntoPatchForVar */
开发者ID:satlank,项目名称:ginnungagap,代码行数:44,代码来源:gridReaderHDF5.c

示例7: H5TBOread_records

herr_t H5TBOread_records( hid_t dataset_id,
                          hid_t mem_type_id,
                          hsize_t start,
                          hsize_t nrecords,
                          void *data )
{

 hid_t    space_id;
 hid_t    mem_space_id;
 hsize_t  count[1];
 hsize_t  offset[1];

 /* Get the dataspace handle */
 if ( (space_id = H5Dget_space( dataset_id )) < 0 )
  goto out;

 /* Define a hyperslab in the dataset of the size of the records */
 offset[0] = start;
 count[0]  = nrecords;
 if ( H5Sselect_hyperslab(space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0 )
  goto out;

 /* Create a memory dataspace handle */
 if ( (mem_space_id = H5Screate_simple( 1, count, NULL )) < 0 )
  goto out;

 if ( H5Dread(dataset_id, mem_type_id, mem_space_id, space_id, H5P_DEFAULT, data ) < 0 )
  goto out;

 /* Terminate access to the memory dataspace */
 if ( H5Sclose( mem_space_id ) < 0 )
  goto out;

 /* Terminate access to the dataspace */
 if ( H5Sclose( space_id ) < 0 )
  goto out;

return 0;

out:
 return -1;

}
开发者ID:tomkooij,项目名称:PyTables,代码行数:43,代码来源:H5TB-opt.c

示例8: fh5d_open_

void fh5d_open_(char *dname, int *hdferr)
{

extern hid_t fileid;
herr_t herr;

dsetid = H5Dopen(fileid, dname);
//printf("fh5d_open: %d\n",dsetid);

if (dsetid < 0) { *hdferr = dsetid; return;}


dspcid = H5Dget_space(dsetid);
//printf("fh5d_get_space: %d\n",dspcid);

*hdferr = dspcid;

return;
}
开发者ID:abudnick,项目名称:TigerED,代码行数:19,代码来源:hdf5_f2c.c

示例9: get_data

	// Extract information from HDF5 file
	void get_data(std::string data_path, std::string dataset_name, std::vector<double> &data_out){

		//  Declare variables 
		const char *fname = data_path.c_str();
		hid_t  file_id , dataset_id , dataspace_id , file_dataspace_id;
		hsize_t* dims;
		hssize_t  num_elem;
		int rank;
		int ndims;

		// Open  existing  HDF5  file 
		file_id = H5Fopen(fname , H5F_ACC_RDONLY , H5P_DEFAULT);

		// Open  existing  dataset
		dataset_id = H5Dopen(file_id , dataset_name.c_str(), H5P_DEFAULT);

		//  Determine  dataset  parameters
		file_dataspace_id = H5Dget_space(dataset_id);
		rank = H5Sget_simple_extent_ndims(file_dataspace_id);
		dims = (hsize_t*)  malloc(rank *sizeof(hsize_t));
		ndims = H5Sget_simple_extent_dims(file_dataspace_id, dims, NULL);
		//std::cout << "rank: " << std::to_string(rank) << std::endl;

		// Allocate  matrix
		num_elem = H5Sget_simple_extent_npoints(file_dataspace_id);
		std::vector<double> data_out_tmp(num_elem);
		// = (double*)malloc(num_elem *sizeof(double));
		//std::cout << "num_elem: " << std::to_string(num_elem) << std::endl;

		// Create  dataspace
		dataspace_id = H5Screate_simple(rank , dims , NULL);

		// Read  matrix  data  from  file 
		H5Dread(dataset_id, H5T_NATIVE_DOUBLE, dataspace_id, file_dataspace_id , H5P_DEFAULT , &data_out_tmp[0]);
		data_out = data_out_tmp;
		
		//  Release  resources  and  close  file 
		H5Dclose(dataset_id);
		H5Sclose(dataspace_id);
		H5Sclose(file_dataspace_id);
		H5Fclose(file_id);
		free(dims);
	}
开发者ID:TusharGupta01,项目名称:CellNet,代码行数:44,代码来源:utils.cpp

示例10: get_rank_by_name

/*
 *  utility function to get dimensionality of a dataset
 */
int get_rank_by_name(hid_t group_id, char *name)
{

  if (!checkfordataset(group_id,name)) { return 0; }

  herr_t HDF5_error = -1;
#if H5_VERSION_GE(1,8,0)
  hid_t dataset_id   = H5Dopen2(group_id,name,H5P_DEFAULT);
#else
  hid_t dataset_id   = H5Dopen(group_id,name);
#endif
  if (dataset_id == HDF5_error) 
     { printf("ERROR opening %s data set \n",name); return 0; }

  hid_t dataspace_id = H5Dget_space(dataset_id);
  int rank           = get_rank(dataspace_id);
  H5Dclose(dataset_id);
  return rank;
}
开发者ID:amoose136,项目名称:splash,代码行数:22,代码来源:read_data_amuse_hdf5_utils.c

示例11: hdf5_object

hdf5_dataspace::hdf5_dataspace(hdf5_dataset const& dataset)
    :
      hdf5_object(H5Dget_space(dataset.get_id()))
{
    if(dataset.get_id() < 0) {
        boost::serialization::throw_exception(
            hdf5_archive_exception(
                hdf5_archive_exception::hdf5_archive_dataset_access_error
            )
        );
    }
    if(get_id() < 0) {
        boost::serialization::throw_exception(
            hdf5_archive_exception(
                hdf5_archive_exception::hdf5_archive_dataspace_access_error
            )
        );
    }
}
开发者ID:bingzhang00,项目名称:serialization,代码行数:19,代码来源:hdf5_dataspace.cpp

示例12: H5ARRAYget_info

herr_t H5ARRAYget_info( hid_t dataset_id,
			hid_t type_id,
			hsize_t *dims,
			hsize_t *maxdims,
			H5T_class_t *class_id,
			char *byteorder)
{
  hid_t       space_id;

  /* Get the class. */
  *class_id = H5Tget_class( type_id );

  /* Get the dataspace handle */
  if ( (space_id = H5Dget_space( dataset_id )) < 0 )
    goto out;

  /* Get dimensions */
  if ( H5Sget_simple_extent_dims( space_id, dims, maxdims) < 0 )
    goto out;

  /* Terminate access to the dataspace */
  if ( H5Sclose( space_id ) < 0 )
    goto out;

  /* Get the byteorder */
  /* Only integer, float, time, enumerate and array classes can be
     byteordered */
  if ((*class_id == H5T_INTEGER) || (*class_id == H5T_FLOAT)
      || (*class_id == H5T_BITFIELD) || (*class_id == H5T_COMPOUND)
      || (*class_id == H5T_TIME) || (*class_id == H5T_ENUM)
      || (*class_id == H5T_ARRAY)) {
    get_order(type_id, byteorder);
  }
  else {
    strcpy(byteorder, "irrelevant");
  }

  return 0;

out:
 return -1;

}
开发者ID:87,项目名称:PyTables,代码行数:43,代码来源:H5ARRAY.c

示例13: ASDF_write_partial_waveform

herr_t ASDF_write_partial_waveform(hid_t data_id, const float *waveform,
                                   int offset, int nsamples) {
  hid_t space_id, slab_id;

  CHK_H5(space_id = H5Dget_space(data_id));

  hsize_t start[1] = {offset};
  hsize_t count[1] = {1};
  hsize_t block[1] = {nsamples};
  CHK_H5(H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start,
                             NULL, count, block));
  CHK_H5(slab_id = H5Screate_simple(1, block, NULL));
  CHK_H5(H5Dwrite(data_id, H5T_IEEE_F32LE, slab_id, space_id,
                  H5P_DEFAULT, waveform));
  CHK_H5(H5Sclose(slab_id));
  CHK_H5(H5Sclose(space_id));

  return 0; // Success
}
开发者ID:QuLogic,项目名称:asdf-library,代码行数:19,代码来源:ASDF_write.c

示例14: cow_domain_readsize

void cow_domain_readsize(cow_domain *d, char *fname, char *dname)
{
#if (COW_HDF5)
  if (_io_check_file_exists(fname)) return;
  hid_t file = H5Fopen(fname, H5F_ACC_RDONLY, d->fapl);
  hid_t dset = H5Dopen(file, dname, H5P_DEFAULT);
  hid_t fspc = H5Dget_space(dset);
  hsize_t dims[3] = { 1, 1, 1 };
  int ndims = H5Sget_simple_extent_dims(fspc, dims, NULL);
  H5Dclose(dset);
  H5Fclose(file);
  cow_domain_setndim(d, ndims);
  for (int n=0; n<ndims; ++n) {
    cow_domain_setsize(d, n, dims[n]);
  }
  printf("[%s] inferred global domain size of (%lld %lld %lld) from %s/%s\n",
	 MODULE, dims[0], dims[1], dims[2], fname, dname);
#endif
}
开发者ID:darien0,项目名称:cow,代码行数:19,代码来源:io.c

示例15: h5_read

 void h5_read(group g, std::string const& name, std::string& value) {
  dataset ds = g.open_dataset(name);
  h5::dataspace d_space = H5Dget_space(ds);
  int rank = H5Sget_simple_extent_ndims(d_space);
  if (rank != 0) TRIQS_RUNTIME_ERROR << "Reading a string and got rank !=0";
  size_t size = H5Dget_storage_size(ds);

  datatype strdatatype = H5Tcopy(H5T_C_S1);
  H5Tset_size(strdatatype, size);
  //auto status = H5Tset_size(strdatatype, size);
  // auto status = H5Tset_size (strdatatype, H5T_VARIABLE);

  std::vector<char> buf(size + 1, 0x00);
  auto err = H5Dread(ds, strdatatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf[0]);
  if (err < 0) TRIQS_RUNTIME_ERROR << "Error reading the string named" << name << " in the group" << g.name();

  value = "";
  value.append(&(buf.front()));
 }
开发者ID:JaksaVucicevic,项目名称:triqs,代码行数:19,代码来源:string.cpp


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