private HDF5Group createHDF5Group(SpectrumProperties props,
Map<String, Detector> detectors,
Element rootElement, String name) throws IOException {
HDF5Group rootGroup = HDF5Group.createRoot();
// Save version, class
rootGroup.setAttribute("version", VERSION);
rootGroup.setAttribute("_class", "Results");
// Create results group
String identifier = rootElement.getAttributeValue("uuid");
rootGroup.setAttribute("identifiers", new String[] { identifier });
HDF5Group resultsGroup =
rootGroup.createSubgroup("result-" + identifier);
// Save results from detectors
String key;
Detector detector;
for (Entry<String, Detector> entry : detectors.entrySet()) {
key = entry.getKey();
detector = entry.getValue();
detector.saveResults(resultsGroup, key);
}
// Save overall log
Properties logProps = new Properties();
logProps.putAll(props.getPropertyMap());
createLog(logProps);
resultsGroup.setAttribute("log", props.toString());
// Save options
XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
String optionsStr = outputter.outputString(rootElement);
resultsGroup.setAttribute("options", optionsStr);
rootGroup.setAttribute("options", optionsStr);
return rootGroup;
}