Skip to content

Commit

Permalink
Add function for writing ExpData to HDF5
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 committed Nov 20, 2024
1 parent 2a25b27 commit 8d589f8
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(

Check warning on line 1391 in src/hdf5.cpp

View check run for this annotation

Codecov / codecov/patch

src/hdf5.cpp#L1391

Added line #L1391 was not covered by tests
ExpData const& edata, std::string const& hdf5Filename,
std::string const& hdf5Location
) {
auto file = createOrOpenForWriting(hdf5Filename);

Check warning on line 1395 in src/hdf5.cpp

View check run for this annotation

Codecov / codecov/patch

src/hdf5.cpp#L1395

Added line #L1395 was not covered by tests

writeSimulationExpData(edata, file, hdf5Location);
}

Check warning on line 1398 in src/hdf5.cpp

View check run for this annotation

Codecov / codecov/patch

src/hdf5.cpp#L1397-L1398

Added lines #L1397 - L1398 were not covered by tests

} // namespace hdf5
} // namespace amici

0 comments on commit 8d589f8

Please sign in to comment.