mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-09-03 10:20:46 +02:00
added more eiger tests
This commit is contained in:
@@ -675,3 +675,95 @@ TEST_CASE("Read Eiger frame with disabled UDP ports",
|
||||
REQUIRE(rois[1] == ROI{0, 1024, 256, 512});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Read Eiger 500k json v8.1 with all ports active",
|
||||
"[.with-data][RawFile][disabled_udp_ports]") {
|
||||
auto fpath = test_data_path() / "raw/eiger_virtual_500k_disabled_ports" /
|
||||
"all_active_master_0.json";
|
||||
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawFile f(fpath);
|
||||
|
||||
auto disabled_udp_ports = f.master().disabled_udp_ports();
|
||||
REQUIRE(disabled_udp_ports.has_value());
|
||||
REQUIRE(disabled_udp_ports.value().empty());
|
||||
|
||||
auto udp_port_types = f.master().udp_port_types();
|
||||
REQUIRE(udp_port_types.has_value());
|
||||
REQUIRE(udp_port_types.value() ==
|
||||
std::vector<UDPPortPosition>{UDPPortPosition::LEFT,
|
||||
UDPPortPosition::RIGHT});
|
||||
REQUIRE(f.total_frames() == 5);
|
||||
|
||||
auto frame = f.read_frame();
|
||||
REQUIRE(frame.cols() == 1024);
|
||||
REQUIRE(frame.rows() == 512);
|
||||
|
||||
auto rois = f.master().rois();
|
||||
REQUIRE(rois.size() == 1);
|
||||
REQUIRE(rois[0] == ROI{0, 1024, 0, 512});
|
||||
}
|
||||
|
||||
TEST_CASE("Read Eiger 500k json v8.1 with one port disabled",
|
||||
"[.with-data][RawFile][disabled_udp_ports]") {
|
||||
auto fpath = test_data_path() / "raw/eiger_virtual_500k_disabled_ports" /
|
||||
"left_master_1.json";
|
||||
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawFile f(fpath);
|
||||
|
||||
auto disabled_udp_ports = f.master().disabled_udp_ports();
|
||||
REQUIRE(disabled_udp_ports.has_value());
|
||||
REQUIRE(disabled_udp_ports.value() == std::vector<size_t>{0});
|
||||
|
||||
auto udp_port_types = f.master().udp_port_types();
|
||||
REQUIRE(udp_port_types.has_value());
|
||||
REQUIRE(udp_port_types.value() ==
|
||||
std::vector<UDPPortPosition>{UDPPortPosition::LEFT,
|
||||
UDPPortPosition::RIGHT});
|
||||
REQUIRE(f.total_frames() == 5);
|
||||
REQUIRE_THROWS_WITH(
|
||||
f.read_frame(),
|
||||
Catch::Matchers::ContainsSubstring(
|
||||
"Multiple ROIs present in file. Use read_ROIs() instead"));
|
||||
|
||||
auto frames = f.read_rois();
|
||||
REQUIRE(frames.size() == 2);
|
||||
REQUIRE(frames[0].cols() == 512);
|
||||
REQUIRE(frames[0].rows() == 256);
|
||||
REQUIRE(frames[1].cols() == 1024);
|
||||
REQUIRE(frames[1].rows() == 256);
|
||||
|
||||
auto rois = f.master().rois();
|
||||
REQUIRE(rois.size() == 2);
|
||||
REQUIRE(rois[0] == ROI{512, 1024, 0, 256});
|
||||
REQUIRE(rois[1] == ROI{0, 1024, 256, 512});
|
||||
}
|
||||
|
||||
TEST_CASE("Read Eiger 500k json v8.1 with two ports on left side disabled",
|
||||
"[.with-data][RawFile][disabled_udp_ports]") {
|
||||
auto fpath = test_data_path() / "raw/eiger_virtual_500k_disabled_ports" /
|
||||
"both_left_master_0.json";
|
||||
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
RawFile f(fpath);
|
||||
|
||||
auto disabled_udp_ports = f.master().disabled_udp_ports();
|
||||
REQUIRE(disabled_udp_ports.has_value());
|
||||
REQUIRE(disabled_udp_ports.value() == std::vector<size_t>{0, 2});
|
||||
|
||||
auto udp_port_types = f.master().udp_port_types();
|
||||
REQUIRE(udp_port_types.has_value());
|
||||
REQUIRE(udp_port_types.value() ==
|
||||
std::vector<UDPPortPosition>{UDPPortPosition::LEFT,
|
||||
UDPPortPosition::RIGHT});
|
||||
REQUIRE(f.total_frames() == 5);
|
||||
|
||||
auto frame = f.read_frame();
|
||||
REQUIRE(frame.cols() == 512);
|
||||
REQUIRE(frame.rows() == 512);
|
||||
|
||||
auto rois = f.master().rois();
|
||||
REQUIRE(rois.size() == 1);
|
||||
REQUIRE(rois[0] == ROI{512, 1024, 0, 512});
|
||||
}
|
||||
|
||||
@@ -1285,3 +1285,110 @@ TEST_CASE("Parse old Moench03 from stream") {
|
||||
REQUIRE(f.period() == std::chrono::microseconds(600));
|
||||
REQUIRE(f.analog_samples() == 5000);
|
||||
}
|
||||
|
||||
TEST_CASE("Parse Eiger json v8.1 all ports active") {
|
||||
std::string master_content = R"(
|
||||
{
|
||||
"Version": 8.1,
|
||||
"Timestamp": "Mon Aug 10 17:44:46 2026",
|
||||
"Detector Type": "Eiger",
|
||||
"Timing Mode": "auto",
|
||||
"Geometry": {
|
||||
"x": 2,
|
||||
"y": 2
|
||||
},
|
||||
"Image Size": 262144,
|
||||
"Pixels": {
|
||||
"x": 512,
|
||||
"y": 256
|
||||
},
|
||||
"Max Frames Per File": 10000,
|
||||
"Frame Discard Policy": "nodiscard",
|
||||
"Frame Padding": 1,
|
||||
"Scan Parameters": {
|
||||
"enable": 0,
|
||||
"dacInd": 0,
|
||||
"start offset": 0,
|
||||
"stop offset": 0,
|
||||
"step size": 0,
|
||||
"dac settle time ns": 0
|
||||
},
|
||||
"Total Frames": 5,
|
||||
"Receiver Rois": [
|
||||
{
|
||||
"xmin": 0,
|
||||
"xmax": 1023,
|
||||
"ymin": 0,
|
||||
"ymax": 511
|
||||
}
|
||||
],
|
||||
"Dynamic Range": 16,
|
||||
"Ten Giga": 0,
|
||||
"Exposure Time": "1s",
|
||||
"Acquisition Period": "1s",
|
||||
"Threshold Energy": -1,
|
||||
"Sub Exposure Time": "2.62144ms",
|
||||
"Sub Acquisition Period": "2.62144ms",
|
||||
"Quad": 0,
|
||||
"UDP Ports Type": [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
"UDP Ports Disabled": [],
|
||||
"Number of Rows": 256,
|
||||
"Rate Corrections": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"Readout Speed": "full_speed",
|
||||
"Frames in File": 5,
|
||||
"Additional JSON Header": {}
|
||||
}
|
||||
|
||||
)";
|
||||
|
||||
std::istringstream iss(master_content);
|
||||
RawMasterFile f(iss, "test_master_0.json");
|
||||
|
||||
REQUIRE(f.version() == "8.1");
|
||||
REQUIRE(f.detector_type() == DetectorType::Eiger);
|
||||
REQUIRE(f.timing_mode() == TimingMode::Auto);
|
||||
REQUIRE(f.detector_layout() == xy{2, 2});
|
||||
REQUIRE(f.n_modules() == 4);
|
||||
REQUIRE(f.image_size_in_bytes() == 262144);
|
||||
REQUIRE(f.pixels_x() == 512);
|
||||
REQUIRE(f.pixels_y() == 256);
|
||||
REQUIRE(f.max_frames_per_file() == 10000);
|
||||
REQUIRE(f.frame_discard_policy() == FrameDiscardPolicy::NoDiscard);
|
||||
REQUIRE(f.frame_padding() == 1);
|
||||
REQUIRE(f.total_frames_expected() == 5);
|
||||
REQUIRE(f.frames_in_file() == 5);
|
||||
REQUIRE(f.bitdepth() == 16);
|
||||
REQUIRE(f.exptime() == std::chrono::seconds(1));
|
||||
REQUIRE(f.period() == std::chrono::seconds(1));
|
||||
REQUIRE(f.quad() == 0);
|
||||
//rows return a std::optional, so we need to check if it has a value before using it
|
||||
auto rows = f.number_of_rows();
|
||||
REQUIRE(rows.has_value());
|
||||
REQUIRE(rows.value() == 256);
|
||||
REQUIRE(f.udp_interfaces_per_module() == xy{1, 2});
|
||||
|
||||
auto scan_parameters = f.scan_parameters();
|
||||
REQUIRE_FALSE(scan_parameters.enabled());
|
||||
REQUIRE(scan_parameters.dac() == DACIndex::DAC_0);
|
||||
REQUIRE(scan_parameters.start() == 0);
|
||||
REQUIRE(scan_parameters.stop() == 0);
|
||||
REQUIRE(scan_parameters.step() == 0);
|
||||
REQUIRE(scan_parameters.settleTime() == 0);
|
||||
|
||||
REQUIRE(f.udp_port_types().has_value());
|
||||
REQUIRE(f.udp_port_types().value() ==
|
||||
std::vector<UDPPortPosition>{UDPPortPosition::LEFT,
|
||||
UDPPortPosition::RIGHT});
|
||||
REQUIRE(f.disabled_udp_ports().has_value());
|
||||
REQUIRE(f.disabled_udp_ports().value().empty());
|
||||
|
||||
auto rois = f.rois();
|
||||
REQUIRE(rois.size() == 1);
|
||||
REQUIRE(rois[0] == ROI{0, 1024, 0, 512});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user