SpECTRE  v2024.09.29
h5::Dat Class Reference

Represents a multicolumn dat file inside an HDF5 file. More...

#include <Dat.hpp>

Public Member Functions

HIDDEN_SYMBOLS void append (const std::vector< double > &data)
 
void append (const std::vector< std::vector< double > > &data)
 
void append (const Matrix &data)
 
const std::vector< std::string > & get_legend () const
 
template<typename T = Matrix>
get_data () const
 
template<typename T = Matrix>
get_data_subset (const std::vector< size_t > &these_columns, size_t first_row=0, size_t num_rows=1) const
 Get only some columns over a range of rows. More...
 
const std::array< hsize_t, 2 > & get_dimensions () const
 
const std::stringget_header () const
 
uint32_t get_version () const
 
const std::stringsubfile_path () const override
 Return the path to the subfile where this object is stored. More...
 
virtual const std::stringsubfile_path () const =0
 Return the path to the subfile where this object is stored. More...
 

Detailed Description

Represents a multicolumn dat file inside an HDF5 file.

A Dat object represents a dat file inside an H5File. A dat file is a multicolumn text file with a header describing what each column represents. Typically dat files are space or tab delimited, and often represent time series data. One common use for them is writing out error norms over the computational domain as a function of time. Inside the H5File they are stored as a string header, and a matrix of doubles holding the data. One problem encountered with dat files is that they quickly increase the file count causing users to run into number of file limitations on HPC systems. Since multiple Dat objects can be stored inside a single H5File the problem of many different dat files being stored as individual files is solved.

Note
This class does not do any caching of data so all data is written as soon as append() is called.

Member Function Documentation

◆ append() [1/3]

void h5::Dat::append ( const Matrix data)

Requires: data.columns() is the same as the number of columns in the file

Effects: appends data to the Dat file

◆ append() [2/3]

HIDDEN_SYMBOLS void h5::Dat::append ( const std::vector< double > &  data)

Requires: data.size() is the same as the number of columns in the file

Effects: appends data to the Dat file

◆ append() [3/3]

void h5::Dat::append ( const std::vector< std::vector< double > > &  data)

Requires: data[0].size() is the same as the number of columns in the file

Effects: appends data to the Dat file

◆ get_data()

template<typename T = Matrix>
T h5::Dat::get_data ( ) const

Returns: all data stored in the Dat file

Example

const Matrix matrix_data_in_dat_file = error_file.get_data();
const auto matrix_data_in_dat_file2 = error_file.get_data<Matrix>();
const auto vector_data_in_dat_file =
error_file.get_data<std::vector<std::vector<double>>>();
A dynamically sized matrix of doubles with column-major storage.
Definition: Matrix.hpp:19

◆ get_data_subset()

template<typename T = Matrix>
T h5::Dat::get_data_subset ( const std::vector< size_t > &  these_columns,
size_t  first_row = 0,
size_t  num_rows = 1 
) const

Get only some columns over a range of rows.

Requires: all members of these_columns have a value less than the number of columns, first_row < last_row and last_row is less than or equal to the number of rows

Returns: a subset of the data from the Dat file

Example

const Matrix matrix_subset_data_in_dat_file =
error_file.get_data_subset({1, 3}, 1, 3);
const auto matrix_subset_data_in_dat_file2 =
error_file.get_data_subset<Matrix>({1, 3}, 1, 3);
const auto vector_subset_data_in_dat_file =
error_file.get_data_subset<std::vector<std::vector<double>>>({1, 3}, 1,
3);

◆ get_dimensions()

const std::array< hsize_t, 2 > & h5::Dat::get_dimensions ( ) const
inline

Returns: the number of rows (first index) and columns (second index)

◆ get_header()

const std::string & h5::Dat::get_header ( ) const
inline

Returns: the header of the Dat file

◆ get_legend()

const std::vector< std::string > & h5::Dat::get_legend ( ) const
inline

Returns: the legend of the Dat file

◆ get_version()

uint32_t h5::Dat::get_version ( ) const
inline

Returns: the user-specified version number of the Dat file

Note
h5::Version returns a uint32_t, so we return one here too for the version

◆ subfile_path()

const std::string & h5::Dat::subfile_path ( ) const
inlineoverridevirtual

Return the path to the subfile where this object is stored.

Implements h5::Object.


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