added tests with LFS
All checks were successful
Build on RHEL9 / buildh (push) Successful in 1m46s

This commit is contained in:
froejdh_e
2025-04-04 19:57:30 +02:00
parent 88a5c2e0d8
commit f78e6cb345
4 changed files with 39 additions and 34 deletions

View File

@ -78,30 +78,5 @@ void define_jungfrau_data_file_io_bindings(py::module &m) {
return py::make_tuple(header, image);
});
// .def("read_frame",
// [](RawFile &self) {
// py::array image;
// 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<DetectorHeader> header(self.n_mod());
// const uint8_t item_size = self.bytes_per_pixel();
// if (item_size == 1) {
// image = py::array_t<uint8_t>(shape);
// } else if (item_size == 2) {
// image = py::array_t<uint16_t>(shape);
// } else if (item_size == 4) {
// image = py::array_t<uint32_t>(shape);
// }
// self.read_into(
// reinterpret_cast<std::byte *>(image.mutable_data()),
// header.mutable_data());
// return py::make_tuple(header, image);
// })
}

View File

@ -11,9 +11,9 @@
using aare::ClusterFile;
TEST_CASE("Read one frame from a a cluster file", "[.integration]") {
TEST_CASE("Read one frame from a a cluster file", "[.files]") {
//We know that the frame has 97 clusters
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
auto fpath = test_data_path() / "clust" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath));
ClusterFile f(fpath);
@ -22,9 +22,9 @@ TEST_CASE("Read one frame from a a cluster file", "[.integration]") {
REQUIRE(clusters.frame_number() == 135);
}
TEST_CASE("Read one frame using ROI", "[.integration]") {
TEST_CASE("Read one frame using ROI", "[.files]") {
//We know that the frame has 97 clusters
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
auto fpath = test_data_path() / "clust" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath));
ClusterFile f(fpath);
@ -50,9 +50,9 @@ TEST_CASE("Read one frame using ROI", "[.integration]") {
}
TEST_CASE("Read clusters from single frame file", "[.integration]") {
TEST_CASE("Read clusters from single frame file", "[.files]") {
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
auto fpath = test_data_path() / "clust" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath));
SECTION("Read fewer clusters than available") {

View File

@ -130,7 +130,7 @@ void JungfrauDataFile::read_into(std::byte *image_buf,
// prepare for next read
// if we are at the end of the file, open the next file
++ m_current_frame;
if(m_current_frame >= m_frame_index[m_current_file_index]){
if(m_current_frame >= m_frame_index[m_current_file_index] && (m_current_frame < m_total_frames)){
++m_current_file_index;
open_file(m_current_file_index);
}

View File

@ -1,6 +1,36 @@
#include "aare/JungfrauDataFile.hpp"
#include <catch2/catch_test_macros.hpp>
#include "test_config.hpp"
TEST_CASE("fail"){
REQUIRE(false);
using aare::JungfrauDataFile;
using aare::JungfrauDataHeader;
TEST_CASE("Open a Jungfrau data file", "[.files]") {
//we know we have 4 files with 7, 7, 7, and 3 frames
//firs frame number if 1 and the bunch id is frame_number**2
//so we can check the header
auto fpath = test_data_path() / "dat" / "AldoJF500k_000000.dat";
REQUIRE(std::filesystem::exists(fpath));
JungfrauDataFile f(fpath);
REQUIRE(f.rows() == 512);
REQUIRE(f.cols() == 1024);
REQUIRE(f.bytes_per_frame() == 1048576);
REQUIRE(f.pixels_per_frame() == 524288);
REQUIRE(f.bytes_per_pixel() == 2);
REQUIRE(f.bitdepth() == 16);
REQUIRE(f.base_name() == "AldoJF500k");
REQUIRE(f.n_files() == 4);
REQUIRE(f.tell() == 0);
REQUIRE(f.total_frames() == 24);
REQUIRE(f.current_file() == fpath);
for (size_t i = 0; i < 24; ++i) {
JungfrauDataHeader header;
auto image = f.read_frame(header);
REQUIRE(header.framenum == i + 1);
REQUIRE(header.bunchid == (i + 1) * (i + 1));
REQUIRE(image.shape(0) == 512);
REQUIRE(image.shape(1) == 1024);
}
}