Commit 0a48955b authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

[IO] Add static data to sparse files: bin radius (1d) & masked pixel radius (2d)

parent 88d09350
......@@ -384,6 +384,8 @@ namespace io
saving_params const& params, // Saving params
int nb_bins, // Data
point_t const& dim, // HDF5
lima::frame radius1d, //
lima::frame radius2d_mask, //
h5::path entry_name = "/entry_0000", // Nexus
h5::path detector_name = "Simulator", //
double exposure_time = 0.1, //
......@@ -483,19 +485,19 @@ namespace io
// Set dimensions
hsize_t dims[] = {m_nb_bins};
dataspace file_space(lengthof(dims), dims);
dataspace mem_space(lengthof(dims), dims);
auto file_space = dataspace::create_simple(lengthof(dims), dims);
auto mem_space = file_space;
predef_datatype dtype = datatype(v);
// Create dataset
dataset mask(data, "radius"_p, dtype, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
auto radius = dataset::create(data, "radius"_p, dtype, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
// Add attributes
mask.attrs.create("interpretation", "spectrum"s);
mask.attrs.create("long_name", "Bin radius"s);
radius.attrs.create("interpretation", "spectrum"s);
radius.attrs.create("long_name", "Bin radius"s);
// Write mask
H5Dwrite(mask, dtype, mem_space, file_space, H5P_DEFAULT, &v(0, 0));
// Write radius
radius.write(&v(0, 0), dtype, mem_space, file_space);
}
// Radius2d-Mask
......@@ -515,19 +517,19 @@ namespace io
// Set dimensions
hsize_t dims[] = {m_dimensions.y, m_dimensions.x};
dataspace file_space(lengthof(dims), dims);
dataspace mem_space(lengthof(dims), dims);
auto file_space = dataspace::create_simple(lengthof(dims), dims);
auto mem_space = file_space;
predef_datatype dtype = datatype(v);
// Create dataset
dataset mask(data, "mask"_p, dtype, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
auto mask = dataset::create(data, "mask"_p, dtype, file_space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
// Add attributes
mask.attrs.create("interpretation", "image"s);
mask.attrs.create("long_name", "Detector masked radius2d"s);
// Write mask
H5Dwrite(mask, dtype, mem_space, file_space, H5P_DEFAULT, &v(0, 0));
mask.write(&v(0, 0), dtype, mem_space, file_space);
}
// Background
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment