only files within the ROI are opened & geometry always read in RawMasterFile

This commit is contained in:
2025-06-04 16:34:40 +02:00
parent 69964e08d5
commit 9c6e629298
5 changed files with 208 additions and 200 deletions

View File

@@ -1,11 +1,10 @@
#pragma once
#include "aare/FileInterface.hpp"
#include "aare/RawMasterFile.hpp"
#include "aare/Frame.hpp"
#include "aare/NDArray.hpp" //for pixel map
#include "aare/RawMasterFile.hpp"
#include "aare/RawSubFile.hpp"
#include <optional>
namespace aare {
@@ -30,12 +29,15 @@ struct ModuleConfig {
* Consider using that unless you need raw file specific functionality.
*/
class RawFile : public FileInterface {
friend class RawMasterFile;
std::vector<std::unique_ptr<RawSubFile>> m_subfiles;
ModuleConfig cfg{0, 0};
RawMasterFile m_master;
size_t m_current_frame{};
size_t m_current_subfile{};
DetectorGeometry m_geometry;
std::vector<ssize_t> m_modules_in_roi{};
public:
/**
@@ -53,10 +55,10 @@ class RawFile : public FileInterface {
void read_into(std::byte *image_buf) override;
void read_into(std::byte *image_buf, size_t n_frames) override;
//TODO! do we need to adapt the API?
// TODO! do we need to adapt the API?
void read_into(std::byte *image_buf, DetectorHeader *header);
void read_into(std::byte *image_buf, size_t n_frames, DetectorHeader *header);
void read_into(std::byte *image_buf, size_t n_frames,
DetectorHeader *header);
size_t frame_number(size_t frame_index) override;
size_t bytes_per_frame() override;
@@ -70,23 +72,21 @@ class RawFile : public FileInterface {
size_t bitdepth() const override;
xy geometry();
size_t n_modules() const;
size_t n_modules_in_roi() const;
RawMasterFile master() const;
DetectorType detector_type() const override;
private:
/**
* @brief read the frame at the given frame index into the image buffer
* @param frame_number frame number to read
* @param image_buf buffer to store the frame
*/
void get_frame_into(size_t frame_index, std::byte *frame_buffer, DetectorHeader *header = nullptr);
void get_frame_into(size_t frame_index, std::byte *frame_buffer,
DetectorHeader *header = nullptr);
/**
* @brief get the frame at the given frame index
@@ -95,8 +95,6 @@ class RawFile : public FileInterface {
*/
Frame get_frame(size_t frame_index);
/**
* @brief read the header of the file
* @param fname path to the data subfile
@@ -108,5 +106,4 @@ class RawFile : public FileInterface {
void find_geometry();
};
} // namespace aare

View File

@@ -1,5 +1,7 @@
#pragma once
// #include "aare/RawFile.hpp"
#include "aare/defs.hpp"
#include <algorithm>
#include <filesystem>
#include <fmt/format.h>
#include <fstream>
@@ -45,7 +47,7 @@ class ScanParameters {
int m_start = 0;
int m_stop = 0;
int m_step = 0;
//TODO! add settleTime, requires string to time conversion
// TODO! add settleTime, requires string to time conversion
public:
ScanParameters(const std::string &par);
@@ -61,6 +63,7 @@ class ScanParameters {
void increment_stop();
};
class RawFile; // forward declaration
/**
* @brief Class for parsing a master file either in our .json format or the old
@@ -101,7 +104,6 @@ class RawMasterFile {
std::optional<ROI> m_roi;
public:
RawMasterFile(const std::filesystem::path &fpath);
@@ -129,15 +131,14 @@ class RawMasterFile {
std::optional<size_t> number_of_rows() const;
std::optional<uint8_t> quad() const;
std::optional<ROI> roi() const;
ScanParameters scan_parameters() const;
private:
void parse_json(const std::filesystem::path &fpath);
void parse_raw(const std::filesystem::path &fpath);
void retrieve_geometry();
};
} // namespace aare