From 039b68bea0ce3cc0f356ea28a48d861f08984550 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Mon, 24 Apr 2023 14:55:14 +0200 Subject: [PATCH] add monofonic metadata to Gadget-HDF5 output --- src/plugins/output_gadget_hdf5.cc | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/plugins/output_gadget_hdf5.cc b/src/plugins/output_gadget_hdf5.cc index a9144bd..4f18225 100644 --- a/src/plugins/output_gadget_hdf5.cc +++ b/src/plugins/output_gadget_hdf5.cc @@ -117,6 +117,46 @@ public: unlink(this_fname_.c_str()); HDFCreateFile(this_fname_); + + // Write MUSIC configuration header + int order = cf_.get_value("setup", "LPTorder"); + std::string load = cf_.get_value("setup", "ParticleLoad"); + std::string tf = cf_.get_value("cosmology", "transfer"); + std::string cosmo_set = cf_.get_value("cosmology", "ParameterSet"); + std::string rng = cf_.get_value("random", "generator"); + int do_fixing = cf_.get_value("setup", "DoFixing"); + int do_invert = cf_.get_value("setup", "DoInversion"); + int do_baryons = cf_.get_value("setup", "DoBaryons"); + int do_baryonsVrel = cf_.get_value("setup", "DoBaryonVrel"); + int L = cf_.get_value("setup", "GridRes"); + + HDFCreateGroup(fname_, "ICs_parameters"); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Code", std::string("MUSIC2 - monofonIC")); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Git Revision", std::string(GIT_REV)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Git Tag", std::string(GIT_TAG)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Git Branch", std::string(GIT_BRANCH)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Precision", std::string(CMAKE_PRECISION_STR)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Convolutions", std::string(CMAKE_CONVOLVER_STR)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "PLT", std::string(CMAKE_PLT_STR)); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "LPT Order", order); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Particle Load", load); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Transfer Function", tf); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Cosmology Parameter Set", cosmo_set); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Random Generator", rng); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Mode Fixing", do_fixing); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Mode inversion", do_invert); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Baryons", do_baryons); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Baryons Relative Velocity", do_baryonsVrel); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Grid Resolution", L); + + if (tf == "CLASS") { + double ztarget = cf_.get_value("cosmology", "ztarget"); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Target Redshift", ztarget); + } + if (rng == "PANPHASIA") { + std::string desc = cf_.get_value("random", "descriptor"); + HDFWriteGroupAttribute(fname_, "ICs_parameters", "Descriptor", desc); + } } // use destructor to write header post factum