AARE
Data analysis library for PSI hybrid detectors
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes
aare::RawFile Class Reference

RawFile class to read .raw and .json files. More...

#include <RawFile.hpp>

Inheritance diagram for aare::RawFile:
aare::FileInterface

Public Member Functions

 RawFile (const std::filesystem::path &fname, const std::string &mode="r", const FileConfig &cfg={})
 RawFile constructor.
 
void write (Frame &frame) override
 write function is not implemented for RawFile
 
Frame read () override
 write a vector of frames to the file
 
std::vector< Frameread (size_t n_frames) override
 read n_frames from the file at the current position
 
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
 
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
 
size_t frame_number (size_t frame_index) override
 get the frame number at the given frame index
 
size_t bytes_per_frame () override
 get the number of bytess per frame
 
size_t pixels () override
 get the number of pixels in the frame
 
void seek (size_t frame_number) override
 seek to the given frame number
 
size_t tell () override
 get the current position of the file pointer
 
void set_config (int row, int col)
 set the module gap row and column
 
void find_number_of_subfiles ()
 get the number of subfiles for the RawFile
 
std::filesystem::path master_fname ()
 get the master file name path for the RawFile
 
std::filesystem::path data_fname (int mod_id, int file_id)
 get the data file name path for the RawFile with the given module id and file id
 
 ~RawFile ()
 destructor: will delete the subfiles
 
size_t total_frames () const override
 get the total number of frames in the file
 
ssize_t rows () const override
 get the number of rows in the file
 
ssize_t cols () const override
 get the number of columns in the file
 
ssize_t bitdepth () const override
 get the bitdepth of the file
 
Frame iread (size_t frame_number)
 read one frame from the file at the given frame number
 
std::vector< Frameiread (size_t frame_number, size_t n_frames)
 read n_frames from the file starting at the given frame number
 

Static Public Member Functions

static bool is_master_file (std::filesystem::path fpath)
 check if the file is a master file
 

Data Fields

std::string m_mode
 
std::filesystem::path m_fname
 
std::filesystem::path m_base_path
 
std::string m_base_name
 
std::string m_ext
 
int m_findex
 
size_t m_total_frames {}
 
size_t max_frames_per_file {}
 
std::string version
 
DetectorType m_type
 
ssize_t m_rows {}
 
ssize_t m_cols {}
 
ssize_t m_bitdepth {}
 
size_t current_frame {}
 

Private Member Functions

void get_frame_into (size_t frame_number, std::byte *image_buf)
 read the frame at the given frame number into the image buffer
 
Frame get_frame (size_t frame_number)
 get the frame at the given frame number
 
void parse_fname ()
 parse the file name to get the extension, base name and index
 
void parse_metadata ()
 parse the metadata from the file
 
void parse_raw_metadata ()
 parse the metadata of a .raw file
 
void parse_json_metadata ()
 parse the metadata of a .json file
 
void find_geometry ()
 finds the geometry of the file
 
sls_detector_header read_header (const std::filesystem::path &fname)
 read the header of the file
 
void open_subfiles ()
 open the subfiles
 

Private Attributes

size_t n_subfiles
 
size_t n_subfile_parts
 
std::vector< std::vector< SubFile * > > subfiles
 
int subfile_rows
 
int subfile_cols
 
xy geometry
 
std::vector< xypositions
 
RawFileConfig cfg {0, 0}
 
TimingMode timing_mode
 
bool quad {false}
 

Detailed Description

RawFile class to read .raw and .json files.

Note
derived from FileInterface
documentation can also be found in the FileInterface class

Constructor & Destructor Documentation

◆ RawFile()

aare::RawFile::RawFile ( const std::filesystem::path &  fname,
const std::string &  mode = "r",
const FileConfig cfg = {} 
)

RawFile constructor.

Parameters
fnamepath to the file
modefile mode (r, w)
cfgfile configuration

◆ ~RawFile()

aare::RawFile::~RawFile ( )

