mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-14 08:17:13 +02:00
fixed master h5
This commit is contained in:
@ -48,35 +48,54 @@ class Hdf5MasterFile {
|
|||||||
std::string m_version;
|
std::string m_version;
|
||||||
DetectorType m_type;
|
DetectorType m_type;
|
||||||
TimingMode m_timing_mode;
|
TimingMode m_timing_mode;
|
||||||
|
xy m_geometry{};
|
||||||
size_t m_image_size_in_bytes{};
|
size_t m_image_size_in_bytes{};
|
||||||
size_t m_frames_in_file{};
|
|
||||||
size_t m_total_frames_expected{};
|
|
||||||
size_t m_pixels_y{};
|
size_t m_pixels_y{};
|
||||||
size_t m_pixels_x{};
|
size_t m_pixels_x{};
|
||||||
size_t m_bitdepth{};
|
|
||||||
|
|
||||||
xy m_geometry{};
|
|
||||||
|
|
||||||
size_t m_max_frames_per_file{};
|
size_t m_max_frames_per_file{};
|
||||||
uint32_t m_adc_mask{}; // TODO! implement reading
|
|
||||||
FrameDiscardPolicy m_frame_discard_policy{};
|
FrameDiscardPolicy m_frame_discard_policy{};
|
||||||
size_t m_frame_padding{};
|
size_t m_frame_padding{};
|
||||||
|
ScanParameters m_scan_parameters;
|
||||||
|
size_t m_total_frames_expected{};
|
||||||
|
// exptime
|
||||||
|
// period
|
||||||
|
// burst mode
|
||||||
|
// num udp interfaces
|
||||||
|
size_t m_bitdepth{};
|
||||||
|
// ten giga
|
||||||
|
// thresholdenergy
|
||||||
|
// thresholdall energy
|
||||||
|
// subexptime
|
||||||
|
// subperiod
|
||||||
|
std::optional<uint8_t> m_quad;
|
||||||
|
std::optional<size_t> m_number_of_rows;
|
||||||
|
// ratecorr
|
||||||
|
uint32_t m_adc_mask{}; // TODO! implement reading
|
||||||
|
uint8_t m_analog_flag{};
|
||||||
|
std::optional<size_t> m_analog_samples;
|
||||||
|
uint8_t m_digital_flag{};
|
||||||
|
std::optional<size_t> m_digital_samples;
|
||||||
|
// dbitoffset
|
||||||
|
// dbitlist
|
||||||
|
// transceiver mask
|
||||||
|
uint8_t m_transceiver_flag{};
|
||||||
|
std::optional<size_t> m_transceiver_samples;
|
||||||
|
// g1 roi
|
||||||
|
std::optional<ROI> m_roi;
|
||||||
|
// counter mask
|
||||||
|
// exptimearray
|
||||||
|
// gatedelay array
|
||||||
|
// gates
|
||||||
|
// additional json header
|
||||||
|
size_t m_frames_in_file{};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO! should these be bool?
|
// TODO! should these be bool?
|
||||||
uint8_t m_analog_flag{};
|
|
||||||
uint8_t m_digital_flag{};
|
|
||||||
uint8_t m_transceiver_flag{};
|
|
||||||
|
|
||||||
ScanParameters m_scan_parameters;
|
|
||||||
|
|
||||||
std::optional<size_t> m_analog_samples;
|
|
||||||
std::optional<size_t> m_digital_samples;
|
|
||||||
std::optional<size_t> m_transceiver_samples;
|
|
||||||
std::optional<size_t> m_number_of_rows;
|
|
||||||
std::optional<uint8_t> m_quad;
|
|
||||||
|
|
||||||
std::optional<ROI> m_roi;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Hdf5MasterFile(const std::filesystem::path &fpath);
|
Hdf5MasterFile(const std::filesystem::path &fpath);
|
||||||
@ -87,28 +106,48 @@ class Hdf5MasterFile {
|
|||||||
const std::string &version() const; //!< For example "7.2"
|
const std::string &version() const; //!< For example "7.2"
|
||||||
const DetectorType &detector_type() const;
|
const DetectorType &detector_type() const;
|
||||||
const TimingMode &timing_mode() const;
|
const TimingMode &timing_mode() const;
|
||||||
|
xy geometry() const;
|
||||||
size_t image_size_in_bytes() const;
|
size_t image_size_in_bytes() const;
|
||||||
size_t frames_in_file() const;
|
|
||||||
size_t pixels_y() const;
|
size_t pixels_y() const;
|
||||||
size_t pixels_x() const;
|
size_t pixels_x() const;
|
||||||
size_t max_frames_per_file() const;
|
size_t max_frames_per_file() const;
|
||||||
size_t bitdepth() const;
|
|
||||||
size_t frame_padding() const;
|
|
||||||
const FrameDiscardPolicy &frame_discard_policy() const;
|
const FrameDiscardPolicy &frame_discard_policy() const;
|
||||||
|
size_t frame_padding() const;
|
||||||
|
ScanParameters scan_parameters() const;
|
||||||
size_t total_frames_expected() const;
|
size_t total_frames_expected() const;
|
||||||
xy geometry() const;
|
// exptime
|
||||||
|
// period
|
||||||
|
// burst mode
|
||||||
|
// num udp interfaces
|
||||||
|
size_t bitdepth() const;
|
||||||
|
// ten giga
|
||||||
|
// thresholdenergy
|
||||||
|
// thresholdall energy
|
||||||
|
// subexptime
|
||||||
|
// subperiod
|
||||||
|
std::optional<uint8_t> quad() const;
|
||||||
|
std::optional<size_t> number_of_rows() const;
|
||||||
|
// ratecorr
|
||||||
|
std::optional<uint32_t> adc_mask() const; // TODO! implement reading
|
||||||
|
std::optional<uint8_t> analog_flag() const;
|
||||||
|
std::optional<size_t> analog_samples() const;
|
||||||
|
std::optional<uint8_t> digital_flag() const;
|
||||||
|
std::optional<size_t> digital_samples() const;
|
||||||
|
// dbitoffset
|
||||||
|
// dbitlist
|
||||||
|
// transceiver mask
|
||||||
|
std::optional<uint8_t> transceiver_flag() const;
|
||||||
|
std::optional<size_t> transceiver_samples() const;
|
||||||
|
// g1 roi
|
||||||
|
std::optional<ROI> roi() const;
|
||||||
|
// counter mask
|
||||||
|
// exptimearray
|
||||||
|
// gatedelay array
|
||||||
|
// gates
|
||||||
|
// additional json header
|
||||||
|
size_t frames_in_file() const;
|
||||||
size_t n_modules() const;
|
size_t n_modules() const;
|
||||||
|
|
||||||
std::optional<size_t> analog_samples() const;
|
|
||||||
std::optional<size_t> digital_samples() const;
|
|
||||||
std::optional<size_t> transceiver_samples() const;
|
|
||||||
std::optional<size_t> number_of_rows() const;
|
|
||||||
std::optional<uint8_t> quad() const;
|
|
||||||
|
|
||||||
std::optional<ROI> roi() const;
|
|
||||||
|
|
||||||
ScanParameters scan_parameters() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string metadata_group_name;
|
static const std::string metadata_group_name;
|
||||||
|
@ -294,6 +294,8 @@ enum class DetectorType {
|
|||||||
enum class TimingMode { Auto, Trigger };
|
enum class TimingMode { Auto, Trigger };
|
||||||
enum class FrameDiscardPolicy { NoDiscard, Discard, DiscardPartial };
|
enum class FrameDiscardPolicy { NoDiscard, Discard, DiscardPartial };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T> T StringTo(const std::string &arg) { return T(arg); }
|
template <class T> T StringTo(const std::string &arg) { return T(arg); }
|
||||||
|
|
||||||
template <class T> std::string ToString(T arg) { return T(arg); }
|
template <class T> std::string ToString(T arg) { return T(arg); }
|
||||||
@ -306,8 +308,11 @@ template <> std::string ToString(TimingMode arg);
|
|||||||
|
|
||||||
template <> FrameDiscardPolicy StringTo(const std::string & /*mode*/);
|
template <> FrameDiscardPolicy StringTo(const std::string & /*mode*/);
|
||||||
template <> std::string ToString(FrameDiscardPolicy arg);
|
template <> std::string ToString(FrameDiscardPolicy arg);
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const ScanParameters &r);
|
||||||
template <> std::string ToString(ScanParameters arg);
|
template <> std::string ToString(ScanParameters arg);
|
||||||
|
std::ostream &operator<<(std::ostream &os, const ROI &roi);
|
||||||
|
template <> std::string ToString(ROI arg);
|
||||||
|
|
||||||
using DataTypeVariants = std::variant<uint16_t, uint32_t>;
|
using DataTypeVariants = std::variant<uint16_t, uint32_t>;
|
||||||
|
|
||||||
|
@ -87,55 +87,69 @@ std::filesystem::path Hdf5MasterFile::data_fname(size_t mod_id,
|
|||||||
const std::string &Hdf5MasterFile::version() const { return m_version; }
|
const std::string &Hdf5MasterFile::version() const { return m_version; }
|
||||||
const DetectorType &Hdf5MasterFile::detector_type() const { return m_type; }
|
const DetectorType &Hdf5MasterFile::detector_type() const { return m_type; }
|
||||||
const TimingMode &Hdf5MasterFile::timing_mode() const { return m_timing_mode; }
|
const TimingMode &Hdf5MasterFile::timing_mode() const { return m_timing_mode; }
|
||||||
|
xy Hdf5MasterFile::geometry() const { return m_geometry; }
|
||||||
size_t Hdf5MasterFile::image_size_in_bytes() const {
|
size_t Hdf5MasterFile::image_size_in_bytes() const {
|
||||||
return m_image_size_in_bytes;
|
return m_image_size_in_bytes;
|
||||||
}
|
}
|
||||||
size_t Hdf5MasterFile::frames_in_file() const { return m_frames_in_file; }
|
|
||||||
size_t Hdf5MasterFile::pixels_y() const { return m_pixels_y; }
|
size_t Hdf5MasterFile::pixels_y() const { return m_pixels_y; }
|
||||||
size_t Hdf5MasterFile::pixels_x() const { return m_pixels_x; }
|
size_t Hdf5MasterFile::pixels_x() const { return m_pixels_x; }
|
||||||
size_t Hdf5MasterFile::max_frames_per_file() const {
|
size_t Hdf5MasterFile::max_frames_per_file() const {
|
||||||
return m_max_frames_per_file;
|
return m_max_frames_per_file;
|
||||||
}
|
}
|
||||||
size_t Hdf5MasterFile::bitdepth() const { return m_bitdepth; }
|
|
||||||
size_t Hdf5MasterFile::frame_padding() const { return m_frame_padding; }
|
|
||||||
const FrameDiscardPolicy &Hdf5MasterFile::frame_discard_policy() const {
|
const FrameDiscardPolicy &Hdf5MasterFile::frame_discard_policy() const {
|
||||||
return m_frame_discard_policy;
|
return m_frame_discard_policy;
|
||||||
}
|
}
|
||||||
|
size_t Hdf5MasterFile::frame_padding() const { return m_frame_padding; }
|
||||||
|
ScanParameters Hdf5MasterFile::scan_parameters() const {
|
||||||
|
return m_scan_parameters;
|
||||||
|
}
|
||||||
size_t Hdf5MasterFile::total_frames_expected() const {
|
size_t Hdf5MasterFile::total_frames_expected() const {
|
||||||
return m_total_frames_expected;
|
return m_total_frames_expected;
|
||||||
}
|
}
|
||||||
|
// exptime
|
||||||
xy Hdf5MasterFile::geometry() const { return m_geometry; }
|
// period
|
||||||
|
// burst mode
|
||||||
|
// num udp interfaces
|
||||||
|
size_t Hdf5MasterFile::bitdepth() const { return m_bitdepth; }
|
||||||
|
// ten giga
|
||||||
|
// thresholdenergy
|
||||||
|
// thresholdall energy
|
||||||
|
// subexptime
|
||||||
|
// subperiod
|
||||||
|
std::optional<uint8_t> Hdf5MasterFile::quad() const { return m_quad; }
|
||||||
|
std::optional<size_t> Hdf5MasterFile::number_of_rows() const {
|
||||||
|
return m_number_of_rows;
|
||||||
|
}
|
||||||
|
std::optional<uint32_t> Hdf5MasterFile::adc_mask() const { return m_adc_mask;}
|
||||||
|
std::optional<uint8_t> Hdf5MasterFile::analog_flag() const { return m_analog_flag; }
|
||||||
|
std::optional<size_t> Hdf5MasterFile::analog_samples() const {
|
||||||
|
return m_analog_samples;
|
||||||
|
}
|
||||||
|
std::optional<uint8_t> Hdf5MasterFile::digital_flag() const { return m_digital_flag; }
|
||||||
|
std::optional<size_t> Hdf5MasterFile::digital_samples() const {
|
||||||
|
return m_digital_samples;
|
||||||
|
}
|
||||||
|
// dbitoffset
|
||||||
|
// dbitlist
|
||||||
|
// transceiver mask
|
||||||
|
std::optional<uint8_t> Hdf5MasterFile::transceiver_flag() const { return m_transceiver_flag; }
|
||||||
|
std::optional<size_t> Hdf5MasterFile::transceiver_samples() const {
|
||||||
|
return m_transceiver_samples;
|
||||||
|
}
|
||||||
|
// g1 roi
|
||||||
|
std::optional<ROI> Hdf5MasterFile::roi() const { return m_roi; }
|
||||||
|
// counter mask
|
||||||
|
// exptimearray
|
||||||
|
// gatedelay array
|
||||||
|
// gates
|
||||||
|
// additional json header
|
||||||
|
size_t Hdf5MasterFile::frames_in_file() const { return m_frames_in_file; }
|
||||||
size_t Hdf5MasterFile::n_modules() const {
|
size_t Hdf5MasterFile::n_modules() const {
|
||||||
return m_geometry.row * m_geometry.col;
|
return m_geometry.row * m_geometry.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional values, these may or may not be present in the master file
|
// optional values, these may or may not be present in the master file
|
||||||
// and are therefore modeled as std::optional
|
// and are therefore modeled as std::optional
|
||||||
std::optional<size_t> Hdf5MasterFile::analog_samples() const {
|
|
||||||
return m_analog_samples;
|
|
||||||
}
|
|
||||||
std::optional<size_t> Hdf5MasterFile::digital_samples() const {
|
|
||||||
return m_digital_samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<size_t> Hdf5MasterFile::transceiver_samples() const {
|
|
||||||
return m_transceiver_samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<size_t> Hdf5MasterFile::number_of_rows() const {
|
|
||||||
return m_number_of_rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<uint8_t> Hdf5MasterFile::quad() const { return m_quad; }
|
|
||||||
|
|
||||||
std::optional<ROI> Hdf5MasterFile::roi() const { return m_roi; }
|
|
||||||
|
|
||||||
ScanParameters Hdf5MasterFile::scan_parameters() const {
|
|
||||||
return m_scan_parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string Hdf5MasterFile::metadata_group_name =
|
const std::string Hdf5MasterFile::metadata_group_name =
|
||||||
"/entry/instrument/detector/";
|
"/entry/instrument/detector/";
|
||||||
@ -204,31 +218,65 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
file, std::string(metadata_group_name + "Geometry in x axis"));
|
file, std::string(metadata_group_name + "Geometry in x axis"));
|
||||||
LOG(logDEBUG) << "Geometry: " << m_geometry.to_string();
|
LOG(logDEBUG) << "Geometry: " << m_geometry.to_string();
|
||||||
|
|
||||||
|
|
||||||
// Image Size
|
// Image Size
|
||||||
m_image_size_in_bytes = h5_get_scalar_dataset<int>(
|
m_image_size_in_bytes = h5_get_scalar_dataset<int>(
|
||||||
file, std::string(metadata_group_name + "Image Size"));
|
file, std::string(metadata_group_name + "Image Size"));
|
||||||
LOG(logDEBUG) << "Image size: {}\n" << m_image_size_in_bytes;
|
LOG(logDEBUG) << "Image size: {}\n" << m_image_size_in_bytes;
|
||||||
|
|
||||||
// Frames in File
|
// Pixels y
|
||||||
m_frames_in_file = h5_get_scalar_dataset<uint64_t>(
|
|
||||||
file, std::string(metadata_group_name + "Frames in File"));
|
|
||||||
LOG(logDEBUG) << "Frames in File: " << m_frames_in_file;
|
|
||||||
|
|
||||||
// Pixels
|
|
||||||
m_pixels_y = h5_get_scalar_dataset<int>(
|
m_pixels_y = h5_get_scalar_dataset<int>(
|
||||||
file,
|
file,
|
||||||
std::string(metadata_group_name + "Number of pixels in y axis"));
|
std::string(metadata_group_name + "Number of pixels in y axis"));
|
||||||
LOG(logDEBUG) << "Pixels in y: " << m_pixels_y;
|
LOG(logDEBUG) << "Pixels in y: " << m_pixels_y;
|
||||||
|
|
||||||
|
// Pixels x
|
||||||
m_pixels_x = h5_get_scalar_dataset<int>(
|
m_pixels_x = h5_get_scalar_dataset<int>(
|
||||||
file,
|
file,
|
||||||
std::string(metadata_group_name + "Number of pixels in x axis"));
|
std::string(metadata_group_name + "Number of pixels in x axis"));
|
||||||
LOG(logDEBUG) << "Pixels in x: " << m_pixels_x;
|
LOG(logDEBUG) << "Pixels in x: " << m_pixels_x;
|
||||||
|
|
||||||
// Max Frames per File
|
// Image Size in Bytes
|
||||||
m_max_frames_per_file = h5_get_scalar_dataset<int>(
|
m_max_frames_per_file = h5_get_scalar_dataset<int>(
|
||||||
file, std::string(metadata_group_name + "Maximum frames per file"));
|
file, std::string(metadata_group_name + "Maximum frames per file"));
|
||||||
LOG(logDEBUG) << "Max frames per File: " << m_max_frames_per_file;
|
LOG(logDEBUG) << "Max frames per File: " << m_max_frames_per_file;
|
||||||
|
|
||||||
|
// Frame Discard Policy
|
||||||
|
m_frame_discard_policy =
|
||||||
|
StringTo<FrameDiscardPolicy>(h5_get_scalar_dataset<std::string>(
|
||||||
|
file,
|
||||||
|
std::string(metadata_group_name + "Frame Discard Policy")));
|
||||||
|
LOG(logDEBUG) << "Frame Discard Policy: " << ToString(m_frame_discard_policy);
|
||||||
|
|
||||||
|
// Frame Padding
|
||||||
|
m_frame_padding = h5_get_scalar_dataset<int>(
|
||||||
|
file, std::string(metadata_group_name + "Frame Padding"));
|
||||||
|
LOG(logDEBUG) << "Frame Padding: " << m_frame_padding;
|
||||||
|
|
||||||
|
|
||||||
|
// Scan Parameters
|
||||||
|
try {
|
||||||
|
std::string scan_parameters = h5_get_scalar_dataset<std::string>(
|
||||||
|
file, std::string(metadata_group_name + "Scan Parameters"));
|
||||||
|
m_scan_parameters = ScanParameters(scan_parameters);
|
||||||
|
if (dVersion < 6.61){
|
||||||
|
m_scan_parameters.increment_stop(); //adjust for endpoint being included
|
||||||
|
}
|
||||||
|
} catch (H5::FileIException &e) {
|
||||||
|
// keep the optional empty
|
||||||
|
}
|
||||||
|
LOG(logDEBUG) << "Scan Parameters: " << ToString(m_scan_parameters);
|
||||||
|
|
||||||
|
// Total Frames Expected
|
||||||
|
m_total_frames_expected = h5_get_scalar_dataset<uint64_t>(
|
||||||
|
file, std::string(metadata_group_name + "Total Frames"));
|
||||||
|
LOG(logDEBUG) << "Total Frames: " << m_total_frames_expected;
|
||||||
|
|
||||||
|
// exptime
|
||||||
|
// period
|
||||||
|
// burst mode
|
||||||
|
// num udp interfaces
|
||||||
|
|
||||||
// Bit Depth
|
// Bit Depth
|
||||||
// Not all detectors write the bitdepth but in case
|
// Not all detectors write the bitdepth but in case
|
||||||
// its not there it is 16
|
// its not there it is 16
|
||||||
@ -240,27 +288,27 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
m_bitdepth = 16;
|
m_bitdepth = 16;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Bit Depth: " << m_bitdepth;
|
LOG(logDEBUG) << "Bit Depth: " << m_bitdepth;
|
||||||
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2), stderr);
|
||||||
|
|
||||||
|
// ten giga
|
||||||
|
// thresholdenergy
|
||||||
|
// thresholdall energy
|
||||||
|
// subexptime
|
||||||
|
// subperiod
|
||||||
|
|
||||||
|
// Quad
|
||||||
|
H5::Exception::dontPrint();
|
||||||
|
try {
|
||||||
|
m_quad = h5_get_scalar_dataset<int>(
|
||||||
|
file, std::string(metadata_group_name + "Quad"));
|
||||||
|
} catch (H5::FileIException &e) {
|
||||||
|
// keep the optional empty
|
||||||
|
}
|
||||||
|
LOG(logDEBUG) << "Quad: " << m_quad;
|
||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||||
stderr);
|
stderr);
|
||||||
|
|
||||||
// Total Frames
|
// Number of Rows
|
||||||
m_total_frames_expected = h5_get_scalar_dataset<uint64_t>(
|
|
||||||
file, std::string(metadata_group_name + "Total Frames"));
|
|
||||||
LOG(logDEBUG) << "Total Frames: " << m_total_frames_expected;
|
|
||||||
|
|
||||||
// Frame Padding
|
|
||||||
m_frame_padding = h5_get_scalar_dataset<int>(
|
|
||||||
file, std::string(metadata_group_name + "Frame Padding"));
|
|
||||||
LOG(logDEBUG) << "Frame Padding: " << m_frame_padding;
|
|
||||||
|
|
||||||
// Frame Discard Policy
|
|
||||||
m_frame_discard_policy =
|
|
||||||
StringTo<FrameDiscardPolicy>(h5_get_scalar_dataset<std::string>(
|
|
||||||
file,
|
|
||||||
std::string(metadata_group_name + "Frame Discard Policy")));
|
|
||||||
LOG(logDEBUG) << "Frame Discard Policy: " << ToString(m_frame_discard_policy);
|
|
||||||
|
|
||||||
// Number of rows
|
|
||||||
// Not all detectors write the Number of rows but in case
|
// Not all detectors write the Number of rows but in case
|
||||||
H5::Exception::dontPrint();
|
H5::Exception::dontPrint();
|
||||||
try {
|
try {
|
||||||
@ -273,6 +321,20 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||||
stderr);
|
stderr);
|
||||||
|
|
||||||
|
// ratecorr
|
||||||
|
|
||||||
|
// ADC Mask
|
||||||
|
H5::Exception::dontPrint();
|
||||||
|
try {
|
||||||
|
m_adc_mask = h5_get_scalar_dataset<int>(
|
||||||
|
file, std::string(metadata_group_name + "ADC Mask"));
|
||||||
|
} catch (H5::FileIException &e) {
|
||||||
|
m_adc_mask = 0;
|
||||||
|
}
|
||||||
|
LOG(logDEBUG) << "ADC Mask: " << m_adc_mask;
|
||||||
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||||
|
stderr);
|
||||||
|
|
||||||
// Analog Flag
|
// Analog Flag
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
// Special treatment of analog flag because of Moench03
|
// Special treatment of analog flag because of Moench03
|
||||||
@ -306,32 +368,6 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
LOG(logDEBUG) << "Analog Samples: " << m_analog_samples;
|
LOG(logDEBUG) << "Analog Samples: " << m_analog_samples;
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
|
|
||||||
// Quad
|
|
||||||
H5::Exception::dontPrint();
|
|
||||||
try {
|
|
||||||
m_quad = h5_get_scalar_dataset<int>(
|
|
||||||
file, std::string(metadata_group_name + "Quad"));
|
|
||||||
} catch (H5::FileIException &e) {
|
|
||||||
// keep the optional empty
|
|
||||||
}
|
|
||||||
LOG(logDEBUG) << "Quad: " << m_quad;
|
|
||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
|
||||||
stderr);
|
|
||||||
|
|
||||||
// ADC Mask
|
|
||||||
H5::Exception::dontPrint();
|
|
||||||
try {
|
|
||||||
m_adc_mask = h5_get_scalar_dataset<int>(
|
|
||||||
file, std::string(metadata_group_name + "ADC
|
|
||||||
Mask"));
|
|
||||||
} catch (H5::FileIException &e) {
|
|
||||||
m_adc_mask = 0;
|
|
||||||
}
|
|
||||||
LOG(logDEBUG) << "ADC Mask: " << m_adc_mask;
|
|
||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
|
||||||
stderr);
|
|
||||||
|
|
||||||
|
|
||||||
// Digital Flag, Digital Samples
|
// Digital Flag, Digital Samples
|
||||||
H5::Exception::dontPrint();
|
H5::Exception::dontPrint();
|
||||||
try {
|
try {
|
||||||
@ -349,6 +385,10 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||||
stderr);
|
stderr);
|
||||||
|
|
||||||
|
// dbitoffset
|
||||||
|
// dbitlist
|
||||||
|
// transceiver mask
|
||||||
|
|
||||||
// Transceiver Flag, Transceiver Samples
|
// Transceiver Flag, Transceiver Samples
|
||||||
H5::Exception::dontPrint();
|
H5::Exception::dontPrint();
|
||||||
try {
|
try {
|
||||||
@ -363,16 +403,16 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
// keep the optional empty
|
// keep the optional empty
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Transceiver Flag: " << m_transceiver_flag;
|
LOG(logDEBUG) << "Transceiver Flag: " << m_transceiver_flag;
|
||||||
LOG(logDEBUG) << "Transceiver Samples: ",m_transceiver_samples;
|
LOG(logDEBUG) << "Transceiver Samples: " << m_transceiver_samples;
|
||||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||||
stderr);
|
stderr);
|
||||||
|
|
||||||
// scan parameters
|
// ROI
|
||||||
try {
|
try {
|
||||||
std::string scan_parameters = h5_get_scalar_dataset<std::string>(
|
std::string scan_parameters = h5_get_scalar_dataset<std::string>(
|
||||||
file, std::string(metadata_group_name + "Scan Parameters"));
|
file, std::string(metadata_group_name + "Scan Parameters"));
|
||||||
m_scan_parameters = ScanParameters(scan_parameters);
|
m_scan_parameters = ScanParameters(scan_parameters);
|
||||||
if (dVersion < 7.21){
|
if (dVersion < 6.61){
|
||||||
m_scan_parameters.increment_stop(); //adjust for endpoint being included
|
m_scan_parameters.increment_stop(); //adjust for endpoint being included
|
||||||
}
|
}
|
||||||
} catch (H5::FileIException &e) {
|
} catch (H5::FileIException &e) {
|
||||||
@ -380,35 +420,37 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Scan Parameters: " << ToString(m_scan_parameters);
|
LOG(logDEBUG) << "Scan Parameters: " << ToString(m_scan_parameters);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ROI tmp_roi;
|
ROI tmp_roi;
|
||||||
auto obj = j.at("Receiver Roi");
|
tmp_roi.xmin = h5_get_scalar_dataset<int>(
|
||||||
tmp_roi.xmin = obj.at("xmin");
|
file, std::string(metadata_group_name + "receiver roi xmin"));
|
||||||
tmp_roi.xmax = obj.at("xmax");
|
tmp_roi.xmax = h5_get_scalar_dataset<int>(
|
||||||
tmp_roi.ymin = obj.at("ymin");
|
file, std::string(metadata_group_name + "receiver roi xmax"));
|
||||||
tmp_roi.ymax = obj.at("ymax");
|
tmp_roi.ymin = h5_get_scalar_dataset<int>(
|
||||||
|
file, std::string(metadata_group_name + "receiver roi ymin"));
|
||||||
|
tmp_roi.ymax = h5_get_scalar_dataset<int>(
|
||||||
|
file, std::string(metadata_group_name + "receiver roi ymax"));
|
||||||
|
|
||||||
//if any of the values are set update the roi
|
//if any of the values are set update the roi
|
||||||
if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295
|
if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295 || tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) {
|
||||||
|| tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) {
|
//why?? TODO
|
||||||
|
if(dVersion < 6.61){
|
||||||
if(v<7.21){
|
tmp_roi.xmax++;
|
||||||
tmp_roi.xmax++;
|
tmp_roi.ymax++;
|
||||||
tmp_roi.ymax++;
|
}
|
||||||
|
m_roi = tmp_roi;
|
||||||
}
|
}
|
||||||
|
} catch (H5::FileIException &e) {
|
||||||
m_roi = tmp_roi;
|
// keep the optional empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not Done TODO
|
||||||
|
//if we have an roi we need to update the geometry for the subfiles
|
||||||
|
if (m_roi){
|
||||||
|
|
||||||
}catch (const json::out_of_range &e) {
|
}
|
||||||
// leave the optional empty
|
LOG(logDEBUG) << "ROI: " << m_roi;
|
||||||
}
|
|
||||||
//if we have an roi we need to update the geometry for the
|
|
||||||
subfiles if (m_roi){
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Update detector type for Moench
|
// Update detector type for Moench
|
||||||
// TODO! How does this work with old .h5 master files?
|
// TODO! How does this work with old .h5 master files?
|
||||||
@ -425,7 +467,17 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
|||||||
m_type = DetectorType::Moench03_old;
|
m_type = DetectorType::Moench03_old;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
// counter mask
|
||||||
|
// exptimearray
|
||||||
|
// gatedelay array
|
||||||
|
// gates
|
||||||
|
// additional json header
|
||||||
|
|
||||||
|
// Frames in File
|
||||||
|
m_frames_in_file = h5_get_scalar_dataset<uint64_t>(
|
||||||
|
file, std::string(metadata_group_name + "Frames in File"));
|
||||||
|
LOG(logDEBUG) << "Frames in File: " << m_frames_in_file;
|
||||||
|
|
||||||
|
|
||||||
} catch (const H5::Exception &e) {
|
} catch (const H5::Exception &e) {
|
||||||
fmt::print("Exception type: {}\n", typeid(e).name());
|
fmt::print("Exception type: {}\n", typeid(e).name());
|
||||||
|
38
src/defs.cpp
38
src/defs.cpp
@ -162,14 +162,14 @@ template <> FrameDiscardPolicy StringTo(const std::string &arg) {
|
|||||||
template <> std::string ToString(ScanParameters arg) {
|
template <> std::string ToString(ScanParameters arg) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << '[';
|
oss << '[';
|
||||||
if (arg.enable) {
|
if (arg.enabled()) {
|
||||||
oss << "enabled" << std::endl
|
oss << "enabled" << std::endl
|
||||||
<< "dac " << ToString(arg.dacInd) << std::endl
|
<< "dac " << arg.dac() << std::endl
|
||||||
<< "start " << arg.startOffset << std::endl
|
<< "start " << arg.start() << std::endl
|
||||||
<< "stop " << arg.stopOffset << std::endl
|
<< "stop " << arg.stop() << std::endl
|
||||||
<< "step " << arg.stepSize << std::endl
|
<< "step " << arg.step() << std::endl
|
||||||
<< "settleTime "
|
//<< "settleTime "
|
||||||
<< ToString(std::chrono::nanoseconds{arg.dacSettleTime_ns})
|
// << ToString(std::chrono::nanoseconds{arg.dacSettleTime_ns})
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
} else {
|
} else {
|
||||||
oss << "disabled";
|
oss << "disabled";
|
||||||
@ -178,6 +178,30 @@ template <> std::string ToString(ScanParameters arg) {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const ScanParameters &r) {
|
||||||
|
return os << ToString(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert a ROI to a string
|
||||||
|
* @param type ROI
|
||||||
|
* @return string representation of the ROI
|
||||||
|
*/
|
||||||
|
template <> std::string ToString(ROI arg) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << '[' << arg.xmin << ", " << arg.xmax;
|
||||||
|
if (arg.ymin != -1 || arg.ymax != -1) {
|
||||||
|
oss << ", " << arg.ymin << ", " << arg.ymax;
|
||||||
|
}
|
||||||
|
oss << ']';
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &os, const ROI &roi) {
|
||||||
|
return os << ToString(roi);
|
||||||
|
}
|
||||||
|
|
||||||
// template <> TimingMode StringTo<TimingMode>(std::string mode);
|
// template <> TimingMode StringTo<TimingMode>(std::string mode);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user