61{
62 H5::Group ref_axes_grp = hist_grp.createGroup("ref_axes");
63
64 for (size_t ax_n = 0; ax_n < axes.size(); ++ax_n) {
65 const auto& ax = axes.at(ax_n);
66 H5::Group ax_grp = ref_axes_grp.createGroup("axis_" + std::to_string(ax_n));
67
68 if (ax.n_regular_bins) {
71 static_cast<double>(ax.edges.front()));
73 static_cast<double>(ax.edges.back()));
75 } else {
77 hsize_t nedges = ax.edges.size();
78 H5::DataSpace edge_space(1, &nedges);
79 H5::DSetCreatPropList edge_props;
80 edge_props.setChunk(1, &nedges);
81 edge_props.setDeflate(7);
82 H5::DataSet edge_ds = ax_grp.createDataSet(
83 "edges", H5::PredType::NATIVE_FLOAT, edge_space, edge_props);
84 edge_ds.write(ax.edges.data(), H5::PredType::NATIVE_FLOAT);
85 }
86
90
91 H5::Group ax_meta = ax_grp.createGroup("metadata");
92 if (!ax.name.empty()) {
94 }
95 ax_grp.createGroup("writer_info");
96 }
97
98
99 std::vector<hobj_ref_t> axis_refs(axes.size());
100 for (size_t ax_n = 0; ax_n < axes.size(); ++ax_n) {
101 std::string ax_path = "ref_axes/axis_" + std::to_string(ax_n);
102 chkerr(H5Rcreate(&axis_refs.at(ax_n), hist_grp.getId(),
103 ax_path.c_str(), H5R_OBJECT, -1),
104 "axis object reference");
105 }
106 hsize_t ref_dim = axes.size();
107 H5::DataSpace ref_space(1, &ref_dim);
108 hist_grp.createDataSet("axes", H5::PredType::STD_REF_OBJ, ref_space)
109 .write(axis_refs.data(), H5::PredType::STD_REF_OBJ);
110}
void chkerr(herr_t code, const std::string &error)
void write_bool_attr(H5::H5Object &obj, const std::string &key, bool val)
void write_str_attr(H5::H5Object &obj, const std::string &key, const std::string &val)
void write_int_attr(H5::H5Object &obj, const std::string &key, int64_t val)
void write_double_attr(H5::H5Object &obj, const std::string &key, double val)