| kspaceFirstOrder3D-OMP 1.1 The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Friends Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
THDF5_File Class Reference

Class wrapping the HDF5 routines. More...

`#include <HDF5_File.h>`

Collaboration diagram for THDF5_File:
[legend]

## 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.

## Detailed Description

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.

## Constructor & Destructor Documentation

THDF5_File::THDF5_File | ( |  | ) |

Constructor.

Definition at line 88 of file HDF5_File.cpp.

THDF5_File::~THDF5_File | ( |  | ) |
| virtual

Destructor.

Definition at line 188 of file HDF5_File.cpp.

Here is the call graph for this function:

## Member Function Documentation

void THDF5_File::Close | ( |  | ) |

Close the HDF5 file.

Definition at line 169 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::CloseDataset | ( | const hid_t | HDF5_Dataset_id | ) |

Close dataset.

Parameters

  [in] | HDF5_Dataset_id |

Definition at line 451 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::CloseGroup | ( | const hid_t | HDF5_group_id | ) |

Close a group.

Parameters

  [in] | HDF5_group_id |

Definition at line 251 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::Create | ( | const char * | FileName,
|  | unsigned int | Flags = `H5F_ACC_TRUNC`
| ) |  |

Create an HDF5 file.

Parameters

  [in] | FileName | - File name
  [in] | Flags | - Flags for the HDF5 runtime

Exceptions

  ios:failure | if an error happens.

Definition at line 103 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup | - Parent group
  [in] | DatasetName | - Dataset name
  [in] | DimensionSizes | - Dimension sizes
  [in] | ChunkSizes | - Chunk sizes
  [in] | CompressionLevel | - Compression level

Returns
  a handle to the new dataset

Definition at line 291 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::CreateGroup | ( | const hid_t | ParentGroup,
|  | const char * | GroupName
| ) |  |

Create a HDF5 group at a specified place in the file tree.

Parameters

  [in] | ParentGroup | - Where to link the group at
  [in] | GroupName | - Group name

Returns
  a handle to the new group

Definition at line 201 of file HDF5_File.cpp.

Here is the caller graph for this function:

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).

Parameters

  [in] | ParentGroup | - Parent group
  [in] | DatasetName | - Dataset name
  [in] | DimensionSizes | - Dimension sizes
  [in] | ChunkSizes | - Chunk sizes
  [in] | CompressionLevel | - Compression level

Returns
  a handle to the new dataset

Definition at line 385 of file HDF5_File.cpp.

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  DimensionSizes

Exceptions

  ios::failure |

Definition at line 1024 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t THDF5_File::GetDatasetElementCount | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName
| ) |  |

Get dataset element count at a specified place in the file tree.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  Number of elements

Exceptions

  ios::failure |

Definition at line 1087 of file HDF5_File.cpp.

Here is the caller graph for this function:

size_t THDF5_File::GetDatasetNumberOfDimensions | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName
| ) |  |

Get number of dimensions of the dataset under a specified group.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  - Number of dimensions

Definition at line 1061 of file HDF5_File.cpp.

Here is the caller graph for this function:

hid_t THDF5_File::GetRootGroup | ( |  | ) | const
| inline

Get handle to the root group.

Returns
  - handle to the root group

Definition at line 581 of file HDF5_File.h.

Here is the caller graph for this function:

static bool THDF5_File::IsAccessible | ( | const char * | FileName | ) |
| inline static

Check if the file exist

Parameters

  [in] | FileName |

Returns
  true if the file exists

Definition at line 550 of file HDF5_File.h.

Here is the caller graph for this function:

bool THDF5_File::IsOpened | ( |  | ) | const
| inline

Is the file opened?

Returns
  true if the file is opened

Definition at line 539 of file HDF5_File.h.

Here is the caller graph for this function:

void THDF5_File::Open | ( | const char * | FileName,
|  | unsigned int | Flags = `H5F_ACC_RDONLY`
| ) |  |

Open the HDF5 file.

Parameters

  [in] | FileName |
  [in] | Flags | - flags for the HDF5 runtime

Exceptions

  ios:failure | if error happened

Definition at line 136 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::OpenDataset | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName
| ) |  |

Open the dataset at a specified place in the file tree.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  Dataset id

Exceptions

  ios::failure |

Definition at line 264 of file HDF5_File.cpp.

Here is the caller graph for this function:

hid_t THDF5_File::OpenGroup | ( | const hid_t | ParentGroup,
|  | const char * | GroupName
| ) |  |

Open a HDF5 group at a specified place in the file tree.

Parameters

  [in] | ParentGroup | - parent group (where the group is)
  [in] | GroupName | - Group name

Returns

Definition at line 229 of file HDF5_File.cpp.

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | DimensionSizes |
  [out] | Data |

Exceptions

  ios::failure |

Definition at line 954 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | DimensionSizes |
  [out] | Data |

Exceptions

  ios::failure |

Definition at line 988 of file HDF5_File.cpp.

Here is the call graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  MatrixDataType

Exceptions

  ios::failure |

Definition at line 1155 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |

Returns
  DomainType

Exceptions

  ios::failure |

Definition at line 1190 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadScalarValue | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName,
|  | float & | Value
| ) |  |

Read the scalar value under a specified group - float value.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [out] | Value |

Definition at line 922 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadScalarValue | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName,
|  | size_t & | Value
| ) |  |

Read the scalar value under a specified group - index value.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [out] | Value |

Definition at line 937 of file HDF5_File.cpp.

Here is the call graph for this function:

string THDF5_File::ReadStringAttribute | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName,
|  | const char * | AttributeName
| ) |  |
| inline

Read integer attribute at a specified place in the file tree.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | AttributeName |

Returns
  Attribute value

Exceptions

  ios::failure |

Definition at line 1254 of file HDF5_File.cpp.

Here is the caller graph for this function:

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)

Parameters

  [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.

Here is the caller graph for this function:

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.

Parameters

  [in] | HDF5_Dataset_id | - Dataset id
  [in] | Position | - Position in the dataset
  [in] | Size | - Size of the hyperslab
  [in] | Data | - Data to be written

Exceptions

  ios::failure |

Definition at line 467 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::WriteHyperSlab | ( | const hid_t | HDF5_Dataset_id,
|  | const TDimensionSizes & | Position,
|  | const TDimensionSizes & | Size,
|  | const size_t * | Data
| ) |  |

Write hyperslab.

Parameters

  [in] | HDF5_Dataset_id | - Dataset id
  [in] | Position | - Position in the dataset
  [in] | Size | - Size of the hyperslab
  [in] | Data | - Data to be written

Exceptions

  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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | MatrixDataType |

Definition at line 1116 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | MatrixDomainType |

Definition at line 1135 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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)

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | Value |

Definition at line 794 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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)

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | Value |

Definition at line 858 of file HDF5_File.cpp.

Here is the call graph for this function:

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]

Parameters

  [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

Warning
  - very slow at this version of HDF5 for orthogonal planes-> DO NOT USE

Definition at line 716 of file HDF5_File.cpp.

void THDF5_File::WriteStringAttribute | ( | const hid_t | ParentGroup,
|  | const char * | DatasetName,
|  | const char * | AttributeName,
|  | const string & | Value
| ) |  |
| inline

Write integer attribute at a specified place in the file tree.

Parameters

  [in] | ParentGroup |
  [in] | DatasetName |
  [in] | AttributeName |
  [in] | Value |

Exceptions

  ios::failure |

Definition at line 1225 of file HDF5_File.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- HDF5/HDF5_File.h
- HDF5/HDF5_File.cpp