destructor: will delete the subfiles

Member Function Documentation

◆ bitdepth()

ssize_t aare::RawFile::bitdepth ( ) const
inlineoverridevirtual

get the bitdepth of the file

Returns
bitdepth of the file

Implements aare::FileInterface.

◆ bytes_per_frame()

size_t aare::RawFile::bytes_per_frame ( )
inlineoverridevirtual

get the number of bytess per frame

Returns
size of one frame in bytes

Implements aare::FileInterface.

◆ cols()

ssize_t aare::RawFile::cols ( ) const
inlineoverridevirtual

get the number of columns in the file

Returns
number of columns in the file

Implements aare::FileInterface.

◆ data_fname()

std::filesystem::path aare::RawFile::data_fname ( int  mod_id,
int  file_id 
)
inline

get the data file name path for the RawFile with the given module id and file id

Parameters
mod_idmodule id
file_idfile id
Returns
path to the data file

◆ find_geometry()

void aare::RawFile::find_geometry ( )
private

finds the geometry of the file

◆ find_number_of_subfiles()

void aare::RawFile::find_number_of_subfiles ( )

get the number of subfiles for the RawFile

Returns
number of subfiles

◆ frame_number()

size_t aare::RawFile::frame_number ( size_t  frame_index)
overridevirtual

get the frame number at the given frame index

Parameters
frame_indexindex of the frame
Returns
frame number

Implements aare::FileInterface.

◆ get_frame()

Frame aare::RawFile::get_frame ( size_t  frame_number)
private

get the frame at the given frame number

Parameters
frame_numberframe number to read
Returns
Frame

◆ get_frame_into()

void aare::RawFile::get_frame_into ( size_t  frame_number,
std::byte *  image_buf 
)
private

read the frame at the given frame number into the image buffer

Parameters
frame_numberframe number to read
image_bufbuffer to store the frame

◆ iread() [1/2]

Frame aare::FileInterface::iread ( size_t  frame_number)
inlineinherited

read one frame from the file at the given frame number

Parameters
frame_numberframe number to read
Returns
frame

◆ iread() [2/2]

std::vector< Frame > aare::FileInterface::iread ( size_t  frame_number,
size_t  n_frames 
)
inlineinherited

read n_frames from the file starting at the given frame number

Parameters
frame_numberframe number to start reading from
n_framesnumber of frames to read
Returns
vector of frames

◆ is_master_file()

bool aare::RawFile::is_master_file ( std::filesystem::path  fpath)
static

check if the file is a master file

Parameters
fpathpath to the file

◆ master_fname()

std::filesystem::path aare::RawFile::master_fname ( )
inline

get the master file name path for the RawFile

Returns
path to the master file

◆ open_subfiles()

void aare::RawFile::open_subfiles ( )
private

open the subfiles

◆ parse_fname()

void aare::RawFile::parse_fname ( )
private

parse the file name to get the extension, base name and index

◆ parse_json_metadata()

void aare::RawFile::parse_json_metadata ( )
private

parse the metadata of a .json file

◆ parse_metadata()

void aare::RawFile::parse_metadata ( )
private

parse the metadata from the file

◆ parse_raw_metadata()

void aare::RawFile::parse_raw_metadata ( )
private

parse the metadata of a .raw file

◆ pixels()

size_t aare::RawFile::pixels ( )
inlineoverridevirtual

get the number of pixels in the frame

Returns
number of pixels

Implements aare::FileInterface.

◆ read() [1/2]

Frame aare::RawFile::read ( )
inlineoverridevirtual

write a vector of frames to the file

Parameters
framesvector of frames to write
Returns
void

read one frame from the file at the current position

Returns
Frame

Implements aare::FileInterface.

◆ read() [2/2]

std::vector< Frame > aare::RawFile::read ( size_t  n_frames)
overridevirtual

read n_frames from the file at the current position

Parameters
n_framesnumber of frames to read
Returns
vector of frames

