kspaceFirstOrder3D-OMP
1.1
The 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 | THDF5_MatrixDataType { hdf5_mdt_float = 0, hdf5_mdt_long = 1 } |
HDF5 matrix data type (float or uint64). | |
enum | THDF5_MatrixDomainType { hdf5_mdt_real = 0, hdf5_mdt_complex = 1 } |
HDF5 Matrix domain type (real or complex). | |
Public Member Functions | |
THDF5_File () | |
Constructor of the class. More... | |
void | Create (const char *FileName, unsigned int Flags=H5F_ACC_TRUNC) |
Create the file, overwrite if exist. More... | |
void | Open (const char *FileName, unsigned int Flags=H5F_ACC_RDONLY) |
Open the file. More... | |
bool | IsOpened () const |
Is the file opened? More... | |
void | Close () |
Close file. More... | |
hid_t | CreateGroup (const hid_t ParentGroup, const char *GroupName) |
Create a HDF5 group at a specified place in the file tree. More... | |
hid_t | OpenGroup (const hid_t ParentGroup, const char *GroupName) |
Open a HDF5 group at a specified place in the file tree. More... | |
void | CloseGroup (const hid_t Group) |
Close HDF5 group. More... | |
hid_t | GetRootGroup () const |
Get handle to the root group. More... | |
hid_t | OpenDataset (const hid_t ParentGroup, const char *DatasetName) |
Open the HDF5 dataset at a specified place in the file tree. More... | |
hid_t | CreateFloatDataset (const hid_t ParentGroup, const char *DatasetName, const TDimensionSizes &DimensionSizes, const TDimensionSizes &ChunkSizes, const size_t CompressionLevel) |
Create the HDF5 dataset at a specified place in the file tree (3D/4D). More... | |
hid_t | CreateIndexDataset (const hid_t ParentGroup, const char *DatasetName, const TDimensionSizes &DimensionSizes, const TDimensionSizes &ChunkSizes, const size_t CompressionLevel) |
Create the HDF5 dataset at a specified place in the file tree (3D only). More... | |
void | CloseDataset (const hid_t HDF5_Dataset_id) |
Close the HDF5 dataset. More... | |
void | WriteHyperSlab (const hid_t HDF5_Dataset_id, const TDimensionSizes &Position, const TDimensionSizes &Size, const float *Data) |
Write a hyper-slab into the dataset - float dataset. More... | |
void | WriteHyperSlab (const hid_t HDF5_Dataset_id, const TDimensionSizes &Position, const TDimensionSizes &Size, const size_t *Data) |
Write a hyper-slab into the dataset - index dataset. More... | |
void | WriteCuboidToHyperSlab (const hid_t HDF5_Dataset_id, const TDimensionSizes &HyperslabPosition, const TDimensionSizes &CuboidPosition, const TDimensionSizes &CuboidSize, const TDimensionSizes &MatrixDimensions, const float *MatrixData) |
Write a cuboid selected inside MatrixData into a Hyperslab. More... | |
void | WriteSensorByMaskToHyperSlab (const hid_t HDF5_Dataset_id, 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, const char *DatasetName, const float Value) |
Write the scalar value under a specified group - float value. More... | |
void | WriteScalarValue (const hid_t ParentGroup, const char *DatasetName, const size_t Value) |
Write the scalar value under a specified group - index value. More... | |
void | ReadScalarValue (const hid_t ParentGroup, const char *DatasetName, float &Value) |
Read the scalar value under a specified group - float value. More... | |
void | ReadScalarValue (const hid_t ParentGroup, const char *DatasetName, size_t &Value) |
Read the scalar value under a specified group - index value. More... | |
void | ReadCompleteDataset (const hid_t ParentGroup, const char *DatasetName, const TDimensionSizes &DimensionSizes, float *Data) |
Read data from the dataset under a specified group - float dataset. More... | |
void | ReadCompleteDataset (const hid_t ParentGroup, const char *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, const char *DatasetName) |
Get dimension sizes of the dataset under a specified group. More... | |
size_t | GetDatasetNumberOfDimensions (const hid_t ParentGroup, const char *DatasetName) |
Get number of dimensions of the dataset under a specified group. More... | |
size_t | GetDatasetElementCount (const hid_t ParentGroup, const char *DatasetName) |
Get dataset element count under a specified group. More... | |
void | WriteMatrixDataType (const hid_t ParentGroup, const char *DatasetName, const THDF5_MatrixDataType &MatrixDataType) |
Write matrix data type into the dataset under a specified group. More... | |
void | WriteMatrixDomainType (const hid_t ParentGroup, const char *DatasetName, const THDF5_MatrixDomainType &MatrixDomainType) |
Write matrix domain type into the dataset under the root group. More... | |
THDF5_File::THDF5_MatrixDataType | ReadMatrixDataType (const hid_t ParentGroup, const char *DatasetName) |
Read matrix data type from the dataset. More... | |
THDF5_File::THDF5_MatrixDomainType | ReadMatrixDomainType (const hid_t ParentGroup, const char *DatasetName) |
Read matrix domain type from the dataset under a specified group. More... | |
void | WriteStringAttribute (const hid_t ParentGroup, const char *DatasetName, const char *AttributeName, const string &Value) |
Write string attribute into the dataset under the root group. More... | |
string | ReadStringAttribute (const hid_t ParentGroup, const char *DatasetName, const char *AttributeName) |
Read string attribute from the dataset under the root group. More... | |
virtual | ~THDF5_File () |
Destructor. More... | |
Static Public Member Functions | |
static bool | IsAccessible (const char *FileName) |
Does the file exist? static method. 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 | HDF5_FileId |
HDF file handle. | |
string | FileName |
File name. | |
Static Private Attributes | |
static const char * | HDF5_MatrixDomainTypeName = "domain_type" |
String representation of the Domain type in the HDF5 file. | |
static const char * | HDF5_MatrixDataTypeName = "data_type" |
String representation of the Data type in the HDF5 file. | |
static const string | HDF5_MatrixDomainTypeNames [] = {"real","complex"} |
String representation of different domain types. | |
static const string | HDF5_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 506 of file HDF5_File.h.
THDF5_File::THDF5_File | ( | ) |
Constructor.
Definition at line 88 of file HDF5_File.cpp.
|
virtual |
void THDF5_File::Close | ( | ) |
Close the HDF5 file.
Definition at line 169 of file HDF5_File.cpp.
void THDF5_File::CloseDataset | ( | const hid_t | HDF5_Dataset_id | ) |
Close dataset.
[in] | HDF5_Dataset_id |
Definition at line 451 of file HDF5_File.cpp.
void THDF5_File::CloseGroup | ( | const hid_t | HDF5_group_id | ) |
Close a group.
[in] | HDF5_group_id |
Definition at line 251 of file HDF5_File.cpp.
void THDF5_File::Create | ( | const char * | FileName, |
unsigned int | Flags = H5F_ACC_TRUNC |
||
) |
Create an HDF5 file.
[in] | FileName | - File name |
[in] | Flags | - Flags for the HDF5 runtime |
ios:failure | if an error happens. |
Definition at line 103 of file HDF5_File.cpp.
hid_t THDF5_File::CreateFloatDataset | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const TDimensionSizes & | DimensionSizes, | ||
const TDimensionSizes & | ChunkSizes, | ||
const size_t | CompressionLevel | ||
) |
Create the HDF5 dataset at a specified place in the file tree.
[in] | ParentGroup | - Parent group |
[in] | DatasetName | - Dataset name |
[in] | DimensionSizes | - Dimension sizes |
[in] | ChunkSizes | - Chunk sizes |
[in] | CompressionLevel | - Compression level |
Definition at line 291 of file HDF5_File.cpp.
hid_t THDF5_File::CreateGroup | ( | const hid_t | ParentGroup, |
const char * | 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 |
Definition at line 201 of file HDF5_File.cpp.
hid_t THDF5_File::CreateIndexDataset | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const TDimensionSizes & | DimensionSizes, | ||
const TDimensionSizes & | ChunkSizes, | ||
const size_t | CompressionLevel | ||
) |
Create the 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 |
Definition at line 385 of file HDF5_File.cpp.
TDimensionSizes THDF5_File::GetDatasetDimensionSizes | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Get dimension sizes of the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName |
ios::failure |
Definition at line 1024 of file HDF5_File.cpp.
size_t THDF5_File::GetDatasetElementCount | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Get dataset element count at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName |
ios::failure |
Definition at line 1087 of file HDF5_File.cpp.
size_t THDF5_File::GetDatasetNumberOfDimensions | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Get number of dimensions of the dataset under a specified group.
[in] | ParentGroup | |
[in] | DatasetName |
Definition at line 1061 of file HDF5_File.cpp.
|
inline |
Get handle to the root group.
Definition at line 581 of file HDF5_File.h.
|
inlinestatic |
Check if the file exist
[in] | FileName |
Definition at line 550 of file HDF5_File.h.
|
inline |
Is the file opened?
Definition at line 539 of file HDF5_File.h.
void THDF5_File::Open | ( | const char * | FileName, |
unsigned int | Flags = H5F_ACC_RDONLY |
||
) |
Open the HDF5 file.
[in] | FileName | |
[in] | Flags | - flags for the HDF5 runtime |
ios:failure | if error happened |
Definition at line 136 of file HDF5_File.cpp.
hid_t THDF5_File::OpenDataset | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Open the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName |
ios::failure |
Definition at line 264 of file HDF5_File.cpp.
hid_t THDF5_File::OpenGroup | ( | const hid_t | ParentGroup, |
const char * | GroupName | ||
) |
Open a HDF5 group at a specified place in the file tree.
[in] | ParentGroup | - parent group (where the group is) |
[in] | GroupName | - Group name |
Definition at line 229 of file HDF5_File.cpp.
void THDF5_File::ReadCompleteDataset | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const TDimensionSizes & | DimensionSizes, | ||
float * | Data | ||
) |
Read data from the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | DimensionSizes | |
[out] | Data |
ios::failure |
Definition at line 954 of file HDF5_File.cpp.
void THDF5_File::ReadCompleteDataset | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const TDimensionSizes & | DimensionSizes, | ||
size_t * | Data | ||
) |
Read data from the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | DimensionSizes | |
[out] | Data |
ios::failure |
Definition at line 988 of file HDF5_File.cpp.
THDF5_File::THDF5_MatrixDataType THDF5_File::ReadMatrixDataType | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Read matrix data type from the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName |
ios::failure |
Definition at line 1155 of file HDF5_File.cpp.
THDF5_File::THDF5_MatrixDomainType THDF5_File::ReadMatrixDomainType | ( | const hid_t | ParentGroup, |
const char * | DatasetName | ||
) |
Read matrix dataset domain type at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName |
ios::failure |
Definition at line 1190 of file HDF5_File.cpp.
void THDF5_File::ReadScalarValue | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
float & | Value | ||
) |
Read the scalar value under a specified group - float value.
[in] | ParentGroup | |
[in] | DatasetName | |
[out] | Value |
Definition at line 922 of file HDF5_File.cpp.
void THDF5_File::ReadScalarValue | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
size_t & | Value | ||
) |
Read the scalar value under a specified group - index value.
[in] | ParentGroup | |
[in] | DatasetName | |
[out] | Value |
Definition at line 937 of file HDF5_File.cpp.
|
inline |
Read integer attribute at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | AttributeName |
ios::failure |
Definition at line 1254 of file HDF5_File.cpp.
void THDF5_File::WriteCuboidToHyperSlab | ( | const hid_t | HDF5_Dataset_id, |
const TDimensionSizes & | HyperslabPosition, | ||
const TDimensionSizes & | CuboidPosition, | ||
const TDimensionSizes & | CuboidSize, | ||
const TDimensionSizes & | MatrixDimensions, | ||
const float * | MatrixData | ||
) |
Write a cuboid selected inside MatrixData into a Hyperslab. The routine writes 3D cuboid into a 4D dataset (only intended for raw time series)
[in] | HDF5_Dataset_id | - 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 |
Definition at line 633 of file HDF5_File.cpp.
void THDF5_File::WriteHyperSlab | ( | const hid_t | HDF5_Dataset_id, |
const TDimensionSizes & | Position, | ||
const TDimensionSizes & | Size, | ||
const float * | Data | ||
) |
Write a hyperslab into the dataset.
[in] | HDF5_Dataset_id | - 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 467 of file HDF5_File.cpp.
void THDF5_File::WriteHyperSlab | ( | const hid_t | HDF5_Dataset_id, |
const TDimensionSizes & | Position, | ||
const TDimensionSizes & | Size, | ||
const size_t * | Data | ||
) |
Write hyperslab.
[in] | HDF5_Dataset_id | - 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 552 of file HDF5_File.cpp.
void THDF5_File::WriteMatrixDataType | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const THDF5_MatrixDataType & | MatrixDataType | ||
) |
Write matrix data type into the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | MatrixDataType |
Definition at line 1116 of file HDF5_File.cpp.
void THDF5_File::WriteMatrixDomainType | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const THDF5_MatrixDomainType & | MatrixDomainType | ||
) |
Write matrix data type into the dataset at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | MatrixDomainType |
Definition at line 1135 of file HDF5_File.cpp.
void THDF5_File::WriteScalarValue | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const float | Value | ||
) |
Write the scalar value at a specified place in the file tree. (no chunks, no compression)
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | Value |
Definition at line 794 of file HDF5_File.cpp.
void THDF5_File::WriteScalarValue | ( | const hid_t | ParentGroup, |
const char * | DatasetName, | ||
const size_t | Value | ||
) |
Write a scalar value at a specified place in the file tree. (no chunks, no compression)
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | Value |
Definition at line 858 of file HDF5_File.cpp.
void THDF5_File::WriteSensorByMaskToHyperSlab | ( | const hid_t | HDF5_Dataset_id, |
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. The routine picks elements from the MatixData based on the Sensor Data and store them into a single hyperslab of size [Nsens, 1, 1]
[in] | HDF5_Dataset_id | - 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 |
Definition at line 716 of file HDF5_File.cpp.
|
inline |
Write integer attribute at a specified place in the file tree.
[in] | ParentGroup | |
[in] | DatasetName | |
[in] | AttributeName | |
[in] | Value |
ios::failure |
Definition at line 1225 of file HDF5_File.cpp.