Formatted package
This commit is contained in:
Dhanya Thattil
2022-08-05 15:39:34 +02:00
committed by GitHub
parent 7173785b29
commit 6bf9dbf6d3
89 changed files with 1366 additions and 1210 deletions

View File

@ -3,7 +3,6 @@
#include "MasterAttributes.h"
#include <time.h>
namespace sls {
void MasterAttributes::GetBinaryAttributes(
@ -33,8 +32,7 @@ void MasterAttributes::GetBinaryAttributes(
GetCtbBinaryAttributes(w);
break;
default:
throw RuntimeError(
"Unknown Detector type to get master attributes");
throw RuntimeError("Unknown Detector type to get master attributes");
}
GetFinalBinaryAttributes(w);
w->EndObject();
@ -66,8 +64,7 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
WriteCtbHDF5Attributes(fd, group);
break;
default:
throw RuntimeError(
"Unknown Detector type to get master attributes");
throw RuntimeError("Unknown Detector type to get master attributes");
}
WriteFinalHDF5Attributes(fd, group);
}
@ -169,14 +166,15 @@ void MasterAttributes::GetFinalBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
char c[1024]{};
// version
{
double version = BINARY_WRITER_VERSION;
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::Attribute attribute =
fd->createAttribute("Version", H5::PredType::NATIVE_DOUBLE, dataspace);
H5::Attribute attribute = fd->createAttribute(
"Version", H5::PredType::NATIVE_DOUBLE, dataspace);
attribute.write(H5::PredType::NATIVE_DOUBLE, &version);
}
// timestamp
@ -211,22 +209,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
// geometry x
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Geometry in x axis",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Geometry in x axis", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.x, H5::PredType::NATIVE_INT);
}
// geometry y
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Geometry in y axis",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Geometry in y axis", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&geometry.y, H5::PredType::NATIVE_INT);
}
// Image Size
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Image Size", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Image Size", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&imageSize, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
@ -239,22 +237,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
// npixels x
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of pixels in x axis",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Number of pixels in x axis", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.x, H5::PredType::NATIVE_INT);
}
// npixels y
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of pixels in y axis",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Number of pixels in y axis", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&nPixels.y, H5::PredType::NATIVE_INT);
}
// Maximum frames per file
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Maximum frames per file",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Maximum frames per file", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&maxFramesPerFile, H5::PredType::NATIVE_INT);
}
// Frame Discard Policy
@ -262,15 +260,15 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset = group->createDataSet("Frame Discard Policy",
strdatatype, dataspace);
strdatatype, dataspace);
strcpy_safe(c, ToString(frameDiscardMode));
dataset.write(c, strdatatype);
}
// Frame Padding
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Frame Padding",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Frame Padding", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&framePadding, H5::PredType::NATIVE_INT);
}
// Scan Parameters
@ -285,47 +283,48 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
// Total Frames
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Total Frames",
H5::PredType::STD_U64LE, dataspace);
H5::DataSet dataset = group->createDataSet(
"Total Frames", H5::PredType::STD_U64LE, dataspace);
dataset.write(&totalFrames, H5::PredType::STD_U64LE);
}
// Receiver Roi xmin
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi xmin",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"receiver roi xmin", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmin, H5::PredType::NATIVE_INT);
}
// Receiver Roi xmax
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi xmax",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"receiver roi xmax", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmax, H5::PredType::NATIVE_INT);
}
// Receiver Roi ymin
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi ymin",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"receiver roi ymin", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymin, H5::PredType::NATIVE_INT);
}
// Receiver Roi ymax
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("receiver roi ymax",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"receiver roi ymax", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymax, H5::PredType::NATIVE_INT);
}
}
void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
char c[1024]{};
// Total Frames in file
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Frames in File",
H5::PredType::STD_U64LE, dataspace);
H5::DataSet dataset = group->createDataSet(
"Frames in File", H5::PredType::STD_U64LE, dataspace);
dataset.write(&framesInFile, H5::PredType::STD_U64LE);
}
// additional json header
@ -334,7 +333,7 @@ void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group
H5::StrType strdatatype(H5::PredType::C_S1, json.length());
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Additional JSON Header",
strdatatype, dataspace);
strdatatype, dataspace);
strcpy_safe(c, ToString(additionalJsonHeader));
dataset.write(c, strdatatype);
}
@ -362,8 +361,8 @@ void MasterAttributes::WriteHDF5Period(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&dynamicRange, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
@ -375,8 +374,8 @@ void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5TenGiga(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Ten Giga Enable",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Ten Giga Enable", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&tenGiga, H5::PredType::NATIVE_INT);
}
@ -384,38 +383,40 @@ void MasterAttributes::WriteHDF5ROI(H5::H5File *fd, H5::Group *group) {
// Roi xmin
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("roi xmin", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"roi xmin", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmin, H5::PredType::NATIVE_INT);
}
// Roi xmax
{
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("roi xmax", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"roi xmax", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&detectorRoi.xmax, H5::PredType::NATIVE_INT);
}
}
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5::H5File *fd,
H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Number of UDP Interfaces",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Number of UDP Interfaces", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&numUDPInterfaces, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Number of rows", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Number of rows", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&readNRows, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd,
H5::Group *group) {
char c[1024]{};
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Threshold Energy",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Threshold Energy", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT);
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256);
@ -425,7 +426,8 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group
attribute.write(strdatatype, c);
}
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd,
H5::Group *group) {
char c[1024]{};
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
@ -462,7 +464,8 @@ void MasterAttributes::WriteHDF5SubQuad(H5::H5File *fd, H5::Group *group) {
dataset.write(&quad, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd,
H5::Group *group) {
char c[1024]{};
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
@ -474,8 +477,8 @@ void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group
void MasterAttributes::WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Counter Mask", H5::PredType::STD_U32LE, dataspace);
H5::DataSet dataset = group->createDataSet(
"Counter Mask", H5::PredType::STD_U32LE, dataspace);
dataset.write(&counterMask, H5::PredType::STD_U32LE);
}
@ -491,7 +494,8 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group) {
}
}
void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd,
H5::Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{};
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
@ -529,43 +533,45 @@ void MasterAttributes::WriteHDF5AdcMask(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5AnalogFlag(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Analog Flag", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Analog Flag", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&analog, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5AnalogSamples(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5AnalogSamples(H5::H5File *fd,
H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Analog Samples", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Analog Samples", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&analogSamples, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Digital Flag", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Digital Flag", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&digital, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DigitalSamples(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteHDF5DigitalSamples(H5::H5File *fd,
H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Digital Samples",
H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Digital Samples", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&digitalSamples, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset =
group->createDataSet("Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
H5::DataSet dataset = group->createDataSet(
"Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
}
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Dbit Bitset List",
H5::PredType::STD_U64LE, dataspace);
H5::DataSet dataset = group->createDataSet(
"Dbit Bitset List", H5::PredType::STD_U64LE, dataspace);
dataset.write(&dbitlist, H5::PredType::STD_U64LE);
}
#endif
@ -586,7 +592,8 @@ void MasterAttributes::GetGotthardBinaryAttributes(
};
#ifdef HDF5C
void MasterAttributes::WriteGotthardHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteGotthardHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5ROI(fd, group);
@ -606,7 +613,8 @@ void MasterAttributes::GetJungfrauBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
@ -639,7 +647,8 @@ void MasterAttributes::GetEigerBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteEigerHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteEigerHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5DynamicRange(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
MasterAttributes::WriteHDF5Exptime(fd, group);
@ -678,7 +687,8 @@ void MasterAttributes::GetMythen3BinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteMythen3HDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteMythen3HDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5DynamicRange(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
@ -701,7 +711,8 @@ void MasterAttributes::GetGotthard2BinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5BurstMode(fd, group);
@ -723,7 +734,8 @@ void MasterAttributes::GetMoenchBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
@ -757,7 +769,8 @@ void MasterAttributes::GetCtbBinaryAttributes(
}
#ifdef HDF5C
void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd, H5::Group *group) {
void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd,
H5::Group *group) {
MasterAttributes::WriteHDF5Exptime(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);