![]() |
kspaceFirstOrder3D-CUDA
1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
|
Class wrapping the HDF5 routines. More...
#include <HDF5_File.h>
Public Types | |
enum | TMatrixDataType { FLOAT = 0, LONG = 1 } |
HDF5 matrix data type (float or uint64). More... | |
enum | TMatrixDomainType { REAL = 0, COMPLEX = 1 } |
HDF5 Matrix domain type (real or complex). More... | |
Public Member Functions | |
THDF5_File () | |
Constructor of the class. More... | |
virtual | ~THDF5_File () |
Destructor. More... | |
void | Create (const std::string &fileName, unsigned int flags=H5F_ACC_TRUNC) |
Create a file. More... | |
void | Open (const std::string &fileName, unsigned int flags=H5F_ACC_RDONLY) |
Open a file. More... | |
bool | IsOpen () const |
Is the file opened? More... | |
void | Close () |
Close file. More... | |
hid_t | CreateGroup (const hid_t parentGroup, TMatrixName &groupName) |
Create a HDF5 group at a specified place in the file tree. More... | |
hid_t | OpenGroup (const hid_t parentGroup, TMatrixName &groupName) |
Open a HDF5 group at a specified place in the file tree. More... | |
void | CloseGroup (const hid_t group) |
Close group. More... | |
hid_t | GetRootGroup () const |
Get handle to the root group. More... | |
hid_t | OpenDataset (const hid_t parentGroup, TMatrixName &datasetName) |
Open the HDF5 dataset at a specified place in the file tree. More... | |
hid_t | CreateFloatDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, const TDimensionSizes &chunkSizes, const size_t compressionLevel) |
Create a float HDF5 dataset at a specified place in the file tree (3D/4D). More... | |
hid_t | CreateIndexDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, const TDimensionSizes &chunkSizes, const size_t compressionLevel) |
Create an index HDF5 dataset at a specified place in the file tree (3D only). More... | |
void | CloseDataset (const hid_t dataset) |
Close the HDF5 dataset. More... | |
void | WriteHyperSlab (const hid_t dataset, const TDimensionSizes &position, const TDimensionSizes &size, const float *data) |
Write a hyper-slab into the dataset - float dataset. More... | |
void | WriteHyperSlab (const hid_t dataset, const TDimensionSizes &position, const TDimensionSizes &size, const size_t *data) |
Write a hyper-slab into the dataset - long dataset. More... | |
void | WriteCuboidToHyperSlab (const hid_t dataset, const TDimensionSizes &hyperslabPosition, const TDimensionSizes &cuboidPosition, const TDimensionSizes &cuboidSize, const TDimensionSizes &matrixDimensions, const float *mMatrixData) |
Write a cuboid selected within the matrixData into a hyperslab. More... | |
void | WriteDataByMaskToHyperSlab (const hid_t dataset, const TDimensionSizes &hyperslabPosition, const size_t indexSensorSize, const size_t *indexSensorData, const TDimensionSizes &matrixDimensions, const float *matrixData) |
Write sensor data selected by the sensor mask - Occasionally very slow, do not use! More... | |
void | WriteScalarValue (const hid_t parentGroup, TMatrixName &datasetName, const float value) |
Write the scalar value under a specified group, float value. More... | |
void | WriteScalarValue (const hid_t parentGroup, TMatrixName &datasetName, const size_t value) |
Write the scalar value under a specified group, index value. More... | |
void | ReadScalarValue (const hid_t parentGroup, TMatrixName &datasetName, float &value) |
Read the scalar value under a specified group, float value. More... | |
void | ReadScalarValue (const hid_t parentGroup, TMatrixName &datasetName, size_t &value) |
Read the scalar value under a specified group, index value. More... | |
void | ReadCompleteDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, float *data) |
Read data from the dataset under a specified group, float dataset. More... | |
void | ReadCompleteDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, size_t *data) |
Read data from the dataset under a specified group, index dataset. More... | |
TDimensionSizes | GetDatasetDimensionSizes (const hid_t parentGroup, TMatrixName &datasetName) |
Get dimension sizes of the dataset under a specified group. More... | |
size_t | GetDatasetNumberOfDimensions (const hid_t parentGroup, TMatrixName &datasetName) |
Get number of dimensions of the dataset under a specified group. More... | |
size_t | GetDatasetElementCount (const hid_t parentGroup, TMatrixName &datasetName) |
Get dataset element count under a specified group. More... | |
void | WriteMatrixDataType (const hid_t parentGroup, TMatrixName &datasetName, const TMatrixDataType &matrixDataType) |
Write matrix data type into the dataset under a specified group. More... | |
void | WriteMatrixDomainType (const hid_t parentGroup, TMatrixName &datasetName, const TMatrixDomainType &matrixDomainType) |
Write matrix domain type into the dataset under the root group. More... | |
THDF5_File::TMatrixDataType | ReadMatrixDataType (const hid_t parentGroup, TMatrixName &datasetName) |
Read matrix data type from the dataset. More... | |
THDF5_File::TMatrixDomainType | ReadMatrixDomainType (const hid_t parentGroup, TMatrixName &datasetName) |
Read matrix domain type from the dataset under a specified group. More... | |
void | WriteStringAttribute (const hid_t parentGroup, TMatrixName &datasetName, TMatrixName &attributeName, const std::string &value) |
Write string attribute into the dataset under the root group. More... | |
std::string | ReadStringAttribute (const hid_t parentGroup, TMatrixName &datasetName, TMatrixName &attributeName) |
Read string attribute from the dataset under the root group. More... | |
Static Public Member Functions | |
static bool | IsHDF5 (const std::string &fileName) |
Does the file exist? More... | |
Protected Member Functions | |
THDF5_File (const THDF5_File &src) | |
Copy constructor is not allowed for public. | |
THDF5_File & | operator= (const THDF5_File &src) |
Operator = is not allowed for public. | |
Private Attributes | |
hid_t | file |
HDF file handle. | |
std::string | fileName |
File name. | |
Static Private Attributes | |
static const std::string | matrixDomainTypeName = "domain_type" |
String representation of the Domain type in the HDF5 file. | |
static const std::string | matrixDataTypeName = "data_type" |
String representation of the Data type in the HDF5 file. | |
static const std::string | matrixDomainTypeNames [] = {"real","complex"} |
String representation of different domain types. | |
static const std::string | matrixDataTypeNames [] = {"float","long"} |
String representation of different data types. | |
This class is responsible for working with HDF5 files. It offers routines to manage files (create, open, close) as well as creating, reading and modifying the contents (groups and datasets).
Definition at line 500 of file HDF5_File.h.
HDF5 matrix data type (float or uint64).
Definition at line 509 of file HDF5_File.h.
HDF5 Matrix domain type (real or complex).
Definition at line 520 of file HDF5_File.h.
THDF5_File::THDF5_File | ( | ) |
Constructor.
Definition at line 82 of file HDF5_File.cpp.
|
virtual |
void THDF5_File::Close | ( | ) |
Close the HDF5 file.
ios::failure |
Definition at line 175 of file HDF5_File.cpp.
void THDF5_File::CloseDataset | ( | const hid_t | dataset | ) |
Close dataset.
[in] | dataset | - Dataset to close |
Definition at line 457 of file HDF5_File.cpp.
void THDF5_File::CloseGroup | ( | const hid_t | group | ) |
Close a group.
[in] | group | - Group to close |
Definition at line 254 of file HDF5_File.cpp.
void THDF5_File::Create | ( | const std::string & | fileName, |
unsigned int | flags = H5F_ACC_TRUNC |
||
) |
Create the HDF5 file.
[in] | fileName | - File name |
[in] | flags | - Flags for the HDF5 runtime |
ios:failure | if error happened. |
Definition at line 97 of file HDF5_File.cpp.
hid_t THDF5_File::CreateFloatDataset | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TDimensionSizes & | dimensionSizes, | ||
const TDimensionSizes & | chunkSizes, | ||
const size_t | compressionLevel | ||
) |
Create a float HDF5 dataset at a specified place in the file tree.
[in] | parentGroup | - Parent group Id |
[in] | datasetName | - Dataset name |
[in] | dimensionSizes | - Dimension sizes |
[in] | chunkSizes | - Chunk sizes |
[in] | compressionLevel | - Compression level |
ios::failure |
Definition at line 296 of file HDF5_File.cpp.
hid_t THDF5_File::CreateGroup | ( | const hid_t | parentGroup, |
TMatrixName & | groupName | ||
) |
Create a HDF5 group at a specified place in the file tree.
[in] | parentGroup | - Where to link the group at |
[in] | groupName | - Group name |
ios::failure |
Definition at line 208 of file HDF5_File.cpp.
hid_t THDF5_File::CreateIndexDataset | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TDimensionSizes & | dimensionSizes, | ||
const TDimensionSizes & | chunkSizes, | ||
const size_t | compressionLevel | ||
) |
Create an index HDF5 dataset at a specified place in the file tree (always 3D).
[in] | parentGroup | - Parent group |
[in] | datasetName | - Dataset name |
[in] | dimensionSizes | - Dimension sizes |
[in] | chunkSizes | - Chunk sizes |
[in] | compressionLevel | - Compression level |
ios::failure |
Definition at line 392 of file HDF5_File.cpp.
TDimensionSizes THDF5_File::GetDatasetDimensionSizes | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Get dimension sizes of the dataset at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 949 of file HDF5_File.cpp.
size_t THDF5_File::GetDatasetElementCount | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Get dataset element count at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 1006 of file HDF5_File.cpp.
size_t THDF5_File::GetDatasetNumberOfDimensions | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Get number of dimensions of the dataset under a specified group.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 982 of file HDF5_File.cpp.
|
inline |
Get handle to the root group.
Definition at line 573 of file HDF5_File.h.
|
static |
Check if the file exist.
[in] | fileName |
Is a HDF5 file (can I access it)
[in] | fileName | - Filename |
Definition at line 158 of file HDF5_File.cpp.
|
inline |
Is the file opened?
Definition at line 545 of file HDF5_File.h.
void THDF5_File::Open | ( | const std::string & | fileName, |
unsigned int | flags = H5F_ACC_RDONLY |
||
) |
Open the HDF5 file.
[in] | fileName | - File name |
[in] | flags | - Flags for the HDF5 runtime |
ios:failure | if error happened. |
Definition at line 127 of file HDF5_File.cpp.
hid_t THDF5_File::OpenDataset | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Open a dataset at a specified place in the file tree.
[in] | parentGroup | - Parent group Id (can be the file Id for root). |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 268 of file HDF5_File.cpp.
hid_t THDF5_File::OpenGroup | ( | const hid_t | parentGroup, |
TMatrixName & | groupName | ||
) |
Open a HDF5 group at a specified place in the file tree.
[in] | parentGroup | - Parent group |
[in] | groupName | - Group name |
ios::failure |
Definition at line 232 of file HDF5_File.cpp.
void THDF5_File::ReadCompleteDataset | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TDimensionSizes & | dimensionSizes, | ||
float * | data | ||
) |
Read data from the dataset at a specified place in the file tree, float version.
[in] | parentGroup | - Where is the dataset situated |
[in] | datasetName | - Dataset name |
[in] | dimensionSizes | - Dimension sizes |
[out] | data | - Pointer to data |
ios::failure |
Definition at line 887 of file HDF5_File.cpp.
void THDF5_File::ReadCompleteDataset | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TDimensionSizes & | dimensionSizes, | ||
size_t * | data | ||
) |
Read data from the dataset at a specified place in the file tree, index version.
[in] | parentGroup | - Where is the dataset situated |
[in] | datasetName | - Dataset name |
[in] | dimensionSizes | - Dimension sizes |
[out] | data | - Pointer to data |
ios::failure |
Definition at line 919 of file HDF5_File.cpp.
THDF5_File::TMatrixDataType THDF5_File::ReadMatrixDataType | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Read matrix data type from the dataset at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 1068 of file HDF5_File.cpp.
THDF5_File::TMatrixDomainType THDF5_File::ReadMatrixDomainType | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName | ||
) |
Read matrix dataset domain type at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
ios::failure |
Definition at line 1101 of file HDF5_File.cpp.
void THDF5_File::ReadScalarValue | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
float & | value | ||
) |
Read the scalar value under a specified group, float value.
[in] | parentGroup | - Where to link the scalar dataset |
[in] | datasetName | - HDF5 dataset name |
[out] | value | - Data to be read |
Definition at line 855 of file HDF5_File.cpp.
void THDF5_File::ReadScalarValue | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
size_t & | value | ||
) |
Read the scalar value under a specified group, index value.
[in] | parentGroup | - Where to link the scalar dataset |
[in] | datasetName | - HDF5 dataset name |
[out] | value | - Data to be read |
Definition at line 870 of file HDF5_File.cpp.
|
inline |
Read integer attribute at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
[in] | attributeName | - Attribute name |
ios::failure |
Definition at line 1163 of file HDF5_File.cpp.
void THDF5_File::WriteCuboidToHyperSlab | ( | const hid_t | dataset, |
const TDimensionSizes & | hyperslabPosition, | ||
const TDimensionSizes & | cuboidPosition, | ||
const TDimensionSizes & | cuboidSize, | ||
const TDimensionSizes & | matrixDimensions, | ||
const float * | matrixData | ||
) |
Write a cuboid selected within the matrixData into a hyperslab. The routine writes 3D cuboid into a 4D dataset (only intended for raw time series).
[in] | dataset | - Dataset to write MatrixData into |
[in] | hyperslabPosition | - Position in the dataset (hyperslab) - may be 3D/4D |
[in] | cuboidPosition | - Position of the cuboid in MatrixData (what to sample) - must be 3D |
[in] | cuboidSize | - Cuboid size (size of data being sampled) - must by 3D |
[in] | matrixDimensions | - Size of the original matrix (the sampled one) |
[in] | matrixData | - C array of MatrixData |
ios::failure |
Definition at line 618 of file HDF5_File.cpp.
void THDF5_File::WriteDataByMaskToHyperSlab | ( | const hid_t | dataset, |
const TDimensionSizes & | hyperslabPosition, | ||
const size_t | indexSensorSize, | ||
const size_t * | indexSensorData, | ||
const TDimensionSizes & | matrixDimensions, | ||
const float * | matrixData | ||
) |
Write sensor data selected by the sensor mask. A routine pick elements from the MatixData based on the sensor data and store. them into a single hyperslab of size [Nsens, 1, 1].
[in] | dataset | - Dataset to write MaatrixData into |
[in] | hyperslabPosition | - 3D position in the dataset (hyperslab) |
[in] | indexSensorSize | - Size of the index based sensor mask |
[in] | indexSensorData | - Index based sensor mask |
[in] | matrixDimensions | - Size of the sampled matrix |
[in] | matrixData | - Matrix data |
ios::failure |
Definition at line 686 of file HDF5_File.cpp.
void THDF5_File::WriteHyperSlab | ( | const hid_t | dataset, |
const TDimensionSizes & | position, | ||
const TDimensionSizes & | size, | ||
const float * | data | ||
) |
Write a hyperslab into the dataset, float version.
[in] | dataset | - Dataset id |
[in] | position | - Position in the dataset |
[in] | size | - Size of the hyperslab |
[in] | data | - Data to be written |
ios::failure |
Definition at line 473 of file HDF5_File.cpp.
void THDF5_File::WriteHyperSlab | ( | const hid_t | dataset, |
const TDimensionSizes & | position, | ||
const TDimensionSizes & | size, | ||
const size_t * | data | ||
) |
Write a hyperslab into the dataset, index version.
[in] | dataset | - Dataset id |
[in] | position | - Position in the dataset |
[in] | size | - Size of the hyperslab |
[in] | data | - Data to be written |
ios::failure |
Definition at line 544 of file HDF5_File.cpp.
void THDF5_File::WriteMatrixDataType | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TMatrixDataType & | matrixDataType | ||
) |
Write matrix data type into the dataset at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
[in] | matrixDataType | - Matrix data type in the file |
Definition at line 1029 of file HDF5_File.cpp.
void THDF5_File::WriteMatrixDomainType | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const TMatrixDomainType & | matrixDomainType | ||
) |
Write matrix data type into the dataset at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
[in] | matrixDomainType | - Matrix domain type |
Definition at line 1048 of file HDF5_File.cpp.
void THDF5_File::WriteScalarValue | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const float | value | ||
) |
Write a scalar value at a specified place in the file tree (no chunks, no compression). Float value.
[in] | parentGroup | - Where to link the scalar dataset |
[in] | datasetName | - HDF5 dataset name |
[in] | value | - data to be written |
ios::failure |
Definition at line 748 of file HDF5_File.cpp.
void THDF5_File::WriteScalarValue | ( | const hid_t | parentGroup, |
TMatrixName & | datasetName, | ||
const size_t | value | ||
) |
Write a scalar value at a specified place in the file tree (no chunks, no compression). Index value.
[in] | parentGroup | - Where to link the scalar dataset |
[in] | datasetName | - HDF5 dataset name |
[in] | value | - Data to be written |
ios::failure |
Definition at line 803 of file HDF5_File.cpp.
|
inline |
Write integer attribute at a specified place in the file tree.
[in] | parentGroup | - Where the dataset is |
[in] | datasetName | - Dataset name |
[in] | attributeName | - Attribute name |
[in] | value | - Data to write |
ios::failure |
Definition at line 1135 of file HDF5_File.cpp.