mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-11-08 02:03:53 +01:00
Keep gap pixels on RawFile only
Drop FileConfig::gap_pixels and the File constructor argument. The generic File does not know the detector geometry of .npy and .dat files, so gap pixels stay a RawFile option; apply insert_gap_pixels to frames from File when needed.
This commit is contained in:
1 parent
7e91a5e1af
commit
b0de46e184
9 files changed
+29
-76
No files matched your search
+7
-32
@@ -3,7 +3,6 @@
|
||||
#include "aare/CtbRawFile.hpp"
|
||||
#include "aare/File.hpp"
|
||||
#include "aare/Frame.hpp"
|
||||
#include "aare/GapPixels.hpp"
|
||||
#include "aare/ROI.hpp"
|
||||
#include "aare/RawFile.hpp"
|
||||
#include "aare/RawMasterFile.hpp"
|
||||
@@ -30,37 +29,13 @@ void define_file_io_bindings(py::module &m) {
|
||||
debug, roundRNumber, detType, version, packetMask);
|
||||
|
||||
py::class_<File>(m, "File")
|
||||
.def(py::init([](const std::filesystem::path &fname,
|
||||
const std::string &mode,
|
||||
std::optional<GapPixels> gap_pixels) {
|
||||
FileConfig cfg;
|
||||
cfg.gap_pixels = std::move(gap_pixels);
|
||||
return File(fname, mode, cfg);
|
||||
}),
|
||||
py::arg("fname"), py::arg("mode") = "r",
|
||||
py::arg("gap_pixels") = py::none())
|
||||
.def(py::init([](const std::filesystem::path &fname,
|
||||
const std::string &mode, bool gap_pixels) {
|
||||
FileConfig cfg;
|
||||
if (gap_pixels) {
|
||||
cfg.gap_pixels = GapPixels{};
|
||||
}
|
||||
return File(fname, mode, cfg);
|
||||
}),
|
||||
py::arg("fname"), py::arg("mode") = "r",
|
||||
py::arg("gap_pixels") = false, R"(
|
||||
Open a file for reading.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
fname : path
|
||||
Master file (.json, .raw), .npy or .dat file.
|
||||
mode : str
|
||||
Only "r" is supported.
|
||||
gap_pixels : bool or GapPixels
|
||||
Insert gap pixels when reading raw files. True uses the
|
||||
default GapPixels configuration.
|
||||
)")
|
||||
.def(py::init([](const std::filesystem::path &fname) {
|
||||
return File(fname, "r", {});
|
||||
}))
|
||||
.def(py::init(
|
||||
[](const std::filesystem::path &fname, const std::string &mode) {
|
||||
return File(fname, mode, {});
|
||||
}))
|
||||
.def(py::init<const std::filesystem::path &, const std::string &,
|
||||
const FileConfig &>())
|
||||
|
||||
|
||||
@@ -544,16 +544,15 @@ def test_raw_file_gap_pixels(tmp_path, layout):
|
||||
|
||||
with RawFile(master_path, gap_pixels=True) as reader:
|
||||
assert reader.gap_pixels == GapPixels()
|
||||
assert (reader.rows(), reader.cols()) == insert_gap_pixels(expected).shape
|
||||
_, image = reader.read_frame()
|
||||
assert (image == insert_gap_pixels(expected)).all()
|
||||
|
||||
with File(master_path, gap_pixels=True) as reader:
|
||||
assert (reader.rows, reader.cols) == insert_gap_pixels(expected).shape
|
||||
assert (reader.read_frame() == insert_gap_pixels(expected)).all()
|
||||
|
||||
module_gaps = GapPixels(module_gaps=ModuleGaps(8, 36))
|
||||
with File(master_path, gap_pixels=module_gaps) as reader:
|
||||
assert (reader.read_frame() == insert_gap_pixels(expected, module_gaps)).all()
|
||||
with RawFile(master_path, gap_pixels=module_gaps) as reader:
|
||||
assert (reader.rows(), reader.cols()) == insert_gap_pixels(expected, module_gaps).shape
|
||||
_, image = reader.read_frame()
|
||||
assert (image == insert_gap_pixels(expected, module_gaps)).all()
|
||||
|
||||
|
||||
def test_raw_file_gap_pixels_split_counts(tmp_path):
|
||||
@@ -570,8 +569,6 @@ def test_raw_file_gap_pixels_unsupported_detector(tmp_path):
|
||||
RawFile(master_path)
|
||||
with pytest.raises(ValueError):
|
||||
RawFile(master_path, gap_pixels=True)
|
||||
with pytest.raises(ValueError):
|
||||
File(master_path, gap_pixels=True)
|
||||
|
||||
|
||||
@pytest.mark.withdata
|
||||
|
||||
Reference in new issue
Block a user