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;
namespace hdf5 {
/* Functions for reading and writing AMICI data to/from HDF5 files. */
H5::H5File createOrOpenForWriting(std::string const &hdf5filename);
void readSolverSettingsFromHDF5(const H5::H5File &file, Solver &solver,
std::string const &datasetPath);
void writeSolverSettingsToHDF5(Solver const& solver,
std::string const& hdf5Filename,
std::string const& hdf5Location);
void writeSolverSettingsToHDF5(Solver const& solver,
H5::H5File const& file,
std::string const& hdf5Location);
void readSolverSettingsFromHDF5(std::string const &hdffile, Solver &solver,
std::string const &datasetPath);
void readModelDataFromHDF5(std::string const &hdffile, Model &model,
std::string const &datasetPath);
void readModelDataFromHDF5(H5::H5File const &file, Model &model,
std::string const &datasetPath);
void writeReturnData(const ReturnData &rdata, H5::H5File const &file,
const std::string &hdf5Location);
void writeReturnData(const ReturnData &rdata, std::string const &hdf5Filename,
const std::string &hdf5Location);
void writeReturnDataDiagnosis(const ReturnData &rdata, H5::H5File const &file,
const std::string &hdf5Location);
void createGroup(const H5::H5File &file, std::string const &groupPath,
bool recursively = true);
std::unique_ptr<ExpData> readSimulationExpData(const std::string &hdf5Filename,
const std::string &hdf5Root,
const Model &model);
void writeSimulationExpData(const ExpData &edata, H5::H5File const &file,
const std::string &hdf5Location);
bool attributeExists(H5::H5File const &file, const std::string &optionsObject,
const std::string &attributeName);
bool attributeExists(H5::H5Object const &object,
const std::string &attributeName);
void createAndWriteInt1DDataset(H5::H5File const &file,
std::string const &datasetName,
gsl::span<const int> buffer);
void createAndWriteInt2DDataset(H5::H5File const &file,
std::string const &datasetName,
gsl::span<const int> buffer, hsize_t m,
hsize_t n);
void createAndWriteDouble1DDataset(H5::H5File const &file,
std::string const &datasetName,
gsl::span<const double> buffer);
void createAndWriteDouble2DDataset(H5::H5File const &file,
std::string const &datasetName,
gsl::span<const double> buffer, hsize_t m,
hsize_t n);
void createAndWriteDouble3DDataset(H5::H5File const &file,
std::string const &datasetName,
gsl::span<const double> buffer, hsize_t m,
hsize_t n, hsize_t o);
double getDoubleScalarAttribute(const H5::H5File &file,
const std::string &optionsObject,
const std::string &attributeName);
int getIntScalarAttribute(const H5::H5File &file,
const std::string &optionsObject,
const std::string &attributeName);
std::vector<int> getIntDataset1D(const H5::H5File &file,
std::string const &name);
std::vector<double> getDoubleDataset1D(const H5::H5File &file,
std::string const &name);
std::vector<double> getDoubleDataset2D(const H5::H5File &file,
std::string const &name, hsize_t &m,
hsize_t &n);
std::vector<double> getDoubleDataset3D(const H5::H5File &file,
std::string const &name, hsize_t &m,
hsize_t &n, hsize_t &o);
bool locationExists(std::string const &filename, std::string const &location);
bool locationExists(H5::H5File const &file, std::string const &location);
} // namespace hdf5
} // namespace amici
#endif