pleiades.processing.models_ornl module

ORNL-specific data models for neutron imaging normalization at VENUS.

This module defines data structures for the ORNL/VENUS neutron imaging processing pipeline. These models represent raw measurement data and calculated transmission spectra used in the normalization process.

The models use Pydantic v2 for validation and serialization while efficiently handling numpy arrays for numerical data.

class pleiades.processing.models_ornl.Run(*, counts: ~numpy.ndarray, proton_charge: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)], shutter_counts: ~numpy.ndarray | None = None, dead_pixel_mask: ~numpy.ndarray | None = None, metadata: ~typing.Dict[str, ~typing.Any] = <factory>)[source]

Bases: BaseModel

Container for a single measurement run (sample or open beam).

This represents data from a single run at the VENUS beamline, containing detector counts, beam monitoring data, and metadata.

counts

3D array of detector counts with shape (tof, y, x)

Type:

numpy.ndarray

proton_charge

Total integrated proton charge in microCoulombs

Type:

float

shutter_counts

Optional 1D array of shutter monitor counts per TOF bin

Type:

numpy.ndarray | None

dead_pixel_mask

Optional 2D boolean mask where True indicates dead pixels

Type:

numpy.ndarray | None

metadata

Dictionary containing run_number, folder, timestamp, etc.

Type:

Dict[str, Any]

model_config = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

counts: ndarray
proton_charge: float
shutter_counts: ndarray | None
dead_pixel_mask: ndarray | None
metadata: Dict[str, Any]
classmethod validate_counts_shape(v: ndarray) ndarray[source]

Ensure counts is a 3D array.

classmethod validate_shutter_shape(v: ndarray | None) ndarray | None[source]

Ensure shutter_counts is 1D if provided.

classmethod validate_dead_mask_shape(v: ndarray | None) ndarray | None[source]

Ensure dead_pixel_mask is 2D boolean if provided.

get_tof_range() Tuple[int, int, int][source]

Return (n_tof, n_y, n_x) shape of the counts array.

class pleiades.processing.models_ornl.Transmission(*, energy: ~numpy.ndarray, transmission: ~numpy.ndarray, uncertainty: ~numpy.ndarray, roi: ~pleiades.processing.Roi | None = None, roi_center: ~typing.Tuple[float, float], metadata: ~typing.Dict[str, ~typing.Any] = <factory>)[source]

Bases: BaseModel

Container for calculated transmission spectrum.

This represents the normalized transmission data ready for SAMMY fitting, containing the transmission spectrum, uncertainties, and processing metadata.

energy

1D array of neutron energies in eV

Type:

numpy.ndarray

transmission

1D array of transmission values (typically 0-1)

Type:

numpy.ndarray

uncertainty

1D array of transmission uncertainties

Type:

numpy.ndarray

roi

Optional ROI used for spatial selection

Type:

pleiades.processing.Roi | None

roi_center

(x, y) coordinates of the ROI center

Type:

Tuple[float, float]

metadata

Processing parameters, source runs, etc.

Type:

Dict[str, Any]

model_config = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

energy: ndarray
transmission: ndarray
uncertainty: ndarray
roi: Roi | None
roi_center: Tuple[float, float]
metadata: Dict[str, Any]
classmethod validate_1d_arrays(v: ndarray, info) ndarray[source]

Ensure arrays are 1D.

classmethod validate_transmission_range(v: ndarray) ndarray[source]

Warn if transmission values are outside typical range.

classmethod validate_positive_uncertainty(v: ndarray) ndarray[source]

Ensure uncertainties are non-negative.

model_post_init(_Transmission__context) None[source]

Validate array length consistency after initialization.

to_dat_format() ndarray[source]

Export as 3-column array for SAMMY .dat file.

Energy values are sorted in increasing order as required by SAMMY.

Returns:

  • Column 0: Energy in eV (increasing order)

  • Column 1: Transmission (0-1)

  • Column 2: Uncertainty (0-1)

Return type:

Array with shape (n_points, 3) containing

save_dat(filepath: str) None[source]

Save transmission data in SAMMY .dat format.

Data is automatically sorted by increasing energy as required by SAMMY.

Parameters:

filepath – Path to output .dat file