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


C++ h5::DataSet类代码示例

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


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

示例1: WriteString

void hdfutil::WriteString(const H5::CommonFG& group, const std::string & dsname, const std::string & str) {
    hsize_t dims[] = {1};
    H5::DataSpace dataspace(1, dims);       // 1 string
    H5::StrType   strtype  (0, str.size()); // string length
    H5::DataSet dset = group.createDataSet(dsname, strtype, dataspace, CreatePropList());
    dset.write(&str[0], strtype);
}
开发者ID:NaohiroHayashi,项目名称:bulletsim,代码行数:7,代码来源:hdfutil.cpp

示例2: setGridNodes

bool ossimHdfGridModel::setGridNodes( H5::H5File* h5File,
                                      const std::string& latDataSetName,
                                      const std::string& lonDataSetName,
                                      ossim_uint32 imageRows,
                                      ossim_uint32 imageCols )

{
    bool status = false;

    if ( h5File )
    {
        H5::DataSet latDataSet = h5File->openDataSet( latDataSetName );
        H5::DataSet lonDataSet = h5File->openDataSet( lonDataSetName );

        try
        {
            status = setGridNodes( &latDataSet, &lonDataSet, imageRows, imageCols );
        }
        catch ( const ossimException& e )
        {
            if ( traceDebug() )
            {
                ossimNotify(ossimNotifyLevel_WARN)
                        << "ossimHdfGridModel::setGridNodes caught exception\n"
                        << e.what() << std::endl;
            }
        }

        latDataSet.close();
        lonDataSet.close();
    }

    return status;
}
开发者ID:rb-rialto,项目名称:ossim,代码行数:34,代码来源:ossimHdfGridModel.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: 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

示例5: compare_datasets

void compare_datasets(H5::DataSet const& ds1, H5::DataSet const& ds2)
{
    std::vector<hsize_t> dims(ds1.getSpace().getSimpleExtentNdims());
    ds1.getSpace().getSimpleExtentDims(&*dims.begin());

    // compare 2 or 3-dimensional list of vectors, e.g., box edges
    BOOST_REQUIRE( dims.size() == 2 );
    BOOST_REQUIRE( dims[1] == 2 || dims[1] == 3 );
    if (dims[1] == 3) {
        std::vector<halmd::fixed_vector<double, 3> > array1, array2;
        h5xx::read_dataset(ds1, array1);
        h5xx::read_dataset(ds2, array2);
        BOOST_CHECK_EQUAL_COLLECTIONS(
            array1.begin(), array1.end()
          , array2.begin(), array2.end()
        );
    }
    else if (dims[1] == 2) {
        std::vector<halmd::fixed_vector<double, 2> > array1, array2;
        h5xx::read_dataset(ds1, array1);
        h5xx::read_dataset(ds2, array2);
        BOOST_CHECK_EQUAL_COLLECTIONS(
            array1.begin(), array1.end()
          , array2.begin(), array2.end()
        );
    }
}
开发者ID:fhoefling,项目名称:halmd,代码行数:27,代码来源:compare_trajectory.cpp

示例6: LBTHROW

H5::DataSet CompartmentReportHDF5::_openDataset( const H5::H5File& file,
                                                 const uint32_t cellID )
{
    std::stringstream cellName;
    cellName << "a" << cellID;
    const std::string datasetName = "/" + cellName.str() + "/" + _reportName +
                                    "/" + dataDatasetName;
    H5::DataSet dataset;
    H5E_BEGIN_TRY
        dataset = file.openDataSet( datasetName );
    H5E_END_TRY
    if( !dataset.getId() )
    {
        LBTHROW(
            std::runtime_error( "ReportReaderHDF5: "
                              "Dataset " + datasetName + " not found "
                              "in file: " + file.getFileName( )));
    }

    if( dataset.getSpace().getSimpleExtentNdims() != 2 )
    {
        LBTHROW(
            std::runtime_error("Compartment_Report_HDF5_File_Reader: "
                             "Error, not 2 dimensional array on " +
                             datasetName));
    }

    return dataset;
}
开发者ID:adevress,项目名称:Brion,代码行数:29,代码来源:compartmentReportHDF5.cpp

示例7: mutex

bool CompartmentReportHDF5::writeCompartments( const uint32_t gid,
                                               const uint16_ts& counts )
{
    lunchbox::ScopedWrite mutex( detail::_hdf5Lock );

    try
    {
        const size_t compCount = std::accumulate( counts.begin(),
                                                  counts.end(), 0 );
        LBASSERT( !counts.empty( ));
        LBASSERTINFO( compCount > 0, gid );
        H5::DataSet dataset = _createDataset( gid, compCount );

        const size_t sections = counts.size();
        LBASSERT( sections > 0 );
        dataset.openAttribute( 1 ).write( H5::PredType::NATIVE_INT, &sections );

//        dataset.openAttribute( 2 ).write( H5::PredType::NATIVE_INT, &somas );
//        dataset.openAttribute( 3 ).write( H5::PredType::NATIVE_INT, &axons );
//        dataset.openAttribute( 4 ).write( H5::PredType::NATIVE_INT, &basals );
//        dataset.openAttribute( 5 ).write( H5::PredType::NATIVE_INT, &apics );

        boost::scoped_array< float > mapping( new float[compCount] );
        size_t i = 0;
        for( size_t j = 0; j < counts.size(); ++j )
            for( size_t k = 0; k < counts[j]; ++k )
                mapping[i++] = j;

        dataset.write( mapping.get(), H5::PredType::NATIVE_FLOAT );
        return true;
    }
    CATCH_HDF5ERRORS
    return false;
}
开发者ID:adevress,项目名称:Brion,代码行数:34,代码来源:compartmentReportHDF5.cpp

