updated rois in master file
Build on RHEL9 / build (push) Successful in 2m29s
Build on RHEL8 / build (push) Successful in 3m12s
Run tests using data on local RHEL8 / build (push) Successful in 3m55s

This commit is contained in:
2026-08-24 16:07:40 +02:00
parent e4f9b791f9
commit cf07d40bb4
6 changed files with 83 additions and 5 deletions
+6
View File
@@ -172,6 +172,12 @@ class RawFile : public FileInterface {
Frame get_frame(size_t frame_index, const size_t roi_index = 0);
void open_subfiles(const size_t roi_index);
/**
* @brief set the ROIs in master file.
* @param rois vector of ROIs to set in the RawMasterFile.
*/
void set_ROIs(const std::vector<ROI> &rois);
};
} // namespace aare
+4
View File
@@ -13,6 +13,8 @@ using json = nlohmann::json;
namespace aare {
class RawFile; // forward declaration
/**
* @brief Implementation used in RawMasterFile to parse the file name
*/
@@ -175,6 +177,8 @@ class RawMasterFile {
void parse_json(std::istream &is);
void parse_raw(std::istream &is);
void retrieve_geometry();
friend class RawFile;
};
} // namespace aare
+8 -2
View File
@@ -190,8 +190,14 @@ void define_file_io_bindings(py::module &m) {
"<ROI: xmin: {} xmax: {} ymin: {} ymax: {}>", self.xmin,
self.xmax, self.ymin, self.ymax);
})
.def("__iter__", [](const ROI &self) {
return py::make_iterator(&self.xmin, &self.ymax + 1); // NOLINT
.def("__iter__",
[](const ROI &self) {
return py::make_iterator(&self.xmin, &self.ymax + 1); // NOLINT
})
.def("__eq__", [](const ROI &self, const ROI &other) {
return self.xmin == other.xmin && self.xmax == other.xmax &&
self.ymin == other.ymin && self.ymax == other.ymax;
});
#pragma GCC diagnostic pop
+13 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: MPL-2.0
import pytest
from aare import RawFile
from aare import RawFile, ROI
import numpy as np
@pytest.mark.withdata
@@ -120,12 +120,19 @@ def test_read_eiger_udp_port_disabled(test_data_path):
assert(len(frame) == 2)
assert frame[0].shape == (256, 512)
assert frame[1].shape == (256, 1024)
rois = f.master.rois
assert len(rois) == 2
assert rois[0] == ROI(512, 1024, 0, 256)
assert rois[1] == ROI(0, 1024, 256, 512)
with RawFile(test_data_path / "raw/eiger/quad_eiger_disabled_bottom_port_master_0.json") as f:
_, frame = f.read_frame()
assert frame.shape == (256, 512)
assert(f.master.disabled_udp_ports == [1])
rois = f.master.rois
assert len(rois) == 1
assert rois[0] == ROI(0, 512, 256, 512)
with RawFile(test_data_path / "raw/eiger/2_modules_eiger_disabled_udp_port_master_0.json") as f:
_, frame = f.read_rois()
@@ -134,3 +141,8 @@ def test_read_eiger_udp_port_disabled(test_data_path):
assert frame[0].shape == (512, 512)
assert frame[1].shape == (512, 512)
assert (f.master.disabled_udp_ports == [1, 3, 5, 7])
rois = f.master.rois
assert len(rois) == 2
assert rois[0] == ROI(0, 512, 0, 512)
assert rois[1] == ROI(1024, 1536, 0, 512)
+4
View File
@@ -210,6 +210,8 @@ RawFile::RawFile(const std::filesystem::path &fname, const std::string &mode)
std::vector<ROI> rois = get_rois_from_disabled_udp_ports(
disabled_ports, udp_port_types, m_geometry);
set_ROIs(rois);
m_subfiles.resize(rois.size());
m_ROI_geometries.reserve(rois.size());
@@ -689,4 +691,6 @@ size_t RawFile::frame_number(size_t frame_index) {
return m_subfiles[0][0]->frame_number(frame_index);
}
void RawFile::set_ROIs(const std::vector<ROI> &rois) { m_master.m_rois = rois; }
} // namespace aare
+48 -2
View File
@@ -421,6 +421,11 @@ TEST_CASE("Read Jungfrau frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 1024);
REQUIRE(frame.rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 1024, 0, 256});
}
SECTION("disabled bottom port") {
@@ -435,6 +440,9 @@ TEST_CASE("Read Jungfrau frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 1024);
REQUIRE(frame.rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 1024, 256, 512});
}
SECTION("2 modules - top ports disabled") {
auto fpath = test_data_path() / "raw/jungfrau" /
@@ -459,6 +467,10 @@ TEST_CASE("Read Jungfrau frame with disabled UDP ports",
REQUIRE(frame[0].rows() == 256);
REQUIRE(frame[1].cols() == 1024);
REQUIRE(frame[1].rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 2);
REQUIRE(rois.value()[0] == ROI{0, 1024, 0, 256});
REQUIRE(rois.value()[1] == ROI{0, 1024, 512, 768});
}
SECTION("2 modules - top ports disabled - bottom port disabled") {
auto fpath = test_data_path() / "raw/jungfrau" /
@@ -472,6 +484,9 @@ TEST_CASE("Read Jungfrau frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 1024);
REQUIRE(frame.rows() == 512);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 1024, 256, 768});
}
SECTION("4 modules- mixed ports disabled") {
auto fpath = test_data_path() / "raw/jungfrau" /
@@ -497,6 +512,12 @@ TEST_CASE("Read Jungfrau frame with disabled UDP ports",
REQUIRE(frames[2].rows() == 256);
REQUIRE(frames[3].cols() == 1024);
REQUIRE(frames[3].rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 4);
REQUIRE(rois.value()[0] == ROI{0, 1024, 0, 256});
REQUIRE(rois.value()[1] == ROI{0, 1024, 512, 768});
REQUIRE(rois.value()[2] == ROI{1024, 2048, 256, 512});
REQUIRE(rois.value()[3] == ROI{1024, 2048, 768, 1024});
}
}
@@ -514,6 +535,10 @@ TEST_CASE("Read Moench frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 400);
REQUIRE(frame.rows() == 200);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 400, 0, 200});
}
SECTION("disabled bottom port") {
@@ -528,6 +553,10 @@ TEST_CASE("Read Moench frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 400);
REQUIRE(frame.rows() == 200);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 400, 200, 400});
}
}
@@ -544,10 +573,12 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
std::vector<std::string>{"left", "right"});
auto frame = f.read_frame();
std::cout << fmt::format("num rows {}, num cols {}", frame.rows(),
frame.cols());
REQUIRE(frame.cols() == 512);
REQUIRE(frame.rows() == 512);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{512, 1024, 0, 512});
}
SECTION("disabled right port") {
auto fpath = test_data_path() / "raw/eiger" /
@@ -561,6 +592,9 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 512);
REQUIRE(frame.rows() == 512);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 512, 0, 512});
}
SECTION("2 full modules stacked vertically - right ports disabled") {
auto fpath = test_data_path() / "raw/eiger" /
@@ -583,6 +617,10 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
REQUIRE(frames[0].rows() == 512);
REQUIRE(frames[1].cols() == 512);
REQUIRE(frames[1].rows() == 512);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 2);
REQUIRE(rois.value()[0] == ROI{0, 512, 0, 512});
REQUIRE(rois.value()[1] == ROI{1024, 1536, 0, 512});
}
SECTION("quad module - bottom port disabled") {
auto fpath = test_data_path() / "raw/eiger" /
@@ -597,6 +635,9 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
auto frame = f.read_frame();
REQUIRE(frame.cols() == 512);
REQUIRE(frame.rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 1);
REQUIRE(rois.value()[0] == ROI{0, 512, 256, 512});
}
SECTION("only one port disabled") {
auto fpath = test_data_path() / "raw/eiger" /
@@ -614,5 +655,10 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
REQUIRE(frame[0].rows() == 256);
REQUIRE(frame[1].cols() == 1024);
REQUIRE(frame[1].rows() == 256);
auto rois = f.master().rois();
REQUIRE(rois.value().size() == 2);
REQUIRE(rois.value()[0] == ROI{512, 1024, 0, 256});
REQUIRE(rois.value()[1] == ROI{0, 1024, 256, 512});
}
}