mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-18 15:28:40 +01:00
Fix/mythenfilereading (#250)
Add counter mask as member of RawFile BugFix: temporarily handle -1 for ROI in mythenfile
This commit is contained in:
@@ -103,6 +103,7 @@ class RawMasterFile {
|
||||
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_counter_mask;
|
||||
|
||||
std::optional<ROI> m_roi;
|
||||
|
||||
@@ -133,6 +134,7 @@ class RawMasterFile {
|
||||
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> counter_mask() const;
|
||||
|
||||
std::optional<ROI> roi() const;
|
||||
|
||||
|
||||
@@ -320,4 +320,14 @@ TEST_CASE("Read file with unordered frames", "[.with-data]") {
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
File f(fpath);
|
||||
REQUIRE_THROWS((f.read_frame()));
|
||||
}
|
||||
|
||||
TEST_CASE("Read Mythenframe", "[.with-data]") {
|
||||
auto fpath = test_data_path() / "raw/newmythen03/run_2_master_1.json";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawFile f(fpath);
|
||||
REQUIRE(f.master().roi().value().width() == 2560);
|
||||
REQUIRE(f.master().roi().value().height() == 1);
|
||||
auto frame = f.read_frame();
|
||||
REQUIRE(frame.cols() == 2560);
|
||||
}
|
||||
@@ -143,6 +143,10 @@ std::optional<size_t> RawMasterFile::number_of_rows() const {
|
||||
return m_number_of_rows;
|
||||
}
|
||||
|
||||
std::optional<uint8_t> RawMasterFile::counter_mask() const {
|
||||
return m_counter_mask;
|
||||
}
|
||||
|
||||
xy RawMasterFile::geometry() const { return m_geometry; }
|
||||
|
||||
size_t RawMasterFile::n_modules() const {
|
||||
@@ -313,15 +317,26 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) {
|
||||
}
|
||||
|
||||
// if any of the values are set update the roi
|
||||
// TODO: doesnt it write garbage if one of them is not set
|
||||
if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295 ||
|
||||
tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) {
|
||||
tmp_roi.xmax++;
|
||||
// Handle Mythen
|
||||
if (tmp_roi.ymin == -1 && tmp_roi.ymax == -1) {
|
||||
tmp_roi.ymin = 0;
|
||||
tmp_roi.ymax = 0;
|
||||
}
|
||||
tmp_roi.ymax++;
|
||||
m_roi = tmp_roi;
|
||||
}
|
||||
|
||||
} catch (const json::out_of_range &e) {
|
||||
LOG(TLogLevel::logERROR) << e.what() << std::endl;
|
||||
// leave the optional empty
|
||||
}
|
||||
try {
|
||||
// TODO: what is the best format to handle
|
||||
m_counter_mask = j.at("Counter Mask");
|
||||
} catch (const json::out_of_range &e) {
|
||||
// leave the optional empty
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user