Skip to content

Commit

Permalink
Add function for writing ExpData to HDF5 (#2588)
Browse files Browse the repository at this point in the history
So far, there was only a H5File-based version, which is inconvenient to use from Python.

This allows passing a file name instead.
  • Loading branch information
dweindl authored Nov 23, 2024
1 parent 2a25b27 commit f42cc16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/amici/hdf5.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,27 @@ std::unique_ptr<ExpData> 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(
ExpData const& edata, H5::H5File const& file,
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.
Expand Down
9 changes: 9 additions & 0 deletions src/hdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,5 +1388,14 @@ std::vector<double> 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

0 comments on commit f42cc16

Please sign in to comment.