Our derived dataset structure that includes utility functions. More...
#include <IH5.h>
Public Member Functions | |
IDataSet (const H5::DataSet &dset) | |
IDataSet (const hid_t id) | |
std::vector< std::string > | getAttrs () |
Get a list of attributes attached to dataset. More... | |
H5::DataSpace | getDataSpace (const std::string &v="") |
Get a HDF5 DataSpace object corresponding to dataset or given attribute. | |
int | getRank (const std::string &v="") |
Get the number of dimension of dataset or given attribute. More... | |
int | getNumElements (const std::string &v="") |
Get the total number of elements contained in dataset or given attribute. More... | |
std::vector< int > | getDimensions (const std::string &v="") |
Get the size of each dimension of the dataset or given attribute. More... | |
std::string | getTypeClassStr (const std::string &v="") |
Get the H5 data type of the dataset or given attribute. More... | |
std::vector< int > | getChunkSize () |
Get the storage chunk size of the dataset. More... | |
int | getNumBits (const std::string &v="") |
Get the number of bit used to store each dataset element. More... | |
std::string | toGDAL () const |
Generate GDALDataset Representation. More... | |
template<typename T > | |
void | read (T &v, const std::string &att="") |
Reading scalar (non string) dataset or attributes. More... | |
void | read (std::string &v, const std::string &att="") |
Reading scalar string dataset or attributes. More... | |
template<typename T > | |
void | read (T *buf, const std::string &att) |
Reading multi-dimensional attribute in raw pointer. More... | |
template<typename T > | |
void | read (std::vector< T > &buf, const std::string &att) |
Reading multi-dimensional attribute in vector. More... | |
template<typename T > | |
void | read (std::valarray< T > &buf, const std::string &att) |
Reading multi-dimensional attribute in valarray. More... | |
template<typename T > | |
void | read (T *buf, const int *startIn=nullptr, const int *countIn=nullptr, const int *strideIn=nullptr) |
Reading multi-dimensional dataset in raw pointer. More... | |
template<typename T > | |
void | read (T *buf, const std::vector< std::slice > *slicesIn) |
Reading multi-dimensional dataset in raw pointer with std:slice subsetting. More... | |
template<typename T > | |
void | read (T *buf, const std::gslice *gsliceIn) |
Reading multi-dimensional dataset in raw pointer with std:gslice subsetting. More... | |
template<typename T > | |
void | read (std::vector< T > &buf) |
Reading multi-dimensional dataset in std::vector. More... | |
template<typename T > | |
void | read (std::vector< T > &buf, const std::vector< int > *startIn, const std::vector< int > *countIn, const std::vector< int > *strideIn) |
Reading multi-dimensional dataset in vector. More... | |
template<typename T > | |
void | read (std::vector< T > &buf, const std::vector< std::slice > *slicesIn) |
Reading multi-dimensional dataset in vector with std:slice subsetting. More... | |
template<typename T > | |
void | read (std::vector< T > &buf, const std::gslice *gsliceIn) |
Reading multi-dimensional dataset in vector with std:gslice subsetting. More... | |
template<typename T > | |
void | read (std::valarray< T > &buf) |
Reading multi-dimensional dataset in valarray. More... | |
template<typename T > | |
void | read (std::valarray< T > &buf, const std::valarray< int > *startIn, const std::valarray< int > *countIn, const std::valarray< int > *strideIn) |
Reading multi-dimensional dataset in valarray. More... | |
template<typename T > | |
void | read (std::valarray< T > &buf, const std::vector< std::slice > *slicesIn) |
Reading multi-dimensional dataset in valarray with std:slice subsetting. More... | |
template<typename T > | |
void | read (std::valarray< T > &buf, const std::gslice *gsliceIn) |
Reading multi-dimensional dataset in valarray with std:slice subsetting. More... | |
template<typename T > | |
void | write (const std::vector< T > &buf) |
Writing std::vector data into a dataset. More... | |
template<typename T , size_t S> | |
void | write (const std::vector< T > &buf, const std::array< int, S > &startIn, const std::array< int, S > &countIn, const std::array< int, S > &strideIn) |
Writing std::vector data into a multi-dimensional dataset using std::array for subsetting. More... | |
template<typename T > | |
void | write (const std::vector< T > &buf, const std::vector< std::slice > *slicesIn) |
Writing std::vector data into a multi-dimensional dataset using std::slice for subsetting. More... | |
template<typename T > | |
void | write (const std::vector< T > &buf, const std::gslice *gsliceIn) |
Writing std::vector data into a multi-dimensional dataset using std::gslice for subsetting. More... | |
template<typename T > | |
void | write (const std::valarray< T > &buf) |
Writing std::valarray data into a dataset. More... | |
template<typename T , size_t S> | |
void | write (const std::valarray< T > &buf, const std::array< int, S > &startIn, const std::array< int, S > &countIn, const std::array< int, S > &strideIn) |
Writing std::valarray data into a multi-dimensional dataset using std::array for subsetting. More... | |
template<typename T > | |
void | write (const std::valarray< T > &buf, const std::vector< std::slice > *slicesIn) |
Writing std::valarray data into a multi-dimensional dataset using std::slice for subsetting. More... | |
template<typename T > | |
void | write (const std::valarray< T > &buf, const std::gslice *gsliceIn) |
Writing std::valarray data into a multi-dimensional dataset using std::gslice for subsetting. More... | |
template<typename T > | |
void | write (const T *buf, const size_t sz) |
Writing a raw pointer buffer into a dataset. More... | |
template<typename T , size_t S> | |
void | write (const T *buf, const std::array< int, S > &startIn, const std::array< int, S > &countIn, const std::array< int, S > &strideIn) |
Writing a raw pointer into a multi-dimensional dataset using std::array for subsetting. More... | |
template<typename T > | |
void | write (const T *buf, const std::vector< std::slice > *slicesIn) |
Writing a buffer into a multi-dimensional dataset using std::slice for subsetting. More... | |
template<typename T > | |
void | write (const T *buf, const std::gslice *gsliceIn) |
Writing a buffer into a multi-dimensional dataset using std::gslice for subsetting. More... | |
template<typename T > | |
void | createAttribute (const std::string &name, const T &data) |
Creating and writing a scalar as an attribute. More... | |
template<typename T > | |
void | createAttribute (const std::string &name, const std::vector< T > &values) |
Creating and writing a std::vector data as a 1D-array attribute. More... | |
template<typename T > | |
void | createAttribute (const std::string &name, const std::valarray< T > &values) |
Creating and writing a std::valarray data as a 1D-array attribute. More... | |
template<typename T , typename T2 , size_t S> | |
void | createAttribute (const std::string &name, const std::array< T2, S > &dims, const std::vector< T > &values) |
Creating and writing a std::vector data with dimensions (std::array) as an attribute. More... | |
template<typename T , typename T2 , size_t S> | |
void | createAttribute (const std::string &name, const std::array< T2, S > &dims, const std::valarray< T > &values) |
Creating and writing a std::valarray data with dimensions (std::array) as an attribute. More... | |
template<typename T , typename T2 , size_t S> | |
void | createAttribute (const std::string &name, const std::array< T2, S > &dims, const T *buffer) |
Creating and writing a raw pointer with dimensions (std::array) to data as an attribute. More... | |
H5::DataSpace | getDataSpace (const int *startIn, const int *countIn, const int *strideIn) |
Get DataSpace corresponding to slice defined by start, count and stride. | |
H5::DataSpace | getDataSpace (const std::vector< std::slice > *sliceIn) |
Get DataSpace corresponding to slice defined by a vector of slices. | |
H5::DataSpace | getDataSpace (const std::gslice *gsliceIn) |
Get DataSpace corresponding to a gslice. | |
H5::DataSpace | getDataSpace (const size_t xidx, const size_t yidx, const size_t iowidth, const size_t iolength, const size_t band) |
Get DataSpace with a GDAL RasterIO-like interface. | |
template<> | |
void | write (const std::string *buf, const H5::DataSpace &dspace) |
template<> | |
void | createAttribute (const std::string &name, const H5::DataType &datatype, const H5::DataSpace &dataspace, const std::string *buffer) |
template<> | |
void | createAttribute (const std::string &name, const std::string &data) |
Our derived dataset structure that includes utility functions.
|
inline |
Creating and writing a scalar as an attribute.
[in] | name | Name of the attribute to create |
[in] | data | Reference to scalar attribute value |
|
inline |
Creating and writing a std::vector data as a 1D-array attribute.
[in] | name | Name of the attribute to create |
[in] | buffer | std::vector of attribute data to write |
The shape of the attribute is 1D.
|
inline |
Creating and writing a std::valarray data as a 1D-array attribute.
[in] | name | Name of the attribute to create |
[in] | buffer | std::valarray of attribute data to write |
The shape of the attribute is 1D.
|
inline |
Creating and writing a std::vector data with dimensions (std::array) as an attribute.
[in] | name | Name of the attribute to create |
[in] | dims | Array containing the size of each dimension of the attribute |
[in] | buffer | std::vector of attribute data to write |
|
inline |
Creating and writing a std::valarray data with dimensions (std::array) as an attribute.
[in] | name | Name of the attribute to create |
[in] | dims | Array containing the size of each dimension of the attribute |
[in] | buffer | std::valarray of attribute data to write |
|
inline |
Creating and writing a raw pointer with dimensions (std::array) to data as an attribute.
[in] | name | Name of the attribute to create |
[in] | dims | Array containing the size of each dimension of the attribute |
[in] | buffer | Raw pointer buffer to attribute data to write |
void isce3::io::IDataSet::createAttribute | ( | const std::string & | name, |
const H5::DataType & | datatype, | ||
const H5::DataSpace & | dataspace, | ||
const std::string * | buffer | ||
) |
[in] | name | Name of the dataset attribute to create |
[in] | datatype | H5 data type of the attribute |
[in] | dataspace | H5 data space of the attribute |
[in] | buffer | of std::string values to write |
|
inline |
[in] | name | Name of the attribute to create |
[in] | data | String scalar attribute |
std::vector< std::string > isce3::io::IDataSet::getAttrs | ( | ) |
Get a list of attributes attached to dataset.
Return the names of all the attributes attached to the current dataset.
std::vector< int > isce3::io::IDataSet::getChunkSize | ( | ) |
Get the storage chunk size of the dataset.
Return the chunk size of the dataset storage layout.
The size of the returned vector is the same as the rank of the dataset and contains the size of the chunk in each dimensions. A size of 0 means no chunking in that dimension.
std::vector< int > isce3::io::IDataSet::getDimensions | ( | const std::string & | v = "" | ) |
Get the size of each dimension of the dataset or given attribute.
[in] | v | Name of the attribute (optional). Returns a std::vector containing the number of elements in each dimension of the dataset or attribute. |
If input is not empty, returns the number of elements in each dimension of the given attribute. If input is empty, returns the number of elements in each dimension of the current dataset. A scalar dataset/attribute will return an empty std::vector.
int isce3::io::IDataSet::getNumBits | ( | const std::string & | v = "" | ) |
Get the number of bit used to store each dataset element.
[in] | v | Name of the attribute (optional). Returns the actual number of bit used to store the current dataset or given attribute data in the file. |
int isce3::io::IDataSet::getNumElements | ( | const std::string & | v = "" | ) |
Get the total number of elements contained in dataset or given attribute.
[in] | v | Name of the attribute (optional). Returns the number of elements in the dataset or attribute. |
If input is not empty, returns the number of elements in the given attribute. If input is empty, returns the number of elements in the current dataset.
int isce3::io::IDataSet::getRank | ( | const std::string & | v = "" | ) |
Get the number of dimension of dataset or given attribute.
[in] | v | Name of the attribute (optional). Returns the number of dimension of the dataset or attribute. |
If input is not empty, returns the number of dimension of the given attribute name. If input is empty, returns the number of dimension of current dataset. Scalar:0; 1D array:1, 2D array:2, etc.
std::string isce3::io::IDataSet::getTypeClassStr | ( | const std::string & | v = "" | ) |
Get the H5 data type of the dataset or given attribute.
[in] | v | Name of the attribute (optional). Returns the HDF5 class type of the data contained in the dataset or attribute. |
If input is not empty, returns the class type of the given attribute. If input is empty, returns the class type. This information is useful to provide the HDF% Read function with a container of the proper type. The HFD5 library will do type conversion when possible, but will throw an error if types are incompatible.
|
inline |
Reading scalar (non string) dataset or attributes.
[in] | att | Name of the attribute (optional). |
[out] | v | Dataset or attribute scalar value. |
If input is not empty, reads the attributes value, otherwise, reads the dataset scalar value. For dataset/attributes containing more than one elements, see other function signature.
void isce3::io::IDataSet::read | ( | std::string & | v, |
const std::string & | att = "" |
||
) |
Reading scalar string dataset or attributes.
[in] | att | Name of the attribute (optional). |
[out] | v | Dataset or attribute string value. |
If input is not empty, reads the attributes string value, otherwise, reads the dataset scalar string value. For dataset/attributes containing more than one elements, see other function signature.
|
inline |
Reading multi-dimensional attribute in raw pointer.
[in] | att | String containing the name of the attribute to read. |
[out] | buffer | Raw pointer to array that will received the read data. |
buffer has to be adequately allocated by caller.
|
inline |
Reading multi-dimensional attribute in vector.
[in] | att | String containing the name of the attribute to read. |
[out] | buffer | std::vector will received the attribute data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional attribute in valarray.
[in] | att | String containing the name of the attribute to read. |
[out] | buffer | std::valarray will received the attribute data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in raw pointer.
[in] | start | Raw pointer to array containing the read start location in each dimension. |
[in] | count | Raw pointer to array containing the number of elements to read in each dimension. |
[in] | stride | Raw pointer to array containing the reading stride in each dimension. |
[out] | buffer | Raw pointer to array that will received the read data. |
buffer has to be adequately allocated by caller. start, count, stride must have a number of elements equals to the rank of the dataset. If start is nullptr, reading start location in each dimension is 0. If count is nullptr, full number of element in each dimension is read. If stride is nullptr, stride defaults to 1 in each dimension.
Examples: Dataset contains a 3-bands raster. Dimensions are (100,100,3).
To retrieve the full second band: start=[0,0,1], count=[100,100,1], stride=nullptr or [1,1,1].
To retrieve the first band, but only every other elements in X direction: start=[0,0,0], count=[50,100,1], stride=[2,1,1].
|
inline |
Reading multi-dimensional dataset in raw pointer with std:slice subsetting.
[in] | slices | Vector containing an std::slice for each dimension of the dataset |
[out] | buffer | Raw pointer to array that will received the read data. |
buffer has to be adequately allocated by caller.
|
inline |
Reading multi-dimensional dataset in raw pointer with std:gslice subsetting.
[in] | gsliceIn | std::gslice for subsetting |
[out] | buffer | Raw pointer to array that will received the read data. |
buffer has to be adequately allocated by caller.
|
inline |
Reading multi-dimensional dataset in std::vector.
[out] | buffer | std::vector that will receive the full dataset. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in vector.
[in] | start | std::vector containing the read start location in each dimension. |
[in] | count | std::vector containing the number of elements to read in each dimension. |
[in] | stride | std::vector containing the reading stride in each dimension. |
[out] | buffer | std::vector that will received the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. both case the data read is stored at the beginning of the container.
start, count, stride must have a number of elements equals to the rank of the dataset. If start is nullptr, reading start location in each dimension is 0. If count is nullptr, full number of element in each dimension is read. If stride is nullptr, stride defaults to 1 in each dimension.
|
inline |
Reading multi-dimensional dataset in vector with std:slice subsetting.
[in] | slices | Vector containing an std::slice for each dimension of the dataset |
[out] | buffer | std::vector that will receive the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in vector with std:gslice subsetting.
[in] | gsliceIn | std::gslice for subsetting |
[out] | buffer | std::vector that will receive the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in valarray.
[out] | buffer | std::valarray that will receive the full dataset. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in valarray.
[in] | startIn | std::valarray containing the read start location in each dimension. |
[in] | countIn | std::valarray containing the number of elements to read in each dimension. |
[in] | strideIn | std::valarray containing the reading stride in each dimension. |
[out] | buffer | std::valarray that will received the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
startIn, countIn, strideIn must have a number of elements equals to the rank of the dataset. If startIn is nullptr, reading start location in each dimension is 0. If countIn is nullptr, full number of element in each dimension is read. If strideIn is nullptr, stride defaults to 1 in each dimension.
|
inline |
Reading multi-dimensional dataset in valarray with std:slice subsetting.
[in] | sliceIn | sts::valarray containing an std::slice for each dimension of the dataset |
[out] | buffer | std::valarray that will receive the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
|
inline |
Reading multi-dimensional dataset in valarray with std:slice subsetting.
[in] | gsliceIn | std::gslice for subsetting |
[out] | buffer | std::valarray that will receive the read data. |
If the output container is undersized compared to the data to read the function will size it accordingly. If the container is larger than the data to be read, its size is unchanged. In both case the data read is stored at the beginning of the container.
std::string isce3::io::IDataSet::toGDAL | ( | ) | const |
Generate GDALDataset Representation.
[out] | str | String representation for GDAL's IH5Dataset driver |
Returns IH5:::ID=string
|
inline |
Writing std::vector data into a dataset.
[in] | buf | std::vector of data to write to dataset. It is mandatory that the size of the dataset and the number of elements in the vector matches. |
|
inline |
Writing std::vector data into a multi-dimensional dataset using std::array for subsetting.
[in] | buf | std::vector of data to write to dataset. |
[in] | start | std::array containing the write start location in each dimension. |
[in] | count | std::array containing the number of elements to write in each dimension. |
[in] | stride | std::array containing the writing stride in each dimension. |
|
inline |
Writing std::vector data into a multi-dimensional dataset using std::slice for subsetting.
[in] | buf | std::vector of data to write to dataset. |
[in] | sliceIn | std::vector containing an std::slice for each dimension of the dataset |
|
inline |
Writing std::vector data into a multi-dimensional dataset using std::gslice for subsetting.
[in] | buf | std::vector of data to write to dataset. |
[in] | gsliceIn | std::gslice for subsetting the dataset writing location |
|
inline |
Writing std::valarray data into a dataset.
[in] | buf | std::valarray of data to write to dataset. It is mandatory that the size of the dataset and the number of elements in the valarray matches. |
|
inline |
Writing std::valarray data into a multi-dimensional dataset using std::array for subsetting.
[in] | buf | std::valarray of data to write to dataset. |
[in] | startIn | std::array containing the write start location in each dimension. |
[in] | countIn | std::array containing the number of elements to write in each dimension. |
[in] | strideIn | std::array containing the writing stride in each dimension. |
|
inline |
Writing std::valarray data into a multi-dimensional dataset using std::slice for subsetting.
[in] | buf | std::valarray of data to write to dataset. |
[in] | sliceIn | std::vector containing an std::slice for each dimension of the dataset |
|
inline |
Writing std::valarray data into a multi-dimensional dataset using std::gslice for subsetting.
[in] | buf | std::valarray of data to write to dataset. |
[in] | gsliceIn | std::gslice for subsetting the dataset writing location |
|
inline |
Writing a raw pointer buffer into a dataset.
[in] | buf | Raw pointer to buffer of data to write to dataset. The size of the dataset and the number of elements in the buffer must match. |
|
inline |
Writing a raw pointer into a multi-dimensional dataset using std::array for subsetting.
[in] | buf | raw pointer to a buffer of data to write to dataset. |
[in] | startIn | std::array containing the write start location in each dimension. |
[in] | countIn | std::array containing the number of elements to write in each dimension. |
[in] | strideIn | std::array containing the writing stride in each dimension. |
It the responsability of the caller to make sure that the size of the buffer inferred from the startIn/countIn/strideIn matches the actual size of the buffer.
|
inline |
Writing a buffer into a multi-dimensional dataset using std::slice for subsetting.
[in] | buf | raw pointer to a buffer of data to write to dataset. |
[in] | sliceIn | std::vector containing an std::slice for each dimension of the dataset |
It the responsability of the caller to make sure that the size of the buffer inferred from the startIn/countIn/strideIn matches the actual size of the buffer.
|
inline |
Writing a buffer into a multi-dimensional dataset using std::gslice for subsetting.
[in] | buf | raw pointer to a buffer of data to write to dataset. |
[in] | gsliceIn | std::gslice for subsetting the dataset writing location |
It the responsability of the caller to make sure that the size of the buffer inferred from the startIn/countIn/strideIn matches the actual size of the buffer.
void isce3::io::IDataSet::write | ( | const std::string * | buf, |
const H5::DataSpace & | dspace | ||
) |
[in] | pointer | to std::string buffer to write to dataset. |
[in] | DataSpace | object for locating where to write the data in the dataset. |