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 noexcept

Matrix get_data () const

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 noexcept

uint32_t get_version () const noexcept

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

## ◆ append() [1/3]

 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() [2/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

## ◆ append() [3/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

## ◆ get_data()

 Matrix h5::Dat::get_data ( ) const

Returns: all data stored in the Dat file

### Example

const Matrix data_in_dat_file = []() {
Matrix result(4, 4);
result(0, 0) = 0.0;
result(0, 1) = 0.1;
result(0, 2) = 0.2;
result(0, 3) = 0.3;
result(1, 0) = 0.11;
result(1, 1) = 0.4;
result(1, 2) = 0.5;
result(1, 3) = 0.6;
result(2, 0) = 0.22;
result(2, 1) = 0.55;
result(2, 2) = 0.6;
result(2, 3) = 0.8;
result(3, 0) = 0.33;
result(3, 1) = 0.66;
result(3, 2) = 0.77;
result(3, 3) = 0.9;
return result;
}();
CHECK(error_file.get_data() == data_in_dat_file);

## ◆ get_data_subset()

 Matrix 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 auto subset = error_file.get_data_subset({1, 3}, 1, 3);
const Matrix answer = []() {
Matrix result(3, 2);
result(0, 0) = 0.4;
result(0, 1) = 0.6;
result(1, 0) = 0.55;
result(1, 1) = 0.8;
result(2, 0) = 0.66;
result(2, 1) = 0.9;
return result;
}();

## ◆ get_dimensions()

 const std::array& h5::Dat::get_dimensions ( ) const
inlinenoexcept

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

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

Returns: the header of the Dat file

## ◆ get_legend()

 const std::vector& h5::Dat::get_legend ( ) const
inlinenoexcept

Returns: the legend of the Dat file

## ◆ get_version()

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

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

The documentation for this class was generated from the following files:
• src/IO/H5/Dat.hpp
• src/IO/H5/Dat.cpp