Program Listing for File hdf5.h
↰ Return to documentation for file (include/amici/hdf5.h)
#ifndef AMICI_HDF5_H
#define AMICI_HDF5_H
#include <memory>
#include <string>
#include <vector>
#include <H5Cpp.h>
#include <gsl/gsl-lite.hpp>
/* Macros for enabling/disabling HDF5 error auto-printing
* AMICI_H5_SAVE_ERROR_HANDLER and AMICI_H5_RESTORE_ERROR_HANDLER must be called
* within the same context, otherwise the stack handler is lost. */
#define AMICI_H5_SAVE_ERROR_HANDLER \
herr_t (*old_func)(void*); \
void* old_client_data; \
H5Eget_auto1(&old_func, &old_client_data); \
H5Eset_auto1(NULL, NULL)
#define AMICI_H5_RESTORE_ERROR_HANDLER H5Eset_auto1(old_func, old_client_data)
namespace amici {
class ReturnData;
class ExpData;
class Model;
class Solver;
struct LogItem;
namespace hdf5 {
/* Functions for reading and writing AMICI data to/from HDF5 files. */
H5::H5File create_or_open_for_writing(std::string const& hdf5filename);
void read_solver_settings_from_hdf5(
const H5::H5File& file, Solver& solver, std::string const& datasetPath
);
void write_solver_settings_to_hdf5(
Solver const& solver, std::string const& hdf5Filename,
std::string const& hdf5Location
);
void write_solver_settings_to_hdf5(
Solver const& solver, H5::H5File const& file,
std::string const& hdf5Location
);
void read_solver_settings_from_hdf5(
std::string const& hdffile, Solver& solver, std::string const& datasetPath
);
void read_model_data_from_hdf5(
std::string const& hdffile, Model& model, std::string const& datasetPath
);
void read_model_data_from_hdf5(
H5::H5File const& file, Model& model, std::string const& datasetPath
);
void write_return_data_to_hdf5(
ReturnData const& rdata, H5::H5File const& file,
std::string const& hdf5Location
);
void write_return_data_to_hdf5(
ReturnData const& rdata, std::string const& hdf5Filename,
std::string const& hdf5Location
);
void write_return_data_diagnosis(
ReturnData const& rdata, H5::H5File const& file,
std::string const& hdf5Location
);
void write_log_items_to_hdf5(
H5::H5File const& file, std::vector<LogItem> const& logItems,
std::string const& hdf5Location
);
void create_group(
const H5::H5File& file, std::string const& groupPath,
bool recursively = true
);
std::unique_ptr<ExpData> read_exp_data_from_hdf5(
std::string const& hdf5Filename, std::string const& hdf5Root,
Model const& model
);
void write_exp_data_to_hdf5(
ExpData const& edata, H5::H5File const& file,
std::string const& hdf5Location
);
void write_exp_data_to_hdf5(
ExpData const& edata, std::string const& filepath,
std::string const& hdf5Location
);
bool attribute_exists(
H5::H5File const& file, std::string const& optionsObject,
std::string const& attributeName
);
bool attribute_exists(
H5::H5Object const& object, std::string const& attributeName
);
void create_and_write_int_1d_dataset(
H5::H5File const& file, std::string const& datasetName,
gsl::span<int const> buffer
);
void create_and_write_int_2d_dataset(
H5::H5File const& file, std::string const& datasetName,
gsl::span<int const> buffer, hsize_t m, hsize_t n
);
void create_and_write_double_1d_dataset(
H5::H5File const& file, std::string const& datasetName,
gsl::span<double const> buffer
);
void create_and_write_double_2d_dataset(
H5::H5File const& file, std::string const& datasetName,
gsl::span<double const> buffer, hsize_t m, hsize_t n
);
void create_and_write_double_3d_dataset(
H5::H5File const& file, std::string const& datasetName,
gsl::span<double const> buffer, hsize_t m, hsize_t n, hsize_t o
);
std::string get_string_attribute(
H5::H5File const& file, std::string const& optionsObject,
std::string const& attributeName
);
double get_double_scalar_attribute(
const H5::H5File& file, std::string const& optionsObject,
std::string const& attributeName
);
int get_int_scalar_attribute(
const H5::H5File& file, std::string const& optionsObject,
std::string const& attributeName
);
std::vector<int>
get_int_1d_dataset(const H5::H5File& file, std::string const& name);
std::vector<double>
get_double_1d_dataset(const H5::H5File& file, std::string const& name);
std::vector<double> get_double_2d_dataset(
const H5::H5File& file, std::string const& name, hsize_t& m, hsize_t& n
);
std::vector<double> get_double_3d_dataset(
const H5::H5File& file, std::string const& name, hsize_t& m, hsize_t& n,
hsize_t& o
);
bool location_exists(std::string const& filename, std::string const& location);
bool location_exists(H5::H5File const& file, std::string const& location);
} // namespace hdf5
} // namespace amici
#endif