RawFile¶
-
class RawFile : public aare::FileInterface¶
Class to read .raw files. The class will parse the master file to find the correct geometry for the frames.
Note
A more generic interface is available in the aare::File class. Consider using that unless you need raw file specific functionality.
Public Functions
-
RawFile(const std::filesystem::path &fname, const std::string &mode = "r")¶
RawFile constructor.
- Parameters:
fname – path to the master file (.json)
mode – file mode (only “r” is supported at the moment)
-
virtual ~RawFile() override = default¶
-
virtual Frame read_frame(size_t frame_number) override¶
read one frame from the file at the given frame number
- Parameters:
frame_number – frame number to read
- Returns:
frame
-
virtual std::vector<Frame> read_n(size_t n_frames) override¶
read n_frames from the file at the current position
- Parameters:
n_frames – number of frames to read
- Returns:
vector of frames
-
Frame read_roi(const size_t roi_index)¶
Read one ROI defined in the master file.
Note
the frame index is incremented after calling this function so reading rois one after the other wont work.
- Parameters:
roi_index – index of the ROI to read
- Returns:
-
std::vector<Frame> read_rois()¶
Read all ROIs defined in the master file.
- Returns:
vector of Frames (one Frame per ROI)
-
std::vector<Frame> read_n_with_roi(const size_t n_frames, const size_t roi_index)¶
Read n frames for the given ROI index.
- Parameters:
n_frames – number of frames to read
roi_index – index of the ROI to read
- Returns:
vector of Frames
-
virtual void read_into(std::byte *image_buf) override¶
read one frame from the file at the current position and store it in the provided buffer
- Parameters:
image_buf – buffer to store the frame
- Returns:
void
-
virtual void read_into(std::byte *image_buf, size_t n_frames) override¶
read n_frames from the file at the current position and store them in the provided buffer
- Parameters:
image_buf – buffer to store the frames
n_frames – number of frames to read
- Returns:
void
-
void read_into(std::byte *image_buf, DetectorHeader *header = nullptr)¶
-
void read_into(std::byte *image_buf, size_t n_frames, DetectorHeader *header)¶
-
void read_roi_into(std::byte *image_buf, const size_t roi_index, const size_t frame_number, DetectorHeader *header = nullptr)¶
-
virtual size_t frame_number(size_t frame_index) override¶
get the frame number at the given frame index
- Parameters:
frame_index – index of the frame
- Returns:
frame number
-
virtual size_t bytes_per_frame() override¶
get the size of one frame in bytes
- Returns:
size of one frame
-
size_t bytes_per_frame(const size_t roi_index)¶
bytes per frame for the given ROI
- Parameters:
roi_index – index of the ROI
-
virtual size_t pixels_per_frame() override¶
get the number of pixels in one frame
- Returns:
number of pixels in one frame
-
size_t pixels_per_frame(const size_t roi_index)¶
pixels per frame for the given ROI
- Parameters:
roi_index – index of the ROI
-
size_t bytes_per_pixel() const¶
-
virtual void seek(size_t frame_index) override¶
seek to the given frame number
- Parameters:
frame_number – frame number to seek to
- Returns:
void
-
virtual size_t tell() override¶
get the current position of the file pointer
- Returns:
current position of the file pointer
-
virtual size_t total_frames() const override¶
get the total number of frames in the file
- Returns:
total number of frames in the file
-
virtual size_t rows() const override¶
get the number of rows in the file
- Returns:
number of rows in the file
-
size_t rows(const size_t roi_index) const¶
rows for the given ROI
- Parameters:
roi_index – index of the ROI
-
virtual size_t cols() const override¶
get the number of columns in the file
- Returns:
number of columns in the file
-
size_t cols(const size_t roi_index) const¶
cols for the given ROI
- Parameters:
roi_index – index of the ROI
-
virtual size_t bitdepth() const override¶
get the bitdepth of the file
- Returns:
bitdepth of the file
-
size_t n_modules() const¶
-
size_t num_rois() const¶
number of ROIs defined
-
const ROIGeometry &roi_geometries(size_t roi_index) const¶
get the ROI geometry for the given ROI index
- Parameters:
roi_index – index of the ROI
-
std::vector<size_t> n_modules_in_roi() const¶
number of modules in each ROI
-
xy geometry() const¶
-
RawMasterFile master() const¶
-
virtual DetectorType detector_type() const override¶
Public Static Functions
-
static DetectorHeader read_header(const std::filesystem::path &fname)¶
read the header of the file
- Parameters:
fname – path to the data subfile
- Returns:
DetectorHeader
Private Functions
-
void get_frame_into(size_t frame_index, std::byte *frame_buffer, const size_t roi_index = 0, DetectorHeader *header = nullptr)¶
read the frame at the given frame index into the image buffer
- Parameters:
frame_index – frame number to read
frame_buffer – buffer to store the frame
roi_index – index of the ROI to read (default is 0 e.g. full frame)
-
Frame get_frame(size_t frame_index, const size_t roi_index = 0)¶
get the frame at the given frame index
- Parameters:
frame_number – frame number to read
roi_index – index of the ROI to read (default is 0 e.g. full frame)
- Returns:
-
void open_subfiles(const size_t roi_index)¶
Private Members
-
std::vector<std::vector<std::unique_ptr<RawSubFile>>> m_subfiles¶
-
RawMasterFile m_master¶
-
size_t m_current_frame = {}¶
-
DetectorGeometry m_geometry¶
-
std::vector<ROIGeometry> m_ROI_geometries¶
Geometries e.g. number of modules, size etc. for each ROI.
-
RawFile(const std::filesystem::path &fname, const std::string &mode = "r")¶