mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-13 15:57:14 +02:00
added all the parameters
This commit is contained in:
@ -90,6 +90,8 @@ class H5Handles {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename Fn>
|
||||
void read_hdf5_header_fields(DetectorHeader *header, Fn &&fn_read_field) {
|
||||
fn_read_field(0, reinterpret_cast<std::byte *>(&(header->frameNumber)));
|
||||
@ -124,8 +126,8 @@ class Hdf5File : public FileInterface {
|
||||
|
||||
static const std::string metadata_group_name;
|
||||
static const std::vector<std::string> header_dataset_names;
|
||||
std::unique_ptr<H5Handles> m_data_file{nullptr};
|
||||
std::vector<std::unique_ptr<H5Handles>> m_header_files;
|
||||
std::unique_ptr<H5Handles> m_data_dataset{nullptr};
|
||||
std::vector<std::unique_ptr<H5Handles>> m_header_datasets{};
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -52,43 +52,43 @@ class Hdf5MasterFile {
|
||||
DetectorType m_type;
|
||||
TimingMode m_timing_mode;
|
||||
xy m_geometry{};
|
||||
size_t m_image_size_in_bytes{};
|
||||
size_t m_pixels_y{};
|
||||
size_t m_pixels_x{};
|
||||
size_t m_max_frames_per_file{};
|
||||
int m_image_size_in_bytes{};
|
||||
int m_pixels_y{};
|
||||
int m_pixels_x{};
|
||||
int m_max_frames_per_file{};
|
||||
FrameDiscardPolicy m_frame_discard_policy{};
|
||||
size_t m_frame_padding{};
|
||||
int m_frame_padding{};
|
||||
std::optional<ScanParameters> m_scan_parameters{};
|
||||
size_t m_total_frames_expected{};
|
||||
std::optional<ns> m_exptime{};
|
||||
std::optional<ns> m_period{};
|
||||
std::optional<BurstMode> m_burst_mode{};
|
||||
std::optional<size_t> m_number_of_udp_interfaces{};
|
||||
size_t m_bitdepth{};
|
||||
std::optional<size_t> m_ten_giga{};
|
||||
std::optional<size_t> m_threshold_energy{};
|
||||
std::optional<std::vector<size_t>> m_threshold_energy_all{};
|
||||
std::optional<int> m_number_of_udp_interfaces{};
|
||||
int m_bitdepth{};
|
||||
std::optional<bool> m_ten_giga{};
|
||||
std::optional<int> m_threshold_energy{};
|
||||
std::optional<std::vector<int>> m_threshold_energy_all{};
|
||||
std::optional<ns> m_subexptime{};
|
||||
std::optional<ns> m_subperiod{};
|
||||
std::optional<uint8_t> m_quad{};
|
||||
std::optional<size_t> m_number_of_rows{};
|
||||
std::optional<bool> m_quad{};
|
||||
std::optional<int> m_number_of_rows{};
|
||||
std::optional<std::vector<size_t>> m_rate_corrections{};
|
||||
size_t m_adc_mask{};
|
||||
uint8_t m_analog_flag{};
|
||||
std::optional<size_t> m_analog_samples{};
|
||||
uint8_t m_digital_flag{};
|
||||
std::optional<size_t> m_digital_samples{};
|
||||
std::optional<size_t> m_dbit_offset{};
|
||||
uint32_t m_adc_mask{};
|
||||
bool m_analog_flag{};
|
||||
std::optional<int> m_analog_samples{};
|
||||
bool m_digital_flag{};
|
||||
std::optional<int> m_digital_samples{};
|
||||
std::optional<int> m_dbit_offset{};
|
||||
std::optional<size_t> m_dbit_list{};
|
||||
std::optional<size_t> m_transceiver_mask{};
|
||||
uint8_t m_transceiver_flag{};
|
||||
std::optional<size_t> m_transceiver_samples{};
|
||||
// g1 roi
|
||||
std::optional<int> m_transceiver_mask{};
|
||||
bool m_transceiver_flag{};
|
||||
std::optional<int> m_transceiver_samples{};
|
||||
// g1 roi - will not be implemented?
|
||||
std::optional<ROI> m_roi{};
|
||||
std::optional<size_t> m_counter_mask{};
|
||||
// exptimearray
|
||||
// gatedelay array
|
||||
std::optional<size_t> m_gates{};
|
||||
std::optional<int> m_counter_mask{};
|
||||
std::optional<std::vector<ns>> m_exptime_array{};
|
||||
std::optional<std::vector<ns>> m_gate_delay_array{};
|
||||
std::optional<int> m_gates{};
|
||||
std::optional<std::map<std::string, std::string>> m_additional_json_header{};
|
||||
size_t m_frames_in_file{};
|
||||
|
||||
@ -110,43 +110,43 @@ class Hdf5MasterFile {
|
||||
const DetectorType &detector_type() const;
|
||||
const TimingMode &timing_mode() const;
|
||||
xy geometry() const;
|
||||
size_t image_size_in_bytes() const;
|
||||
size_t pixels_y() const;
|
||||
size_t pixels_x() const;
|
||||
size_t max_frames_per_file() const;
|
||||
int image_size_in_bytes() const;
|
||||
int pixels_y() const;
|
||||
int pixels_x() const;
|
||||
int max_frames_per_file() const;
|
||||
const FrameDiscardPolicy &frame_discard_policy() const;
|
||||
size_t frame_padding() const;
|
||||
int frame_padding() const;
|
||||
std::optional<ScanParameters> scan_parameters() const;
|
||||
size_t total_frames_expected() const;
|
||||
std::optional<ns> exptime() const;
|
||||
std::optional<ns> period() const;
|
||||
std::optional<BurstMode> burst_mode() const;
|
||||
std::optional<size_t> number_of_udp_interfaces() const;
|
||||
size_t bitdepth() const;
|
||||
std::optional<size_t> ten_giga() const;
|
||||
std::optional<size_t> threshold_energy() const;
|
||||
std::optional<std::vector<size_t>> threshold_energy_all() const;
|
||||
std::optional<int> number_of_udp_interfaces() const;
|
||||
int bitdepth() const;
|
||||
std::optional<bool> ten_giga() const;
|
||||
std::optional<int> threshold_energy() const;
|
||||
std::optional<std::vector<int>> threshold_energy_all() const;
|
||||
std::optional<ns> subexptime() const;
|
||||
std::optional<ns> subperiod() const;
|
||||
std::optional<uint8_t> quad() const;
|
||||
std::optional<size_t> number_of_rows() const;
|
||||
std::optional<bool> quad() const;
|
||||
std::optional<int> number_of_rows() const;
|
||||
std::optional<std::vector<size_t>> rate_corrections() const;
|
||||
std::optional<size_t> adc_mask() const;
|
||||
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;
|
||||
std::optional<size_t> dbit_offset() const;
|
||||
std::optional<uint32_t> adc_mask() const;
|
||||
bool analog_flag() const;
|
||||
std::optional<int> analog_samples() const;
|
||||
bool digital_flag() const;
|
||||
std::optional<int> digital_samples() const;
|
||||
std::optional<int> dbit_offset() const;
|
||||
std::optional<size_t> dbit_list() const;
|
||||
std::optional<size_t> transceiver_mask() const;
|
||||
std::optional<uint8_t> transceiver_flag() const;
|
||||
std::optional<size_t> transceiver_samples() const;
|
||||
// g1 roi
|
||||
std::optional<int> transceiver_mask() const;
|
||||
bool transceiver_flag() const;
|
||||
std::optional<int> transceiver_samples() const;
|
||||
// g1 roi - will not be implemented?
|
||||
std::optional<ROI> roi() const;
|
||||
std::optional<size_t> counter_mask() const;
|
||||
// exptimearray
|
||||
// gatedelay array
|
||||
std::optional<size_t> gates() const;
|
||||
std::optional<int> counter_mask() const;
|
||||
std::optional<std::vector<ns>> exptime_array() const;
|
||||
std::optional<std::vector<ns>> gate_delay_array() const;
|
||||
std::optional<int> gates() const;
|
||||
std::optional<std::map<std::string, std::string>> additional_json_header() const;
|
||||
size_t frames_in_file() const;
|
||||
size_t n_modules() const;
|
||||
|
@ -307,102 +307,19 @@ enum class BurstMode { Burst_Interal, Burst_External, Continuous_Internal,
|
||||
template <class T, typename = std::enable_if_t<!is_duration<T>::value>>
|
||||
std::string ToString(T arg) { return T(arg); }
|
||||
|
||||
template <typename T, std::enable_if_t<!is_duration<T>::value, int> = 0 >
|
||||
template <typename T, std::enable_if_t<
|
||||
!is_duration<T>::value && !is_container<T>::value, int> = 0 >
|
||||
T StringTo(const std::string &arg) { return T(arg); }
|
||||
|
||||
|
||||
// so that StringTo<std::vector<size_t>> below doesnt complain about the above
|
||||
// generic overload
|
||||
template <> inline size_t StringTo(const std::string &arg) {
|
||||
return std::stoi(arg);
|
||||
}
|
||||
|
||||
|
||||
// vector
|
||||
template <typename T> std::string ToString(const std::vector<T> &vec) {
|
||||
std::ostringstream oss;
|
||||
oss << "[";
|
||||
for (size_t i = 0; i < vec.size(); ++i) {
|
||||
oss << vec[i];
|
||||
if (i != vec.size() - 1)
|
||||
oss << ", ";
|
||||
}
|
||||
oss << "]";
|
||||
return oss.str();
|
||||
}
|
||||
template <> inline std::vector<size_t> StringTo(const std::string &s) {
|
||||
std::vector<size_t> result;
|
||||
std::string str = s;
|
||||
// Remove brackets and spaces
|
||||
str.erase(std::remove_if(str.begin(), str.end(),
|
||||
[](unsigned char c) {
|
||||
return c == '[' || c == ']' || std::isspace(c);
|
||||
}),
|
||||
str.end());
|
||||
std::stringstream ss(str);
|
||||
std::string item;
|
||||
while (std::getline(ss, item, ',')) {
|
||||
if (!item.empty())
|
||||
result.push_back(StringTo<size_t>(item));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// map
|
||||
template <typename KeyType, typename ValueType>
|
||||
std::string ToString(const std::map<KeyType, ValueType> &m) {
|
||||
std::ostringstream os;
|
||||
os << '{';
|
||||
if (!m.empty()) {
|
||||
auto it = m.cbegin();
|
||||
os << ToString(it->first) << ": " << ToString(it->second);
|
||||
it++;
|
||||
while (it != m.cend()) {
|
||||
os << ", " << ToString(it->first) << ": " << ToString(it->second);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
os << '}';
|
||||
return os.str();
|
||||
}
|
||||
template <> inline std::map<std::string, std::string> StringTo(const std::string &s) {
|
||||
std::map<std::string, std::string> result;
|
||||
std::string str = s;
|
||||
|
||||
// Remove outer braces if present
|
||||
if (!str.empty() && str.front() == '{' && str.back() == '}') {
|
||||
str = str.substr(1, str.size() - 2);
|
||||
}
|
||||
|
||||
std::stringstream ss(str);
|
||||
std::string item;
|
||||
|
||||
auto trim = [](std::string& t) {
|
||||
// trim leading white spaces
|
||||
t.erase(t.begin(), std::find_if(t.begin(), t.end(), [](unsigned char c){ return !std::isspace(c); }));
|
||||
// trim trailing white spaces
|
||||
t.erase(std::find_if(t.rbegin(), t.rend(), [](unsigned char c){ return !std::isspace(c); }).base(), t.end());
|
||||
};
|
||||
|
||||
while (std::getline(ss, item, ',')) {
|
||||
auto colon_pos = item.find(':');
|
||||
if (colon_pos == std::string::npos)
|
||||
throw std::runtime_error("Missing ':' in item: " + item);
|
||||
|
||||
std::string key = item.substr(0, colon_pos);
|
||||
std::string value = item.substr(colon_pos + 1);
|
||||
|
||||
trim(key);
|
||||
trim(value);
|
||||
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// time
|
||||
std::string RemoveUnit(std::string &str);
|
||||
inline void TrimWhiteSpaces(std::string& s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||
[](unsigned char c) { return !std::isspace(c); }));
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
[](unsigned char c) { return !std::isspace(c); }).base(),
|
||||
s.end());
|
||||
}
|
||||
|
||||
/** Convert std::chrono::duration with specified output unit */
|
||||
template <typename T, typename Rep = double>
|
||||
@ -445,6 +362,11 @@ ToString(From t) {
|
||||
return ToString(tns, "s");
|
||||
}
|
||||
}
|
||||
template <class Rep, class Period>
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const std::chrono::duration<Rep, Period>& d) {
|
||||
return os << ToString(d);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T StringTo(const std::string &t, const std::string &unit) {
|
||||
@ -477,10 +399,160 @@ T StringTo(const std::string &t) {
|
||||
return StringTo<T>(tmp, unit);
|
||||
}
|
||||
|
||||
template <> inline bool StringTo(const std::string &s) {
|
||||
int i = std::stoi(s, nullptr, 10);
|
||||
switch (i) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
return true;
|
||||
default:
|
||||
throw std::runtime_error("Unknown boolean. Expecting be 0 or 1.");
|
||||
}
|
||||
}
|
||||
|
||||
template <> inline uint8_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
int value = std::stoi(s, nullptr, base);
|
||||
if (value < std::numeric_limits<uint8_t>::min() ||
|
||||
value > std::numeric_limits<uint8_t>::max()) {
|
||||
throw std::runtime_error("Cannot scan uint8_t from string '" + s +
|
||||
"'. Value must be in range 0 - 255.");
|
||||
}
|
||||
return static_cast<uint8_t>(value);
|
||||
}
|
||||
|
||||
template <> inline uint16_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
int value = std::stoi(s, nullptr, base);
|
||||
if (value < std::numeric_limits<uint16_t>::min() ||
|
||||
value > std::numeric_limits<uint16_t>::max()) {
|
||||
throw std::runtime_error("Cannot scan uint16_t from string '" + s +
|
||||
"'. Value must be in range 0 - 65535.");
|
||||
}
|
||||
return static_cast<uint16_t>(value);
|
||||
}
|
||||
|
||||
template <> inline uint32_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
return std::stoul(s, nullptr, base);
|
||||
}
|
||||
|
||||
template <> inline uint64_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
return std::stoull(s, nullptr, base);
|
||||
}
|
||||
|
||||
template <> inline int StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
return std::stoi(s, nullptr, base);
|
||||
}
|
||||
|
||||
/*template <> inline size_t StringTo(const std::string &s) {
|
||||
int base = s.find("0x") != std::string::npos ? 16 : 10;
|
||||
return std::stoull(s, nullptr, base);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
// vector
|
||||
template <typename T> std::string ToString(const std::vector<T> &vec) {
|
||||
std::ostringstream oss;
|
||||
oss << "[";
|
||||
for (size_t i = 0; i < vec.size(); ++i) {
|
||||
oss << vec[i];
|
||||
if (i != vec.size() - 1)
|
||||
oss << ", ";
|
||||
}
|
||||
oss << "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
|
||||
return os << ToString(v);
|
||||
}
|
||||
|
||||
template <
|
||||
typename Container,
|
||||
std::enable_if_t<is_container<Container>::value &&
|
||||
!is_std_string_v<Container> /*&&
|
||||
!is_map_v<Container>*/,
|
||||
int> = 0>
|
||||
Container StringTo(const std::string& s) {
|
||||
using Value = typename Container::value_type;
|
||||
|
||||
// strip outer brackets
|
||||
std::string str = s;
|
||||
str.erase(std::remove_if(str.begin(), str.end(),
|
||||
[](unsigned char c){ return c=='[' || c==']'; }), str.end());
|
||||
|
||||
std::stringstream ss(str);
|
||||
std::string item;
|
||||
Container result;
|
||||
|
||||
while (std::getline(ss, item, ',')) {
|
||||
TrimWhiteSpaces(item);
|
||||
if (!item.empty()) {
|
||||
result.push_back(StringTo<Value>(item));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// map
|
||||
template <typename KeyType, typename ValueType>
|
||||
std::string ToString(const std::map<KeyType, ValueType> &m) {
|
||||
std::ostringstream os;
|
||||
os << '{';
|
||||
if (!m.empty()) {
|
||||
auto it = m.cbegin();
|
||||
os << ToString(it->first) << ": " << ToString(it->second);
|
||||
it++;
|
||||
while (it != m.cend()) {
|
||||
os << ", " << ToString(it->first) << ": " << ToString(it->second);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
os << '}';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <> inline std::map<std::string, std::string> StringTo(const std::string &s) {
|
||||
std::map<std::string, std::string> result;
|
||||
std::string str = s;
|
||||
|
||||
// Remove outer braces if present
|
||||
if (!str.empty() && str.front() == '{' && str.back() == '}') {
|
||||
str = str.substr(1, str.size() - 2);
|
||||
}
|
||||
|
||||
std::stringstream ss(str);
|
||||
std::string item;
|
||||
|
||||
while (std::getline(ss, item, ',')) {
|
||||
auto colon_pos = item.find(':');
|
||||
if (colon_pos == std::string::npos)
|
||||
throw std::runtime_error("Missing ':' in item: " + item);
|
||||
|
||||
std::string key = item.substr(0, colon_pos);
|
||||
std::string value = item.substr(colon_pos + 1);
|
||||
|
||||
TrimWhiteSpaces(key);
|
||||
TrimWhiteSpaces(value);
|
||||
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// optional
|
||||
template <class T> std::string ToString(const std::optional<T> &opt) {
|
||||
return opt ? ToString(*opt) : "nullopt";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream &operator<<(std::ostream &os, const std::optional<T> &opt) {
|
||||
if (opt)
|
||||
|
@ -23,4 +23,52 @@ struct is_duration<T,
|
||||
decltype(std::declval<T>().zero())>,
|
||||
void>::type> : public std::true_type {};
|
||||
|
||||
/**
|
||||
* Type trait to evaluate if template parameter is
|
||||
* complying with a standard container
|
||||
*/
|
||||
template <typename T, typename _ = void>
|
||||
struct is_container : std::false_type {};
|
||||
|
||||
template <typename... Ts> struct is_container_helper {};
|
||||
|
||||
template <typename T>
|
||||
struct is_container<
|
||||
T, typename std::conditional<
|
||||
false,
|
||||
is_container_helper<
|
||||
typename std::remove_reference<T>::type::value_type,
|
||||
typename std::remove_reference<T>::type::size_type,
|
||||
typename std::remove_reference<T>::type::iterator,
|
||||
typename std::remove_reference<T>::type::const_iterator,
|
||||
decltype(std::declval<T>().size()),
|
||||
decltype(std::declval<T>().begin()),
|
||||
decltype(std::declval<T>().end()),
|
||||
decltype(std::declval<T>().cbegin()),
|
||||
decltype(std::declval<T>().cend()),
|
||||
decltype(std::declval<T>().empty())>,
|
||||
void>::type> : public std::true_type {};
|
||||
|
||||
|
||||
/**
|
||||
* Type trait to evaluate if template parameter is
|
||||
* complying with a std::string
|
||||
*/
|
||||
template <typename T>
|
||||
inline constexpr bool is_std_string_v =
|
||||
std::is_same_v<std::decay_t<T>, std::string>;
|
||||
|
||||
/**
|
||||
* Type trait to evaluate if template parameter is
|
||||
* complying with std::map
|
||||
*/
|
||||
template <typename T>
|
||||
struct is_map : std::false_type {};
|
||||
|
||||
template <typename K, typename V, typename... Args>
|
||||
struct is_map<std::map<K, V, Args...>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
inline constexpr bool is_map_v = is_map<std::decay_t<T>>::value;
|
||||
|
||||
} // namsespace aare
|
@ -63,7 +63,7 @@ size_t Hdf5File::frame_number(size_t frame_index) {
|
||||
}
|
||||
uint64_t fnum{0};
|
||||
int part_index = 0; // assuming first part
|
||||
m_header_files[0]->get_header_into(frame_index, part_index,
|
||||
m_header_datasets[0]->get_header_into(frame_index, part_index,
|
||||
reinterpret_cast<std::byte *>(&fnum));
|
||||
return fnum;
|
||||
}
|
||||
@ -76,9 +76,9 @@ size_t Hdf5File::pixels_per_frame() { return m_rows * m_cols; }
|
||||
size_t Hdf5File::bytes_per_pixel() const { return m_master.bitdepth() / 8; }
|
||||
|
||||
void Hdf5File::seek(size_t frame_index) {
|
||||
m_data_file->seek(frame_index);
|
||||
m_data_dataset->seek(frame_index);
|
||||
for (size_t i = 0; i != header_dataset_names.size(); ++i) {
|
||||
m_header_files[i]->seek(frame_index);
|
||||
m_header_datasets[i]->seek(frame_index);
|
||||
}
|
||||
m_current_frame = frame_index;
|
||||
}
|
||||
@ -123,7 +123,7 @@ void Hdf5File::get_frame_into(size_t frame_index, std::byte *frame_buffer,
|
||||
|
||||
void Hdf5File::get_data_into(size_t frame_index, std::byte *frame_buffer,
|
||||
size_t n_frames) {
|
||||
m_data_file->get_data_into(frame_index, frame_buffer, n_frames);
|
||||
m_data_dataset->get_data_into(frame_index, frame_buffer, n_frames);
|
||||
}
|
||||
|
||||
void Hdf5File::get_header_into(size_t frame_index, int part_index,
|
||||
@ -131,7 +131,7 @@ void Hdf5File::get_header_into(size_t frame_index, int part_index,
|
||||
try {
|
||||
read_hdf5_header_fields(header,
|
||||
[&](size_t iParameter, std::byte *dest) {
|
||||
m_header_files[iParameter]->get_header_into(
|
||||
m_header_datasets[iParameter]->get_header_into(
|
||||
frame_index, part_index, dest);
|
||||
});
|
||||
LOG(logDEBUG5) << "Read 1D header for frame " << frame_index;
|
||||
@ -191,15 +191,15 @@ void Hdf5File::open_data_file() {
|
||||
throw std::runtime_error(LOCATION +
|
||||
"Unsupported mode. Can only read Hdf5 files.");
|
||||
try {
|
||||
m_data_file = std::make_unique<H5Handles>(m_master.master_fname().string(), metadata_group_name + "/data");
|
||||
m_data_dataset = std::make_unique<H5Handles>(m_master.master_fname().string(), metadata_group_name + "/data");
|
||||
|
||||
m_total_frames = m_data_file->get_dims()[0];
|
||||
m_rows = m_data_file->get_dims()[1];
|
||||
m_cols = m_data_file->get_dims()[2];
|
||||
m_total_frames = m_data_dataset->get_dims()[0];
|
||||
m_rows = m_data_dataset->get_dims()[1];
|
||||
m_cols = m_data_dataset->get_dims()[2];
|
||||
//fmt::print("Data Dataset dimensions: frames = {}, rows = {}, cols = {}\n",
|
||||
// m_total_frames, m_rows, m_cols);
|
||||
} catch (const H5::Exception &e) {
|
||||
m_data_file.reset();
|
||||
m_data_dataset.reset();
|
||||
fmt::print("Exception type: {}\n", typeid(e).name());
|
||||
e.printErrorStack();
|
||||
throw std::runtime_error(
|
||||
@ -213,13 +213,12 @@ void Hdf5File::open_header_files() {
|
||||
"Unsupported mode. Can only read Hdf5 files.");
|
||||
try {
|
||||
for (size_t i = 0; i != header_dataset_names.size(); ++i) {
|
||||
m_header_files.push_back(std::make_unique<H5Handles>(m_master.master_fname().string(), metadata_group_name + header_dataset_names[i]));
|
||||
//fmt::print("{} Dataset dimensions: size = {}\n",
|
||||
// header_dataset_names[i], m_header_files[i]->dims[0]);
|
||||
m_header_datasets.push_back(std::make_unique<H5Handles>(m_master.master_fname().string(), metadata_group_name + header_dataset_names[i]));
|
||||
LOG(logDEBUG) << header_dataset_names[i] << " Dataset dimensions: size = " << m_header_datasets[i]->get_dims()[0];
|
||||
}
|
||||
} catch (const H5::Exception &e) {
|
||||
m_header_files.clear();
|
||||
m_data_file.reset();
|
||||
m_header_datasets.clear();
|
||||
m_data_dataset.reset();
|
||||
fmt::print("Exception type: {}\n", typeid(e).name());
|
||||
e.printErrorStack();
|
||||
throw std::runtime_error(
|
||||
|
@ -88,18 +88,18 @@ const std::string &Hdf5MasterFile::version() const { return m_version; }
|
||||
const DetectorType &Hdf5MasterFile::detector_type() const { return m_type; }
|
||||
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 {
|
||||
int Hdf5MasterFile::image_size_in_bytes() const {
|
||||
return m_image_size_in_bytes;
|
||||
}
|
||||
size_t Hdf5MasterFile::pixels_y() const { return m_pixels_y; }
|
||||
size_t Hdf5MasterFile::pixels_x() const { return m_pixels_x; }
|
||||
size_t Hdf5MasterFile::max_frames_per_file() const {
|
||||
int Hdf5MasterFile::pixels_y() const { return m_pixels_y; }
|
||||
int Hdf5MasterFile::pixels_x() const { return m_pixels_x; }
|
||||
int Hdf5MasterFile::max_frames_per_file() const {
|
||||
return m_max_frames_per_file;
|
||||
}
|
||||
const FrameDiscardPolicy &Hdf5MasterFile::frame_discard_policy() const {
|
||||
return m_frame_discard_policy;
|
||||
}
|
||||
size_t Hdf5MasterFile::frame_padding() const { return m_frame_padding; }
|
||||
int Hdf5MasterFile::frame_padding() const { return m_frame_padding; }
|
||||
std::optional<ScanParameters> Hdf5MasterFile::scan_parameters() const {
|
||||
return m_scan_parameters;
|
||||
}
|
||||
@ -115,17 +115,17 @@ std::optional<ns> Hdf5MasterFile::period() const {
|
||||
std::optional<BurstMode> Hdf5MasterFile::burst_mode() const {
|
||||
return m_burst_mode;
|
||||
}
|
||||
std::optional<size_t> Hdf5MasterFile::number_of_udp_interfaces() const {
|
||||
std::optional<int> Hdf5MasterFile::number_of_udp_interfaces() const {
|
||||
return m_number_of_udp_interfaces;
|
||||
}
|
||||
size_t Hdf5MasterFile::bitdepth() const { return m_bitdepth; }
|
||||
std::optional<size_t> Hdf5MasterFile::ten_giga() const {
|
||||
int Hdf5MasterFile::bitdepth() const { return m_bitdepth; }
|
||||
std::optional<bool> Hdf5MasterFile::ten_giga() const {
|
||||
return m_ten_giga;
|
||||
}
|
||||
std::optional<size_t> Hdf5MasterFile::threshold_energy() const {
|
||||
std::optional<int> Hdf5MasterFile::threshold_energy() const {
|
||||
return m_threshold_energy;
|
||||
}
|
||||
std::optional<std::vector<size_t>>
|
||||
std::optional<std::vector<int>>
|
||||
Hdf5MasterFile::threshold_energy_all() const {
|
||||
return m_threshold_energy_all;
|
||||
}
|
||||
@ -135,39 +135,43 @@ std::optional<ns> Hdf5MasterFile::subexptime() const {
|
||||
std::optional<ns> Hdf5MasterFile::subperiod() const {
|
||||
return m_subperiod;
|
||||
}
|
||||
std::optional<uint8_t> Hdf5MasterFile::quad() const { return m_quad; }
|
||||
std::optional<size_t> Hdf5MasterFile::number_of_rows() const {
|
||||
std::optional<bool> Hdf5MasterFile::quad() const { return m_quad; }
|
||||
std::optional<int> Hdf5MasterFile::number_of_rows() const {
|
||||
return m_number_of_rows;
|
||||
}
|
||||
std::optional<std::vector<size_t>> Hdf5MasterFile::rate_corrections() const {
|
||||
return m_rate_corrections;
|
||||
}
|
||||
std::optional<size_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 {
|
||||
std::optional<uint32_t> Hdf5MasterFile::adc_mask() const { return m_adc_mask; }
|
||||
bool Hdf5MasterFile::analog_flag() const { return m_analog_flag; }
|
||||
std::optional<int> 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 {
|
||||
bool Hdf5MasterFile::digital_flag() const { return m_digital_flag; }
|
||||
std::optional<int> Hdf5MasterFile::digital_samples() const {
|
||||
return m_digital_samples;
|
||||
}
|
||||
std::optional<size_t> Hdf5MasterFile::dbit_offset() const {
|
||||
std::optional<int> Hdf5MasterFile::dbit_offset() const {
|
||||
return m_dbit_offset;
|
||||
}
|
||||
std::optional<size_t> Hdf5MasterFile::dbit_list() const { return m_dbit_list; }
|
||||
std::optional<size_t> Hdf5MasterFile::transceiver_mask() const {
|
||||
std::optional<int> Hdf5MasterFile::transceiver_mask() const {
|
||||
return m_transceiver_mask;
|
||||
}
|
||||
std::optional<uint8_t> Hdf5MasterFile::transceiver_flag() const { return m_transceiver_flag; }
|
||||
std::optional<size_t> Hdf5MasterFile::transceiver_samples() const {
|
||||
bool Hdf5MasterFile::transceiver_flag() const { return m_transceiver_flag; }
|
||||
std::optional<int> Hdf5MasterFile::transceiver_samples() const {
|
||||
return m_transceiver_samples;
|
||||
}
|
||||
// g1 roi
|
||||
std::optional<ROI> Hdf5MasterFile::roi() const { return m_roi; }
|
||||
std::optional<size_t> Hdf5MasterFile::counter_mask() const { return m_counter_mask; }
|
||||
// exptimearray
|
||||
// gatedelay array
|
||||
std::optional<size_t> Hdf5MasterFile::gates() const { return m_gates; }
|
||||
std::optional<int> Hdf5MasterFile::counter_mask() const { return m_counter_mask; }
|
||||
std::optional<std::vector<ns>> Hdf5MasterFile::exptime_array() const {
|
||||
return m_exptime_array;
|
||||
}
|
||||
std::optional<std::vector<ns>> Hdf5MasterFile::gate_delay_array() const {
|
||||
return m_gate_delay_array;
|
||||
}
|
||||
std::optional<int> Hdf5MasterFile::gates() const { return m_gates; }
|
||||
std::optional<std::map<std::string, std::string>> Hdf5MasterFile::additional_json_header() const {
|
||||
return m_additional_json_header;
|
||||
}
|
||||
@ -193,9 +197,10 @@ T Hdf5MasterFile::h5_read_scalar_dataset(const H5::DataSet &dataset,
|
||||
template <>
|
||||
std::string Hdf5MasterFile::h5_read_scalar_dataset<std::string>(
|
||||
const H5::DataSet &dataset, const H5::DataType &data_type) {
|
||||
char buffer[257]{0};
|
||||
dataset.read(buffer, data_type);
|
||||
return std::string(buffer);
|
||||
size_t size = data_type.getSize();
|
||||
std::vector<char> buffer(size + 1, 0);
|
||||
dataset.read(buffer.data(), data_type);
|
||||
return std::string(buffer.data());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -225,7 +230,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::setprecision(1) << dVersion;
|
||||
m_version = oss.str();
|
||||
LOG(logDEBUG) << "Version: " << m_version;
|
||||
LOG(logINFOBLUE) << "Version: " << m_version;
|
||||
}
|
||||
|
||||
// Scalar Dataset
|
||||
@ -234,54 +239,54 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Detector Type
|
||||
m_type = StringTo<DetectorType>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Detector Type")));
|
||||
LOG(logDEBUG) << "Detector Type: " << ToString(m_type);
|
||||
LOG(logINFOBLUE) << "Detector Type: " << ToString(m_type);
|
||||
|
||||
// Timing Mode
|
||||
m_timing_mode = StringTo<TimingMode>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Timing Mode")));
|
||||
LOG(logDEBUG) << "Timing Mode: " << ToString(m_timing_mode);
|
||||
LOG(logINFOBLUE) << "Timing Mode: " << ToString(m_timing_mode);
|
||||
|
||||
// Geometry
|
||||
m_geometry.row = h5_get_scalar_dataset<size_t>(
|
||||
m_geometry.row = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Geometry in y axis"));
|
||||
m_geometry.col = h5_get_scalar_dataset<size_t>(
|
||||
m_geometry.col = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Geometry in x axis"));
|
||||
LOG(logDEBUG) << "Geometry: " << m_geometry.to_string();
|
||||
LOG(logINFOBLUE) << "Geometry: " << m_geometry.to_string();
|
||||
|
||||
|
||||
// Image Size
|
||||
m_image_size_in_bytes = h5_get_scalar_dataset<size_t>(
|
||||
m_image_size_in_bytes = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Image Size"));
|
||||
LOG(logDEBUG) << "Image size: {}\n" << m_image_size_in_bytes;
|
||||
LOG(logINFOBLUE) << "Image size: {}\n" << m_image_size_in_bytes;
|
||||
|
||||
// Pixels y
|
||||
m_pixels_y = h5_get_scalar_dataset<size_t>(
|
||||
m_pixels_y = h5_get_scalar_dataset<int>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Number of pixels in y axis"));
|
||||
LOG(logDEBUG) << "Pixels in y: " << m_pixels_y;
|
||||
LOG(logINFOBLUE) << "Pixels in y: " << m_pixels_y;
|
||||
|
||||
// Pixels x
|
||||
m_pixels_x = h5_get_scalar_dataset<size_t>(
|
||||
m_pixels_x = h5_get_scalar_dataset<int>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Number of pixels in x axis"));
|
||||
LOG(logDEBUG) << "Pixels in x: " << m_pixels_x;
|
||||
LOG(logINFOBLUE) << "Pixels in x: " << m_pixels_x;
|
||||
|
||||
// Max Frames Per File
|
||||
m_max_frames_per_file = h5_get_scalar_dataset<size_t>(
|
||||
m_max_frames_per_file = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Maximum frames per file"));
|
||||
LOG(logDEBUG) << "Max frames per File: " << m_max_frames_per_file;
|
||||
LOG(logINFOBLUE) << "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);
|
||||
LOG(logINFOBLUE) << "Frame Discard Policy: " << ToString(m_frame_discard_policy);
|
||||
|
||||
// Frame Padding
|
||||
m_frame_padding = h5_get_scalar_dataset<size_t>(
|
||||
m_frame_padding = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Frame Padding"));
|
||||
LOG(logDEBUG) << "Frame Padding: " << m_frame_padding;
|
||||
LOG(logINFOBLUE) << "Frame Padding: " << m_frame_padding;
|
||||
|
||||
// Scan Parameters
|
||||
try {
|
||||
@ -292,7 +297,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
m_scan_parameters
|
||||
->increment_stop(); // adjust for endpoint being included
|
||||
}
|
||||
LOG(logDEBUG) << "Scan Parameters: " << ToString(m_scan_parameters);
|
||||
LOG(logINFOBLUE) << "Scan Parameters: " << ToString(m_scan_parameters);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -300,13 +305,13 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Total Frames Expected
|
||||
m_total_frames_expected = h5_get_scalar_dataset<size_t>(
|
||||
file, std::string(metadata_group_name + "Total Frames"));
|
||||
LOG(logDEBUG) << "Total Frames: " << m_total_frames_expected;
|
||||
LOG(logINFOBLUE) << "Total Frames: " << m_total_frames_expected;
|
||||
|
||||
// Exptime
|
||||
try {
|
||||
m_exptime = StringTo<ns>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Exposure Time")));
|
||||
LOG(logDEBUG) << "Exptime: " << ToString(m_exptime);
|
||||
LOG(logINFOBLUE) << "Exptime: " << ToString(m_exptime);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -315,7 +320,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
try {
|
||||
m_period = StringTo<ns>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Acquisition Period")));
|
||||
LOG(logDEBUG) << "Period: " << ToString(m_period);
|
||||
LOG(logINFOBLUE) << "Period: " << ToString(m_period);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -325,7 +330,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
m_burst_mode =
|
||||
StringTo<BurstMode>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Burst Mode")));
|
||||
LOG(logDEBUG) << "Burst Mode: " << ToString(m_burst_mode);
|
||||
LOG(logINFOBLUE) << "Burst Mode: " << ToString(m_burst_mode);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -333,10 +338,10 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Number of UDP Interfaces
|
||||
// Not all detectors write the Number of UDP Interfaces but in case
|
||||
try {
|
||||
m_number_of_udp_interfaces = h5_get_scalar_dataset<size_t>(
|
||||
m_number_of_udp_interfaces = h5_get_scalar_dataset<int>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Number of UDP Interfaces"));
|
||||
LOG(logDEBUG) << "Number of UDP Interfaces: "
|
||||
LOG(logINFOBLUE) << "Number of UDP Interfaces: "
|
||||
<< m_number_of_udp_interfaces;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
@ -346,40 +351,42 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Not all detectors write the bitdepth but in case
|
||||
// its not there it is 16
|
||||
try {
|
||||
m_bitdepth = h5_get_scalar_dataset<size_t>(
|
||||
m_bitdepth = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Dynamic Range"));
|
||||
LOG(logDEBUG) << "Bit Depth: " << m_bitdepth;
|
||||
LOG(logINFOBLUE) << "Bit Depth: " << m_bitdepth;
|
||||
} catch (H5::FileIException &e) {
|
||||
m_bitdepth = 16;
|
||||
}
|
||||
|
||||
// Ten Giga
|
||||
try {
|
||||
m_ten_giga = h5_get_scalar_dataset<size_t>(
|
||||
file, std::string(metadata_group_name + "Ten Giga"));
|
||||
LOG(logDEBUG) << "Ten Giga: " << m_ten_giga;
|
||||
m_ten_giga = h5_get_scalar_dataset<bool>(
|
||||
file, std::string(metadata_group_name + "Ten Giga Enable"));
|
||||
LOG(logINFOBLUE) << "Ten Giga Enable: " << m_ten_giga;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Threshold Energy
|
||||
try {
|
||||
m_threshold_energy = h5_get_scalar_dataset<size_t>(
|
||||
m_threshold_energy = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Threshold Energy"));
|
||||
LOG(logDEBUG) << "Threshold Energy: " << m_threshold_energy;
|
||||
LOG(logINFOBLUE) << "Threshold Energy: " << m_threshold_energy;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Threshold All Energy
|
||||
try {
|
||||
m_threshold_energy_all = StringTo<std::vector<size_t>>(
|
||||
m_threshold_energy_all = StringTo<std::vector<int>>(
|
||||
h5_get_scalar_dataset<std::string>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Threshold Energies")));
|
||||
LOG(logDEBUG) << "Threshold Energies: "
|
||||
LOG(logINFOBLUE) << "Threshold Energies: "
|
||||
<< ToString(m_threshold_energy_all);
|
||||
} catch (H5::FileIException &e) {
|
||||
std::cout << "No Threshold Energies found in file: "
|
||||
<< fpath << std::endl;
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
@ -387,7 +394,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
try {
|
||||
m_subexptime = StringTo<ns>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Sub Exposure Time")));
|
||||
LOG(logDEBUG) << "Subexptime: " << ToString(m_subexptime);
|
||||
LOG(logINFOBLUE) << "Subexptime: " << ToString(m_subexptime);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -396,16 +403,16 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
try {
|
||||
m_subperiod = StringTo<ns>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Sub Period")));
|
||||
LOG(logDEBUG) << "Subperiod: " << ToString(m_subperiod);
|
||||
LOG(logINFOBLUE) << "Subperiod: " << ToString(m_subperiod);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Quad
|
||||
try {
|
||||
m_quad = h5_get_scalar_dataset<uint8_t>(
|
||||
m_quad = h5_get_scalar_dataset<bool>(
|
||||
file, std::string(metadata_group_name + "Quad"));
|
||||
LOG(logDEBUG) << "Quad: " << m_quad;
|
||||
LOG(logINFOBLUE) << "Quad: " << m_quad;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -413,9 +420,9 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Number of Rows
|
||||
// Not all detectors write the Number of rows but in case
|
||||
try {
|
||||
m_number_of_rows = h5_get_scalar_dataset<size_t>(
|
||||
m_number_of_rows = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Number of rows"));
|
||||
LOG(logDEBUG) << "Number of rows: " << m_number_of_rows;
|
||||
LOG(logINFOBLUE) << "Number of rows: " << m_number_of_rows;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -426,7 +433,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
h5_get_scalar_dataset<std::string>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Rate Corrections")));
|
||||
LOG(logDEBUG) << "Rate Corrections: "
|
||||
LOG(logINFOBLUE) << "Rate Corrections: "
|
||||
<< ToString(m_rate_corrections);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
@ -434,12 +441,12 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
|
||||
// ADC Mask
|
||||
try {
|
||||
m_adc_mask = h5_get_scalar_dataset<size_t>(
|
||||
m_adc_mask = h5_get_scalar_dataset<uint32_t>(
|
||||
file, std::string(metadata_group_name + "ADC Mask"));
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
LOG(logDEBUG) << "ADC Mask: " << m_adc_mask;
|
||||
LOG(logINFOBLUE) << "ADC Mask: " << m_adc_mask;
|
||||
|
||||
// Analog Flag
|
||||
// ----------------------------------------------------------------
|
||||
@ -447,7 +454,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
try {
|
||||
m_analog_flag = h5_get_scalar_dataset<uint8_t>(
|
||||
file, std::string(metadata_group_name + "Analog Flag"));
|
||||
LOG(logDEBUG) << "Analog Flag: " << m_analog_flag;
|
||||
LOG(logINFOBLUE) << "Analog Flag: " << m_analog_flag;
|
||||
} catch (H5::FileIException &e) {
|
||||
// if it doesn't work still set it to one
|
||||
// to try to decode analog samples (Old Moench03)
|
||||
@ -457,36 +464,36 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Analog Samples
|
||||
try {
|
||||
if (m_analog_flag) {
|
||||
m_analog_samples = h5_get_scalar_dataset<size_t>(
|
||||
m_analog_samples = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Analog Samples"));
|
||||
LOG(logDEBUG) << "Analog Samples: " << m_analog_samples;
|
||||
LOG(logINFOBLUE) << "Analog Samples: " << m_analog_samples;
|
||||
}
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
// and set analog flag to 0
|
||||
m_analog_flag = 0;
|
||||
m_analog_flag = false;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
// Digital Flag, Digital Samples
|
||||
try {
|
||||
m_digital_flag = h5_get_scalar_dataset<uint8_t>(
|
||||
m_digital_flag = h5_get_scalar_dataset<bool>(
|
||||
file, std::string(metadata_group_name + "Digital Flag"));
|
||||
LOG(logDEBUG) << "Digital Flag: " << m_digital_flag;
|
||||
if (m_digital_flag) {
|
||||
m_digital_samples = h5_get_scalar_dataset<size_t>(
|
||||
file, std::string(metadata_group_name + "Digital Samples"));
|
||||
}
|
||||
LOG(logDEBUG) << "Digital Samples: " << m_digital_samples;
|
||||
LOG(logINFOBLUE) << "Digital Flag: " << m_digital_flag;
|
||||
if (m_digital_flag) {
|
||||
m_digital_samples = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Digital Samples"));
|
||||
}
|
||||
LOG(logINFOBLUE) << "Digital Samples: " << m_digital_samples;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
m_digital_flag = false;
|
||||
}
|
||||
|
||||
// Dbit Offset
|
||||
try {
|
||||
m_dbit_offset = h5_get_scalar_dataset<size_t>(
|
||||
m_dbit_offset = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Dbit Offset"));
|
||||
LOG(logDEBUG) << "Dbit Offset: " << m_dbit_offset;
|
||||
LOG(logINFOBLUE) << "Dbit Offset: " << m_dbit_offset;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -495,46 +502,46 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
try {
|
||||
m_dbit_list = h5_get_scalar_dataset<size_t>(
|
||||
file, std::string(metadata_group_name + "Dbit Bitset List"));
|
||||
LOG(logDEBUG) << "Dbit list: " << m_dbit_list;
|
||||
LOG(logINFOBLUE) << "Dbit list: " << m_dbit_list;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Transceiver Mask
|
||||
try {
|
||||
m_transceiver_mask = h5_get_scalar_dataset<size_t>(
|
||||
m_transceiver_mask = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Transceiver Mask"));
|
||||
LOG(logDEBUG) << "Transceiver Mask: " << m_transceiver_mask;
|
||||
LOG(logINFOBLUE) << "Transceiver Mask: " << m_transceiver_mask;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Transceiver Flag, Transceiver Samples
|
||||
try {
|
||||
m_transceiver_flag = h5_get_scalar_dataset<uint8_t>(
|
||||
m_transceiver_flag = h5_get_scalar_dataset<bool>(
|
||||
file, std::string(metadata_group_name + "Transceiver Flag"));
|
||||
LOG(logDEBUG) << "Transceiver Flag: " << m_transceiver_flag;
|
||||
LOG(logINFOBLUE) << "Transceiver Flag: " << m_transceiver_flag;
|
||||
if (m_transceiver_flag) {
|
||||
m_transceiver_samples = h5_get_scalar_dataset<size_t>(
|
||||
m_transceiver_samples = h5_get_scalar_dataset<int>(
|
||||
file,
|
||||
std::string(metadata_group_name + "Transceiver Samples"));
|
||||
LOG(logDEBUG)
|
||||
LOG(logINFOBLUE)
|
||||
<< "Transceiver Samples: " << m_transceiver_samples;
|
||||
}
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
m_transceiver_flag = false;
|
||||
}
|
||||
|
||||
// Rx ROI
|
||||
try{
|
||||
ROI tmp_roi;
|
||||
tmp_roi.xmin = h5_get_scalar_dataset<size_t>(
|
||||
tmp_roi.xmin = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "receiver roi xmin"));
|
||||
tmp_roi.xmax = h5_get_scalar_dataset<size_t>(
|
||||
tmp_roi.xmax = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "receiver roi xmax"));
|
||||
tmp_roi.ymin = h5_get_scalar_dataset<size_t>(
|
||||
tmp_roi.ymin = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "receiver roi ymin"));
|
||||
tmp_roi.ymax = h5_get_scalar_dataset<size_t>(
|
||||
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
|
||||
@ -550,7 +557,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// if we have an roi we need to update the geometry for the subfiles
|
||||
if (m_roi) {
|
||||
}
|
||||
LOG(logDEBUG) << "ROI: " << m_roi;
|
||||
LOG(logINFOBLUE) << "ROI: " << m_roi;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -572,33 +579,47 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
|
||||
// Counter Mask
|
||||
try {
|
||||
m_counter_mask = h5_get_scalar_dataset<size_t>(
|
||||
m_counter_mask = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Counter Mask"));
|
||||
LOG(logDEBUG) << "Counter Mask: " << m_counter_mask;
|
||||
LOG(logINFOBLUE) << "Counter Mask: " << m_counter_mask;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// exptimearray
|
||||
//std::vector<ns> exptimearray = {std::chrono::nanoseconds(10), std::chrono::milliseconds(500)};
|
||||
//std::cout << "exptimearray: " << ToString(exptimearray) << std::endl;
|
||||
// Exposure Time Array
|
||||
try {
|
||||
m_exptime_array = StringTo<std::vector<ns>>(
|
||||
h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Exposure Times")));
|
||||
LOG(logINFOBLUE) << "Exposure Times: " << ToString(m_exptime_array);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// gatedelay array
|
||||
// Gate Delay Array
|
||||
try {
|
||||
m_gate_delay_array = StringTo<std::vector<ns>>(
|
||||
h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Gate Delays")));
|
||||
LOG(logINFOBLUE) << "Gate Delays: " << ToString(m_gate_delay_array);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// Gates
|
||||
try {
|
||||
m_gates = h5_get_scalar_dataset<size_t>(
|
||||
m_gates = h5_get_scalar_dataset<int>(
|
||||
file, std::string(metadata_group_name + "Gates"));
|
||||
LOG(logDEBUG) << "Gates: " << m_gates;
|
||||
LOG(logINFOBLUE) << "Gates: " << m_gates;
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
|
||||
// additional json header
|
||||
// Additional Json Header
|
||||
try {
|
||||
m_additional_json_header = StringTo<std::map<std::string, std::string>>(h5_get_scalar_dataset<std::string>(
|
||||
file, std::string(metadata_group_name + "Additional JSON Header")));
|
||||
LOG(logDEBUG) << "Additional JSON Header: " << ToString(m_additional_json_header);
|
||||
LOG(logINFOBLUE) << "Additional JSON Header: " << ToString(m_additional_json_header);
|
||||
} catch (H5::FileIException &e) {
|
||||
// keep the optional empty
|
||||
}
|
||||
@ -606,7 +627,7 @@ void Hdf5MasterFile::parse_acquisition_metadata(
|
||||
// Frames in File
|
||||
m_frames_in_file = h5_get_scalar_dataset<size_t>(
|
||||
file, std::string(metadata_group_name + "Frames in File"));
|
||||
LOG(logDEBUG) << "Frames in File: " << m_frames_in_file;
|
||||
LOG(logINFOBLUE) << "Frames in File: " << m_frames_in_file;
|
||||
|
||||
H5Eset_auto(H5E_DEFAULT, reinterpret_cast<H5E_auto2_t>(H5Eprint2),
|
||||
stderr);
|
||||
|
@ -247,6 +247,7 @@ std::string RemoveUnit(std::string &str) {
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
// template <> TimingMode StringTo<TimingMode>(std::string mode);
|
||||
|
||||
} // namespace aare
|
Reference in New Issue
Block a user