From f42cc16315fc990e57fb60bb47ed7c4a06e1a95c Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Sat, 23 Nov 2024 17:36:21 +0100 Subject: [PATCH] Add function for writing ExpData to HDF5 (#2588) So far, there was only a H5File-based version, which is inconvenient to use from Python. This allows passing a file name instead. --- include/amici/hdf5.h | 16 ++++++++++++++-- src/hdf5.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/amici/hdf5.h b/include/amici/hdf5.h index 32cd4c925a..731c4ddecc 100644 --- a/include/amici/hdf5.h +++ b/include/amici/hdf5.h @@ -164,8 +164,8 @@ std::unique_ptr readSimulationExpData( /** * @brief Write AMICI experimental data to HDF5 file. * @param edata The experimental data which is to be written - * @param file Name of HDF5 file - * @param hdf5Location Path inside the HDF5 file to object having ExpData + * @param file HDF5 file + * @param hdf5Location Path inside the HDF5 file */ void writeSimulationExpData( @@ -173,6 +173,18 @@ void writeSimulationExpData( std::string const& hdf5Location ); +/** + * @brief Write AMICI experimental data to HDF5 file. + * @param edata The experimental data which is to be written + * @param file Name of HDF5 file + * @param hdf5Location Path inside the HDF5 file + */ +void writeSimulationExpData( + ExpData const& edata, std::string const& hdf5Filename, + std::string const& hdf5Location + ); + + /** * @brief Check whether an attribute with the given name exists * on the given dataset. diff --git a/src/hdf5.cpp b/src/hdf5.cpp index f9914452eb..a22ec65a2b 100644 --- a/src/hdf5.cpp +++ b/src/hdf5.cpp @@ -1388,5 +1388,14 @@ std::vector getDoubleDataset3D( return result; } +void writeSimulationExpData( + ExpData const& edata, std::string const& hdf5Filename, + std::string const& hdf5Location +) { + auto file = createOrOpenForWriting(hdf5Filename); + + writeSimulationExpData(edata, file, hdf5Location); +} + } // namespace hdf5 } // namespace amici