fixes from review
All checks were successful
Build on RHEL9 / buildh (push) Successful in 1m53s

This commit is contained in:
froejdh_e
2025-04-07 17:20:41 +02:00
parent da9190d57d
commit 6d8855980c
3 changed files with 33 additions and 12 deletions

View File

@ -20,14 +20,11 @@ using namespace ::aare;
#pragma GCC diagnostic ignored "-Wunused-parameter"
auto read_dat_frame(JungfrauDataFile &self) {
std::vector<ssize_t> shape;
shape.reserve(2);
shape.push_back(self.rows());
shape.push_back(self.cols());
// return headers from all subfiles
py::array_t<JungfrauDataHeader> header(1);
py::array_t<uint16_t> image(shape);
py::array_t<uint16_t> image({
self.rows(),
self.cols()
});
self.read_into(reinterpret_cast<std::byte *>(image.mutable_data()),
header.mutable_data());
@ -41,12 +38,11 @@ auto read_n_dat_frames(JungfrauDataFile &self, size_t n_frames) {
if (n_frames == 0) {
throw std::runtime_error("No frames left in file");
}
std::vector<size_t> shape{n_frames, self.rows(), self.cols()};
// return headers from all subfiles
py::array_t<JungfrauDataHeader> header(n_frames);
py::array_t<uint16_t> image(shape);
py::array_t<uint16_t> image({
n_frames, self.rows(),
self.cols()});
self.read_into(reinterpret_cast<std::byte *>(image.mutable_data()),
n_frames, header.mutable_data());

View File

@ -11,7 +11,7 @@ def pytest_addoption(parser):
def pytest_configure(config):
config.addinivalue_line("markers", "files: mark test as needing image fiels to run")
config.addinivalue_line("markers", "files: mark test as needing image files to run")
def pytest_collection_modifyitems(config, items):

View File

@ -67,3 +67,28 @@ TEST_CASE("Seek in a JungfrauDataFile", "[.files]"){
REQUIRE_THROWS(f.seek(86356)); //out of range
}
TEST_CASE("Open a Jungfrau data file with non zero file index", "[.files]"){
auto fpath = test_data_path() / "dat" / "AldoJF65k_000003.dat";
REQUIRE(std::filesystem::exists(fpath));
JungfrauDataFile f(fpath);
//18 files per data file, opening the 3rd file we ignore the first 3
REQUIRE(f.total_frames() == 113-18*3);
REQUIRE(f.tell() == 0);
//Frame numbers start at 1 in the first file
REQUIRE(f.read_header().framenum == 18*3+1);
// moving relative to the third file
f.seek(5);
REQUIRE(f.read_header().framenum == 18*3+1+5);
// ignoring the first 3 files
REQUIRE(f.n_files() == 4);
REQUIRE(f.current_file().stem() == "AldoJF65k_000003");
}