Commit f46f2007 authored by Laurent Claustre's avatar Laurent Claustre

A more acceptable format for users, by P.Boesecke and M.Sztuchi ID01/ID02)

parent 71e8e019
......@@ -46,9 +46,10 @@ struct SaveContainerHdf5::_File
m_image_dataset(NULL),
m_file(NULL),
m_entry(NULL),
m_measurement_detector(NULL),
m_measurement(NULL),
m_instrument_detector(NULL),
m_instrument_detector_meta_data(NULL),
m_instrument_detector_data(NULL),
m_instrument_detector_data_parameters(NULL),
m_entry_index(0)
{}
......@@ -56,9 +57,10 @@ struct SaveContainerHdf5::_File
{
delete m_image_dataspace;
delete m_image_dataset;
delete m_measurement_detector;
delete m_measurement;
delete m_instrument_detector;
delete m_instrument_detector_meta_data;
delete m_instrument_detector_data;
delete m_instrument_detector_data_parameters;
delete m_entry;
delete m_file;
}
......@@ -73,9 +75,10 @@ struct SaveContainerHdf5::_File
m_image_dataset = other.m_image_dataset;
m_file = other.m_file;
m_entry = other.m_entry;
m_measurement_detector = other.m_measurement_detector;
m_measurement = other.m_measurement;
m_instrument_detector = other.m_instrument_detector;
m_instrument_detector_meta_data = other.m_instrument_detector_meta_data;
m_instrument_detector_data = other.m_instrument_detector_data;
m_instrument_detector_data_parameters = other.m_instrument_detector_data_parameters;
m_entry_index = other.m_entry_index;
m_entry_name = other.m_entry_name;
m_data_name = other.m_data_name;
......@@ -85,9 +88,10 @@ struct SaveContainerHdf5::_File
other.m_image_dataset = NULL;
other.m_file = NULL;
other.m_entry = NULL;
other.m_measurement_detector = NULL;
other.m_measurement = NULL;
other.m_instrument_detector = NULL;
other.m_instrument_detector_meta_data = NULL;
other.m_instrument_detector_data = NULL;
other.m_instrument_detector_data_parameters = NULL;
}
bool m_format_written;
......@@ -98,9 +102,10 @@ struct SaveContainerHdf5::_File
DataSet *m_image_dataset;
H5File *m_file;
Group *m_entry;
Group *m_measurement_detector;
Group *m_measurement;
Group *m_instrument_detector;
Group *m_instrument_detector_meta_data;
Group *m_instrument_detector_data;
Group *m_instrument_detector_data_parameters;
int m_entry_index;
string m_entry_name;
string m_data_name;
......@@ -359,26 +364,27 @@ void* SaveContainerHdf5::_open(const std::string &filename, std::ios_base::openm
new_file.m_instrument_detector = new Group(instrument.createGroup(m_ct_parameters.det_name));
string nxdetector = "NXdetector";
write_h5_attribute(*new_file.m_instrument_detector, "NX_class", nxdetector);
Group measurement = Group(new_file.m_entry->createGroup("measurement"));
string nxcollection = "NXcollection";
write_h5_attribute(measurement, "NX_class", nxcollection);
new_file.m_measurement_detector = new Group(measurement.createGroup(m_ct_parameters.det_name));
string nxdata = "NXdata";
write_h5_attribute(*new_file.m_measurement_detector, "NX_class", nxdata);
// Add attribute "default" for path to the NXdata
new_file.m_data_name = "image_data";
string path_to_nxdata = new_file.m_entry_name + "/measurement/" + m_ct_parameters.det_name;
new_file.m_instrument_detector_data = new Group(new_file.m_instrument_detector->createGroup("data"));
new_file.m_instrument_detector_data_parameters =
new Group(new_file.m_instrument_detector_data->createGroup("parameters"));
// set attributes for default path to data, measurement/detector is the default path but a soft-link to instrument/detector
new_file.m_data_name = "images";
string path_to_nxdata = new_file.m_entry_name + "/measurement/" + m_ct_parameters.det_name +"/data";
write_h5_attribute(*new_file.m_entry, "default", path_to_nxdata);
// Add attribute "signal" for final data path
write_h5_attribute(*new_file.m_measurement_detector, "signal", new_file.m_data_name);
new_file.m_instrument_detector_meta_data =
new Group(new_file.m_instrument_detector->createGroup("meta_data"));
string nxdata = "NXdata";
write_h5_attribute(*new_file.m_instrument_detector_data, "NX_class", nxdata);
write_h5_attribute(*new_file.m_instrument_detector_data, "signal", new_file.m_data_name);
// Finally create a measurement group, it will only contain a sof-link to intrument_detector created at _close()
new_file.m_measurement = new Group(new_file.m_entry->createGroup("measurement"));
string nxcollection = "NXcollection";
write_h5_attribute(*new_file.m_measurement, "NX_class", nxcollection);
// write the control parameters (detinfo, acq and image)
//Det Info
......@@ -447,8 +453,7 @@ void* SaveContainerHdf5::_open(const std::string &filename, std::ios_base::openm
} else {
new_file.m_entry = new Group(new_file.m_file->openGroup(strname));
Group instrument = Group(new_file.m_entry->openGroup(m_ct_parameters.instrument_name));
Group measurement = Group(new_file.m_entry->openGroup("measurement"));
new_file.m_measurement_detector = new Group(measurement.openGroup(m_ct_parameters.det_name));
new_file.m_measurement = new Group(new_file.m_entry->openGroup("measurement"));
new_file.m_instrument_detector = new Group(instrument.openGroup(m_ct_parameters.det_name));
}
} catch (FileIException &error) {
......@@ -465,12 +470,10 @@ void SaveContainerHdf5::_close(void* f) {
_File *file = (_File*)f;
if (!file->m_in_append || m_is_multiset) {
// Create soft link to the Data and NXdetector groups
// Create in measurement a soft link to the instrument detector group
string root_path = file->m_entry_name + "/" + m_ct_parameters.instrument_name+ "/";
string path = root_path + m_ct_parameters.det_name;
file->m_measurement_detector->link(H5L_TYPE_SOFT, path, "information");
path += "/" + file->m_data_name;
file->m_measurement_detector->link(H5L_TYPE_SOFT, path, file->m_data_name);
file->m_measurement->link(H5L_TYPE_SOFT, path, m_ct_parameters.det_name);
// ISO 8601 Time format
......@@ -559,12 +562,12 @@ long SaveContainerHdf5::_writeFile(void* f,Data &aData,
string key = it->first;
string value = it->second;
write_h5_dataset(*file->m_instrument_detector_meta_data,
write_h5_dataset(*file->m_instrument_detector_data_parameters,
key.c_str(),value);
}
}
delete file->m_instrument_detector_meta_data;
file->m_instrument_detector_meta_data = NULL;
delete file->m_instrument_detector_data_parameters;
file->m_instrument_detector_data_parameters = NULL;
// create the image data structure in the file
hsize_t data_dims[3], max_dims[3];
......@@ -595,7 +598,7 @@ long SaveContainerHdf5::_writeFile(void* f,Data &aData,
// create new dspace
file->m_image_dataspace = new DataSpace(RANK_THREE, data_dims, NULL);
file->m_image_dataset =
new DataSet(file->m_instrument_detector->createDataSet(file->m_data_name,
new DataSet(file->m_instrument_detector_data->createDataSet(file->m_data_name,
data_type,
*file->m_image_dataspace,
plist));
......@@ -605,7 +608,7 @@ long SaveContainerHdf5::_writeFile(void* f,Data &aData,
file->m_format_written = true;
} else if (file->m_in_append && !m_is_multiset && !file->m_dataset_extended) {
hsize_t allocated_dims[3];
file->m_image_dataset = new DataSet(file->m_instrument_detector->
file->m_image_dataset = new DataSet(file->m_instrument_detector_data->
openDataSet(file->m_data_name));
file->m_image_dataspace = new DataSpace(file->m_image_dataset->getSpace());
file->m_image_dataspace->getSimpleExtentDims(allocated_dims);
......
Markdown is supported
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