本文整理汇总了C++中h5::DataSpace类的典型用法代码示例。如果您正苦于以下问题:C++ DataSpace类的具体用法?C++ DataSpace怎么用?C++ DataSpace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataSpace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
void Bundle2::storeParameters(H5::H5File& file) const {
H5::Group root = file.openGroup("/");
H5::DataSpace scalar;
H5::Attribute attr = root.createAttribute("version", H5::PredType::STD_U32LE, scalar);
attr.write(H5::PredType::NATIVE_UINT, &version_);
attr.close();
unsigned char r2 = parameters_.reduce2?1:0;
attr = root.createAttribute("reduce2", H5::PredType::STD_U8LE, scalar);
attr.write(H5::PredType::NATIVE_UCHAR, &r2);
attr.close();
attr = root.createAttribute("xROI", H5::PredType::STD_U32LE, scalar);
attr.write(H5::PredType::NATIVE_UINT, ¶meters_.xROI);
attr.close();
attr = root.createAttribute("yROI", H5::PredType::STD_U32LE, scalar);
attr.write(H5::PredType::NATIVE_UINT, ¶meters_.yROI);
attr.close();
scalar.close();
root.close();
}
开发者ID:ttnguyenUBP,项目名称:T3DV_backup,代码行数:25,代码来源:bundle2.cpp
示例2:
void HDFAtom<std::vector<std::string> >::Read(std::vector<std::string> &values) {
std::string value;
/*
* This attribute is an array of std::strings. They are read in by
* storing pointers to std::strings in memory controlled by HDF. To read
* the std::strings, read the pointers into a temporary array, then copy
* those std::strings to the values array. This way when the values array
* is destroyed, it will not try and get rid of space that is under
* HDF control.
*/
H5::DataSpace attributeSpace = attribute.getSpace();
hsize_t nPoints;
nPoints = attributeSpace.getSelectNpoints();
H5::DataType attrType = attribute.getDataType(); // necessary for attr.read()
// Declare and initialize std::vector of pointers to std::string attribute list.
std::vector<char*> ptrsToHDFControlledMemory;
ptrsToHDFControlledMemory.resize(nPoints);
// Copy the pointers.
attribute.read(attrType, &ptrsToHDFControlledMemory[0]);
// Copy the std::strings into memory the main program has control over.
unsigned int i;
for (i = 0; i < ptrsToHDFControlledMemory.size(); i++ ){
values.push_back(ptrsToHDFControlledMemory[i]);
free(ptrsToHDFControlledMemory[i]);
}
}
开发者ID:outpaddling,项目名称:blasr_libcpp,代码行数:27,代码来源:HDFAtom.cpp
示例3: addrow
void addrow( H5::DataSet& ds, const std::vector<double>& rowtowrite )
{
//Get the space (since it may have grown in length since last time of course )
H5::DataSpace origspace = ds.getSpace();
//get the rank, even though I know it is 2
int rank = origspace.getSimpleExtentNdims();
//Get the actual dimensions of the ranks.
hsize_t dims[rank];
int ndims = origspace.getSimpleExtentDims( dims, NULL);
//Want to ADD a row, so need to offset at row = nrows, and col = 0;
hsize_t offset[rank] = { dims[0], 0 };
hsize_t dims_toadd[rank] = { 1, rowtowrite.size() }; //will write 1 row, ncols columns.
//Compute "new" size (extended by 1 row).
hsize_t size[rank] = { dims[0]+dims_toadd[0], rowtowrite.size() };
//Do the extension.
ds.extend( size );
//Get the new (extended) space, and select the hyperslab to write the row to.
origspace = ds.getSpace();
origspace.selectHyperslab( H5S_SELECT_SET, dims_toadd, offset );
//Make the "memory" data space?
H5::DataSpace toaddspace(rank, dims_toadd);
ds.write( rowtowrite.data(), H5::PredType::NATIVE_DOUBLE, toaddspace, origspace );
//Can close toaddspace/origspace with no effect.
//Can also close/open data set at the beginning of each time with no effect.
}
开发者ID:flyingfalling,项目名称:psweep2,代码行数:34,代码来源:testhdf5ids.cpp
示例4:
void ossim_hdf5::getExtents( const H5::DataSet* dataset,
std::vector<ossim_uint32>& extents )
{
extents.clear();
if ( dataset )
{
// Get dataspace of the dataset.
H5::DataSpace dataspace = dataset->getSpace();
// Number of dimensions:
int ndims = dataspace.getSimpleExtentNdims();
if ( ndims )
{
//hsize_t dims_out[ndims];
std::vector<hsize_t> dims_out(ndims);
dataspace.getSimpleExtentDims( &dims_out.front(), 0 );
for ( ossim_int32 i = 0; i < ndims; ++i )
{
extents.push_back(static_cast<ossim_uint32>(dims_out[i]));
}
}
dataspace.close();
}
}
开发者ID:bradh,项目名称:ossim-plugins,代码行数:26,代码来源:ossimH5Util.cpp
示例5: columnData
void Hdf5Handler::getColumnEntries(
void* data,
const std::string& dataSetName,
const hsize_t numEntries,
const hsize_t offset) const
{
try
{
const ColumnData& columnData(getColumnData(dataSetName));
columnData.dataSpace.selectHyperslab(
H5S_SELECT_SET,
&numEntries,
&offset);
const hsize_t outOffset = 0;
const H5::DataSpace outSpace(1, &numEntries);
outSpace.selectHyperslab(H5S_SELECT_SET, &numEntries, &outOffset);
columnData.dataSet.read(
data,
columnData.predType,
outSpace,
columnData.dataSpace);
}
catch (const H5::Exception&)
{
throw hdf5_error("Could not read from dataset");
}
}
开发者ID:devrimgunduz,项目名称:PDAL,代码行数:30,代码来源:Hdf5Handler.cpp
示例6: GetDatasetNDim
UInt GetDatasetNDim(H5::CommonFG &parentGroup, std::string datasetName) {
HDFData tmpDataset;
tmpDataset.InitializeDataset(parentGroup, datasetName);
H5::DataSpace dataspace = tmpDataset.dataset.getSpace();
UInt nDims = dataspace.getSimpleExtentNdims();
dataspace.close();
tmpDataset.dataset.close();
return nDims;
}
开发者ID:outpaddling,项目名称:blasr_libcpp,代码行数:9,代码来源:BufferedHDF2DArray.cpp
示例7:
int H5Signal::signal_count(void)
/*----------------------------*/
{
H5::DataSpace uspace = dataset.openAttribute("uri").getSpace() ;
int udims = uspace.getSimpleExtentNdims() ;
if (udims == 0) return 1 ; // SCALAR
else {
if (udims != 1) throw H5Exception("Dataset's 'uri' attribute has wrong shape: " + uri) ;
return uspace.getSimpleExtentNpoints() ;
}
}
开发者ID:dbrnz,项目名称:libbsml_V1,代码行数:11,代码来源:h5signal.cpp
示例8: memspace
/**
* @brief Returns a pointer to a std::vector<float> containing the values of the selected variable
*
* This allocates a new std::vector<float> pointer. Make sure you
* delete the contents when you done using it, or you will have a memory leak.
*
* @param variable
* @return std::vector<float> containing the values of the selected variable.
*/
std::vector<float>* HDF5FileReader::getVariable(const std::string& variable)
{
std::vector<float>* variableData = new std::vector<float>();
if (this->doesVariableExist(variable))
{
//std::cout << "reading " << variable << std::endl;
//get variable number
// long variableNum = this->getVariableID(variable);
//std::cout << "variableNum for " << variable << ": " << variableNum << std::endl;
//get dim sizes
H5::Group group = this->current_file->openGroup("Variables");
//cout << "variable: " << variable << ": " << counts[0] << endl;
H5::DataSet * dataset = new H5::DataSet(group.openDataSet(variable));
H5::DataSpace dataspace = dataset->getSpace();
int rank = dataspace.getSimpleExtentNdims(); //should be 1
hsize_t count[1];
hsize_t offset[1] = {0};
// int ndims = dataspace.getSimpleExtentDims(count, NULL);
//std::cout << "count[0]: " << count[0] << std::endl;
float * buffer = new float[count[0]];
dataspace.selectHyperslab(H5S_SELECT_SET, count, offset);
H5::DataSpace memspace( rank, count);
memspace.selectHyperslab(H5S_SELECT_SET, count, offset);
dataset->read(buffer, H5::PredType::NATIVE_FLOAT, memspace, dataspace);
//std::cout << "after read" << std::endl;
//add data to vector type, and delete original array
variableData->reserve(count[0]);
for (int i = 0; i < count[0]; i++)
{
variableData->push_back(buffer[i]);
}
//std::cout << "after adding to variableData vector" << std::endl;
delete[] buffer;
delete dataset;
//std::cout << "finished reading " << variable << std::endl;
//std::cout << "size of variable: " << variableData.size() << std::endl;
//std::cout << "dimSizes[0]: " << dimSizes[0] << std::endl;
}
return variableData;
}
开发者ID:NeelSavani,项目名称:ccmc-software,代码行数:62,代码来源:HDF5FileReader.cpp
示例9: runtime_error
const std::vector<hsize_t> TableDims(){
if(flags_ != hdf5::READ)
throw std::runtime_error("TableDims() is only valid in READ mode");
H5::DataSet dSet = file_->openDataSet("T00000000");
H5::DataSpace dSpace = dSet.getSpace();
std::vector<hsize_t> dims(dSpace.getSimpleExtentNdims());
dSpace.getSimpleExtentDims(&dims[0]);
return dims;
}
开发者ID:rseal,项目名称:HDF5R,代码行数:13,代码来源:HDF5.hpp
示例10: dataspace_from_LS
H5::DataSpace dataspace_from_LS (
mini_vector<hsize_t, R> const & Ltot,
mini_vector<hsize_t, R> const & L,
mini_vector<hsize_t, R> const & S,
mini_vector<hsize_t, R> const & offset = mini_vector<hsize_t,R>() )
{
static const unsigned int rank = R + (IsComplex ? 1 : 0);
hsize_t totdimsf[rank], dimsf [rank], stridesf[rank], offsetf[rank]; // dataset dimensions
for (size_t u=0; u<R ; ++u) { offsetf[u] = offset[u]; dimsf[u] = L[u]; totdimsf[u] = Ltot[u]; stridesf[u] = S[u]; }
if (IsComplex) { offsetf[rank-1]=0; dimsf[rank-1]=2; totdimsf[rank-1] = 2; stridesf[rank-1]=1; }
H5::DataSpace ds ( rank, totdimsf );
ds.selectHyperslab (H5S_SELECT_SET , dimsf, offsetf, stridesf);
return ds;
}
开发者ID:EBRUDU1,项目名称:triqs,代码行数:14,代码来源:base.hpp
示例11: range_error
NDArray<T, Nd> NDArray<T,Nd>::ReadFromH5(const H5::DataSet& h5Dset) {
H5::DataSpace dspace = h5Dset.getSpace();
int ndim = dspace.getSimpleExtentNdims();
if (ndim>Nd)
throw std::range_error("Too many dimensions in H5 dataset for NDArray");
hsize_t dimSize[ndim];
dspace.getSimpleExtentDims(dimSize);
std::array<std::size_t, Nd> dimSizeArr;
for (int i=0; i<Nd; ++i) dimSizeArr[i] = dimSize[i];
NDArray<T, Nd> arr(dimSizeArr);
// Read in data here
H5::DataType h5DType = GetH5DataType<T>();
h5Dset.read(arr.mData, h5DType);
return arr;
}
开发者ID:ermalrrapaj,项目名称:two_phase_skyrme,代码行数:15,代码来源:NDArray.hpp
示例12: getGroup
void HDF5IO::loadStdVector(const std::string& GroupName, const std::string& Name,
std::vector<RealType>& V)
{
try{
H5::Group FG = getGroup( GroupName );
H5::DataSet DataSet = FG.openDataSet(Name.c_str());
H5::DataSpace DataSpace = DataSet.getSpace();
if(DataSpace.getSimpleExtentNdims() != 1)
throw(H5::DataSpaceIException("HDF5IO::loadRealVector()","Unexpected multidimentional dataspace."));
V.resize(DataSpace.getSimpleExtentNpoints());
DataSet.read(V.data(),H5::PredType::NATIVE_DOUBLE);
FG.close();
} catch( const H5::Exception err ){
RUNTIME_ERROR("HDF5IO::loadRealStdVector");
}
}
开发者ID:chengyanlai,项目名称:ExactDiagonalization,代码行数:16,代码来源:hdf5io.cpp
示例13: mem_space
inline void
read_values(H5::DataSet& dataset, H5::DataSpace& data_space,
dimension const& dimx, dimension const& dimy, dimension const& dimz,
double* values)
{
using namespace H5;
// Define the hyperslab for file based data.
hsize_t data_offset[dimension::dim] = {
dimx.offset_, dimy.offset_, dimz.offset_
};
hsize_t data_count[dimension::dim] = {
dimx.count_, dimy.count_, dimz.count_
};
data_space.selectHyperslab(H5S_SELECT_SET, data_count, data_offset);
// Memory dataspace.
DataSpace mem_space (dimension::dim, data_count);
// Define the hyperslab for data in memory.
hsize_t mem_offset[dimension::dim] = { 0, 0, 0 };
mem_space.selectHyperslab(H5S_SELECT_SET, data_count, mem_offset);
// Read data to memory.
dataset.read(values, PredType::NATIVE_DOUBLE, mem_space, data_space);
}
开发者ID:brycelelbach,项目名称:hpx,代码行数:26,代码来源:read_values.cpp
示例14: clk
size_t H5Signal::clock_size(void)
/*-----------------------------*/
{
try {
H5::Attribute attr = dataset.openAttribute("clock") ;
hobj_ref_t ref ;
attr.read(H5::PredType::STD_REF_OBJ, &ref) ;
attr.close() ;
H5::DataSet clk(H5Rdereference(H5Iget_file_id(dataset.getId()), H5R_OBJECT, &ref)) ;
H5::DataSpace cspace = clk.getSpace() ;
int cdims = cspace.getSimpleExtentNdims() ;
hsize_t cshape[cdims] ;
cspace.getSimpleExtentDims(cshape) ;
return cshape[0] ;
}
catch (H5::AttributeIException e) { }
return -1 ;
}
开发者ID:dbrnz,项目名称:libbsml_V1,代码行数:18,代码来源:h5signal.cpp
示例15: GetDsDims
/** Retrieves the dimensions of the dataset */
int hdfutil::GetDsDims (const H5::DataSet & dataset, int dims[3]) {
H5::DataSpace dataspace = dataset.getSpace();
bool simple = dataspace.isSimple();
if (!simple)
throw std::runtime_error("complex HDF5 dataspace");
int rank = (int)dataspace.getSimpleExtentNdims();
if (rank > 3)
throw std::runtime_error("unsupported dimensionality");
hsize_t h5_dims[3];
dataspace.getSimpleExtentDims(h5_dims, NULL);
for (int i = 0; i < rank; i++)
dims[i] = (int)h5_dims[i];
for (int i = rank; i < 3; i++)
dims[i] = -1;
return rank;
}
开发者ID:NaohiroHayashi,项目名称:bulletsim,代码行数:19,代码来源:hdfutil.cpp
示例16: getNodeType
bool readDataset1D(const H5::H5File &file, const std::string &name, std::vector<_Tp> &data)
{
H5::DataSet dataset = file.openDataSet(name);
H5::DataSpace dataspace = dataset.getSpace();
hsize_t dims_out[1];
int rank = dataspace.getSimpleExtentDims( dims_out, NULL);
int _type;
bool read = getNodeType(dataset, _type);
read &= (_type == StorageNode::SEQ);
read &= (rank == 1);
if (!read)
return read;
data.resize(dims_out[0]);
dataset.read(data.data(), dataset.getDataType());
return true;
}
开发者ID:yxliang,项目名称:binaryStorage,代码行数:18,代码来源:h5persistence.hpp
示例17: memspace
arma::Mat<uint16_t> readLUT(const std::string& path)
{
H5::H5File file (path.c_str(), H5F_ACC_RDONLY);
H5::DataSet ds = file.openDataSet("LUT");
H5::DataSpace filespace = ds.getSpace();
int ndims = filespace.getSimpleExtentNdims();
assert(ndims == 2);
hsize_t dims[2] = {1, 1};
filespace.getSimpleExtentDims(dims);
H5::DataSpace memspace (ndims, dims);
arma::Mat<uint16_t> res (dims[0], dims[1]);
ds.read(res.memptr(), H5::PredType::NATIVE_UINT16, memspace, filespace);
filespace.close();
memspace.close();
ds.close();
file.close();
// NOTE: Armadillo stores data in column-major order, while HDF5 uses
// row-major ordering. Above, we read the data directly from HDF5 into
// the arma matrix, so it was implicitly transposed. The next function
// fixes this problem.
arma::inplace_trans(res);
return res;
}
开发者ID:jbradt,项目名称:mcopt,代码行数:29,代码来源:utils.cpp
示例18: strdatatype
/// Return the attribute name of obj, and "" if the attribute does not exist.
inline std::string read_string_attribute (H5::H5Object const * obj, std::string name ) {
std::string value ="";
H5::Attribute attr;
if (H5LTfind_attribute(obj -> getId(), name.c_str() )==0) return value;// not present
// can not find how to get the size with hl. Using full interface
//herr_t err2 = H5LTget_attribute_string(gr.getId(), x.c_str(), name.c_str() , &(buf.front()) ) ;
//value.append( &(buf.front()) );
try { attr= obj->openAttribute(name.c_str());}
catch (H5::AttributeIException) { return value;}
try {
H5::DataSpace dataspace = attr.getSpace();
int rank = dataspace.getSimpleExtentNdims();
if (rank != 0) TRIQS_RUNTIME_ERROR << "Reading a string attribute and got rank !=0";
size_t size = attr.getStorageSize();
H5::StrType strdatatype(H5::PredType::C_S1, size+1);
std::vector<char> buf(size+1, 0x00);
attr.read(strdatatype, (void *)(&buf[0]));
value.append( &(buf.front()) );
}
TRIQS_ARRAYS_H5_CATCH_EXCEPTION;
return value;
}
开发者ID:EBRUDU1,项目名称:triqs,代码行数:23,代码来源:base.hpp
示例19: read_attr
static void read_attr(Attribute *attr, H5::Group g, cpath basename, cpath group_path, cpath name, BaseType &type)
{
int total = 1;
H5::Attribute h5attr = g.openAttribute(name.generic_string().c_str());
type = toBaseType(H5Aget_type(h5attr.getId()));
H5::DataSpace space = h5attr.getSpace();
int dimcount = space.getSimpleExtentNdims();
hsize_t *dims = new hsize_t[dimcount];
hsize_t *maxdims = new hsize_t[dimcount];
space.getSimpleExtentDims(dims, maxdims);
for(int i=0;i<dimcount;i++)
total *= dims[i];
group_path = remove_prefix(group_path, basename);
name = group_path / name;
//legacy attribute reading
if (dimcount == 1) {
void *buf = malloc(baseType_size(type)*total);
h5attr.read(toH5NativeDataType(type), buf);
attr->set<hsize_t>(name, dimcount, dims, type, buf);
}
else {
Mat m;
Mat_H5AttrRead(m, h5attr);
attr->setName(name);
attr->set(m);
}
delete[] dims;
delete[] maxdims;
}
开发者ID:g-manfredi,项目名称:clif,代码行数:38,代码来源:attribute.cpp
示例20: write_time_step_history
void Datafile::write_time_step_history(size_t index, double eps) {
// pack values of index and eps into a struct in memory
time_step_history_pair pair;
pair.step = static_cast<int>(index);
pair.time_step = eps;
try {
ensure_time_step_history_data();
// calculate current size, extend if needed, and write data. You know the drill.
H5::DataSpace tempspace = time_step_history_data.getSpace();
tempspace.selectAll();
hsize_t cur_size = tempspace.getSelectNpoints();
hsize_t new_size = cur_size + 1;
space_1d.setExtentSimple(1, &new_size);
time_step_history_data.extend(&new_size);
space_1d.selectElements(H5S_SELECT_SET, 1, &cur_size);
validate_selection(space_1d);
time_step_history_data.write(&pair, time_step_history_type, scalar_space, space_1d);
}
catch(H5::Exception& e) {
e.printError();
throw;
}
}
开发者ID:borunda,项目名称:itp2d,代码行数:23,代码来源:datafile.cpp
注:本文中的h5::DataSpace类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论