RawFile

Reading requires frame padding to be enabled or Frame Discard Policy to be discardpartial. Construction raises RuntimeError with the master path before opening data subfiles if this requirement is not met. This applies to JSON and legacy .raw masters, including when opened through File. RawMasterFile can still be used to inspect their metadata.

total_frames and len(reader) report the minimum actual frame count across all selected subfiles and ROIs, including each subfile’s complete .raw series. read() uses this count, and read_n() and read_n_with_roi() limit batches to the remaining frames. Counts are determined when the reader is constructed. An empty subfile makes the count zero, and construction fails if no subfiles are selected.

The C++ logger prints one warning to stderr on opening if the subfile counts differ or their minimum differs from reader.master.frames_in_file. The warning includes the count range, the recorded master count, and the count used for reading. Master metadata is preserved; its expected frame count does not affect reading bounds. Detector frame-number mismatches can still cause synchronization errors within these bounds.

Reading errors raise RuntimeError with the attempted zero-based frame index and the failing file path. If a data subfile fails, its path and the underlying failure reason are reported. Out-of-range subfile errors include the available frame count across that subfile’s series. This applies to read_frame(), read_n(), and the ROI reading methods. The frame index is the position in the file, not the frame number recorded by the detector.

Synchronization errors also identify the last .raw data file read for the module that ran out of frames. An out-of-range request rejected before accessing a subfile reports the master path.

For a file containing five frames, the valid indices are 0 through 4. Attempting to read index 5 raises an error stating: Frame index 5 is out of range: file contains 5 frames (indices are zero-based).

class aare.RawFile(fname, chunk_size=1)

Bases: RawFile

property bitdepth
bytes_per_frame(*args, **kwargs)

Overloaded function.

  1. bytes_per_frame(self: aare._aare.RawFile) -> int

  2. bytes_per_frame(self: aare._aare.RawFile, arg0: typing.SupportsInt | typing.SupportsIndex) -> int

    Bytes per frame for the given ROI.

property bytes_per_pixel
cols(*args, **kwargs)

Overloaded function.

  1. cols(self: aare._aare.RawFile) -> int

  2. cols(self: aare._aare.RawFile, arg0: typing.SupportsInt | typing.SupportsIndex) -> int

    Cols for the given ROI.

property detector_type
frame_number(self: aare._aare.RawFile, arg0: SupportsInt | SupportsIndex) → int
property geometry
property master

Return the master file.

Returns:

Master file.

Return type:

RawMasterFile

property n_modules
property n_modules_in_roi
property num_rois
pixels_per_frame(*args, **kwargs)

Overloaded function.

  1. pixels_per_frame(self: aare._aare.RawFile) -> int

  2. pixels_per_frame(self: aare._aare.RawFile, arg0: typing.SupportsInt | typing.SupportsIndex) -> int

    Pixels per frame for the given ROI.

read() → tuple

Read the entire file. Seeks to the beginning of the file before reading.

Returns:

header, data

Return type:

tuple

read_frame(self: aare._aare.RawFile) → tuple[numpy.typing.NDArray[aare::DetectorHeader], numpy.ndarray]
read_n(self: aare._aare.RawFile, arg0: SupportsInt | SupportsIndex) → tuple[numpy.typing.NDArray[aare::DetectorHeader], numpy.ndarray]

Read n frames from the file.

read_n_with_roi(self: aare._aare.RawFile, num_frames: SupportsInt | SupportsIndex, *, roi_index: SupportsInt | SupportsIndex) → tuple[numpy.typing.NDArray[aare::DetectorHeader], numpy.ndarray]

Read n frames for a specific ROI

Parameters:
  • num_frames (int) – Number of frames to read.

  • roi_index (int) – Index of the ROI to read.

Return type:

three dimensional numpy.ndarray.

read_roi(self: aare._aare.RawFile, roi_index: SupportsInt | SupportsIndex) → tuple[numpy.typing.NDArray[aare::DetectorHeader], numpy.ndarray]

Read one ROI from the current frame.

Parameters:

roi_index (int) – Index of the ROI to read.

Notes

The method advances the frame number, so reading ROIs one after the other won’t work.

Return type:

tuple (header, image)

read_rois(self: aare._aare.RawFile) → tuple[list[numpy.typing.NDArray[aare::DetectorHeader]], list[numpy.ndarray]]

Read all ROIs for specific frame.

Parameters:
  • frame_number (int) – Frame number to read.

  • roi_index (Optional[int]) – Index of the ROI to read. If not provided, all ROIs are read.

Returns:

One array per ROI.

Return type:

list of numpy.ndarray

rows(*args, **kwargs)

Overloaded function.

  1. rows(self: aare._aare.RawFile) -> int

  2. rows(self: aare._aare.RawFile, arg0: typing.SupportsInt | typing.SupportsIndex) -> int

    Rows for the given ROI.

property scan_parameters

Return the scan parameters.

Returns:

Scan parameters.

Return type:

ScanParameters

seek(self: aare._aare.RawFile, arg0: SupportsInt | SupportsIndex) → None

Seek to a frame index in file.

tell(self: aare._aare.RawFile) → int

Return the current frame number.

property total_frames