示例8: dataspace

void HDF5IO::saveMatrix(const std::string& GroupName, const std::string& Name,
    const ComplexMatrixType& M)
{
  try{
    H5::CompType ComplexDataType = this->openCompType("complex");
    hsize_t Dims[2] = {hsize_t(M.rows()),hsize_t(M.cols())};
    H5::DataSpace dataspace(2,Dims);
    H5::Group FG = getGroup( GroupName );
    try{
      H5::Exception::dontPrint();
      H5::DataSet dset = FG.openDataSet(Name.c_str());
      // dset.extend( Dims );not working
      dset.write(M.data(), ComplexDataType);
    } catch ( const H5::GroupIException not_found_error ){
      H5::DataSet dset = FG.createDataSet(Name.c_str(), ComplexDataType, dataspace);
      dset.write(M.data(), ComplexDataType);
    } catch ( const H5::DataSetIException error ){
      error.printError();
      RUNTIME_ERROR("HDF5IO::saveComplexMatrix at ");
    }
    FG.close();
  } catch( const H5::Exception error ){
    error.printError();
    RUNTIME_ERROR("HDF5IO::saveComplexMatrix at ");
  }
}
开发者ID:chengyanlai,项目名称:ExactDiagonalization,代码行数:26,代码来源:hdf5io.cpp

示例9: writeArray

void writeArray(H5::Group &group, const std::string &name,
                const std::string &value) {
  StrType dataType(0, value.length() + 1);
  DataSpace dataSpace = getDataSpace(1);
  H5::DataSet data = group.createDataSet(name, dataType, dataSpace);
  data.write(value, dataType);
}
开发者ID:dezed,项目名称:mantid,代码行数:7,代码来源:SaveDiffCal.cpp

示例10:

void pyne::Material::_load_comp_protocol0(H5::H5File * db, std::string datapath, int row)
{
  H5::Group matgroup = (*db).openGroup(datapath);
  H5::DataSet nucset;

  double nucvalue;
  hsize_t matG = matgroup.getNumObjs();

  // Iterate over datasets in the group.
  for (int matg = 0; matg < matG; matg++)
  {
    std::string nuckey = matgroup.getObjnameByIdx(matg);
    nucset = matgroup.openDataSet(nuckey);
    nucvalue = h5wrap::get_array_index<double>(&nucset, row);

    if (nuckey == "Mass" || nuckey == "MASS" || nuckey == "mass")
      mass = nucvalue;
    else
      comp[pyne::nucname::zzaaam(nuckey)] = nucvalue;

    nucset.close();
  };

  // Set meta data
  name = datapath.substr(datapath.rfind("/")+1, datapath.length());
  atoms_per_mol = -1.0;
};
开发者ID:chrisdembia,项目名称:pyne,代码行数:27,代码来源:material.cpp

示例11:

	/**
	 * @param attribute_id
	 * @return String representing the name of the attribute specified by attribute_id
	 */
	std::string HDF5FileReader::getVariableAttributeName(long attribute_id)
	{
		H5::DataSet dataset = this->variableGroup->openDataSet(this->variableGroup->getObjnameByIdx(0));
		H5::Attribute attribute = dataset.openAttribute(attribute_id);
		std::string buffer = attribute.getName();
		cout << "Attribute Name: '" << buffer << "'" << endl;
		return buffer;
	}
开发者ID:NeelSavani,项目名称:ccmc-software,代码行数:12,代码来源:HDF5FileReader.cpp

示例12: 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

示例13: getGroup

int HDF5IO::loadInt(const std::string& GroupName, const std::string& Name)
{
    try{
      H5::Group FG = getGroup( GroupName );
      H5::DataSet DataSet = FG.openDataSet( Name.c_str());
      int x;
      DataSet.read(&x,H5::PredType::NATIVE_INT);
      FG.close();
      return x;
    }catch( H5::GroupIException not_found_error ){
      RUNTIME_ERROR("No dataset found in loadInt. ");
    }
}
开发者ID:chengyanlai,项目名称:ExactDiagonalization,代码行数:13,代码来源:hdf5io.cpp

示例14: 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

示例15: if

ossimRefPtr<ossimImageGeometry> ossimH5Reader::getInternalImageGeometry()
{
   ossimRefPtr<ossimImageGeometry> geom = new ossimImageGeometry();

   if ( m_projection.valid() )
   {
      // Stored projection, currently shared by all entries.
      geom->setProjection( m_projection.get() );
   }
   else if ( isOpen() )
   {
      // Find the "Latitude" and "Longitude" datasets if present.
      std::string latName;
      std::string lonName;
      if ( getLatLonDatasetNames(  m_h5File, latName, lonName ) )
      {
         H5::DataSet latDataSet = m_h5File->openDataSet( latName );
         H5::DataSet lonDataSet = m_h5File->openDataSet( lonName );

         // Get the valid rectangle of the dataset.
         ossimIrect validRect = m_entries[m_currentEntry].getValidImageRect();

         // Try for a coarse projection first:
         ossimRefPtr<ossimProjection> proj =
            processCoarseGridProjection( latDataSet,
                                         lonDataSet,
                                         validRect );
         
         if ( proj.valid() == false )
         {
            ossimIrect rect;
            proj = ossim_hdf5::getBilinearProjection( latDataSet, lonDataSet, validRect );
         }
         
         if ( proj.valid() )
         {
            // Store it for next time:
            m_projection = proj;
            
            // Set the geometry projection
            geom->setProjection( proj.get() ); 
         }
               
         latDataSet.close();
         lonDataSet.close();
      }
   }
 
   return geom;
}
开发者ID:bradh,项目名称:ossim-plugins,代码行数:50,代码来源:ossimH5Reader.cpp


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