Implements aare::FileInterface.

◆ read_header()

sls_detector_header aare::RawFile::read_header ( const std::filesystem::path &  fname)
private

read the header of the file

Parameters
fnamepath to the data subfile
Returns
sls_detector_header

◆ read_into() [1/2]

void aare::RawFile::read_into ( std::byte *  image_buf)
inlineoverridevirtual

read one frame from the file at the current position and store it in the provided buffer

Parameters
image_bufbuffer to store the frame
Returns
void

Implements aare::FileInterface.

◆ read_into() [2/2]

void aare::RawFile::read_into ( std::byte *  image_buf,
size_t  n_frames 
)
overridevirtual

read n_frames from the file at the current position and store them in the provided buffer

Parameters
image_bufbuffer to store the frames
n_framesnumber of frames to read
Returns
void

Implements aare::FileInterface.

◆ rows()

ssize_t aare::RawFile::rows ( ) const
inlineoverridevirtual

get the number of rows in the file

Returns
number of rows in the file

Implements aare::FileInterface.

◆ seek()

void aare::RawFile::seek ( size_t  frame_number)
inlineoverridevirtual

seek to the given frame number

Parameters
frame_numberframe number to seek to
Returns
void

Implements aare::FileInterface.

◆ set_config()

void aare::RawFile::set_config ( int  row,
int  col 
)
inline

set the module gap row and column

Parameters
rowgap between rows
colgap between columns

◆ tell()

size_t aare::RawFile::tell ( )
inlineoverridevirtual

get the current position of the file pointer

Returns
current position of the file pointer

Implements aare::FileInterface.

◆ total_frames()

size_t aare::RawFile::total_frames ( ) const
inlineoverridevirtual

get the total number of frames in the file

Returns
total number of frames in the file

Implements aare::FileInterface.

◆ write()

void aare::RawFile::write ( Frame frame)
inlineoverridevirtual

write function is not implemented for RawFile

Parameters
frameframe to write

Implements aare::FileInterface.

Field Documentation

◆ cfg

RawFileConfig aare::RawFile::cfg {0, 0}
private

◆ current_frame

size_t aare::FileInterface::current_frame {}
inherited

◆ geometry

xy aare::RawFile::geometry
private

◆ m_base_name

std::string aare::FileInterface::m_base_name
inherited

◆ m_base_path

std::filesystem::path aare::FileInterface::m_base_path
inherited

◆ m_bitdepth

ssize_t aare::FileInterface::m_bitdepth {}
inherited

◆ m_cols

ssize_t aare::FileInterface::m_cols {}
inherited

◆ m_ext

std::string aare::FileInterface::m_ext
inherited

◆ m_findex

int aare::FileInterface::m_findex
inherited

◆ m_fname

std::filesystem::path aare::FileInterface::m_fname
inherited

◆ m_mode

std::string aare::FileInterface::m_mode
inherited

◆ m_rows

ssize_t aare::FileInterface::m_rows {}
inherited

◆ m_total_frames

size_t aare::FileInterface::m_total_frames {}
inherited

◆ m_type

DetectorType aare::FileInterface::m_type
inherited

◆ max_frames_per_file

size_t aare::FileInterface::max_frames_per_file {}
inherited

◆ n_subfile_parts

size_t aare::RawFile::n_subfile_parts
private

◆ n_subfiles

size_t aare::RawFile::n_subfiles
private

◆ positions

std::vector<xy> aare::RawFile::positions
private

◆ quad

bool aare::RawFile::quad {false}
private

◆ subfile_cols

int aare::RawFile::subfile_cols
private

◆ subfile_rows

int aare::RawFile::subfile_rows
private

◆ subfiles

std::vector<std::vector<SubFile *> > aare::RawFile::subfiles
private

◆ timing_mode

TimingMode aare::RawFile::timing_mode
private

◆ version

std::string aare::FileInterface::version
inherited

The documentation for this class was generated from the following files: