Exemple #1
0
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() ;
    }
  }
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");
  }
}
void HDF5IO::loadVector(const std::string& GroupName, const std::string& Name,
  RealVectorType& V)
{
  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());
  try{
    DataSet.read(V.data(),H5::PredType::NATIVE_DOUBLE);
  }catch( H5::GroupIException not_found_error ){
    RUNTIME_ERROR("No dataset found in loadRealVector. ");
  }
  FG.close();
}
void HDF5IO::loadStdVector(const std::string& GroupName, const std::string& Name,
    std::vector<ComplexType>& V)
{
  try{
    H5::CompType ComplexDataType = this->openCompType("complex");
    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::loadComplexVector()","Unexpected multidimentional dataspace."));
    V.resize(DataSpace.getSimpleExtentNpoints());
    DataSet.read(V.data(),ComplexDataType);
    FG.close();
  } catch( const H5::Exception err ){
    RUNTIME_ERROR("HDF5IO::loadComplexStdVector");
  }
}