CHAP.common.models package

Submodules

CHAP.common.models.common module

Common Pydantic model classes.

class BinarizeConfig(*, method: Literal['CHAP', 'isodata', 'minimum', 'otsu', 'yen'] | None = 'CHAP', num_bin: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = 256, nxpath: str | None = None, remove_original_data: bool | None = False)

Bases: CHAPBaseModel

Configuration class to binarize a dataset in a 2D or 3D array-like object or a NeXus NXdata or NXfield object.

Parameters:
  • method (Literal['CHAP', 'isodata', 'minimum', 'otsu', 'yen']) – Binarization method, defaults to ‘CHAP’ (CHAP’s internal implementation of Otzu’s method).

  • num_bin (int, optional) – The number of bins used to calculate the histogram in the binarization algorithms, defaults to 256.

  • nxpath (str, optional) – The path to a specific NeXus NXdata or NXfield object in the NeXus file tree to read the input data from (ignored for non-NeXus input objects).

  • remove_original_data (bool, optional) – Removes the original data field (ignored for non-NeXus input objects), defaults to False.

method: Literal['CHAP', 'isodata', 'minimum', 'otsu', 'yen'] | None
model_config: ClassVar[ConfigDict] = {}

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

num_bin: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None
nxpath: str | None
remove_original_data: bool | None
class ImageProcessorConfig(*, animation: bool | None = False, axis: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = 0, coord_range: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=3)] | None = None, index_range: int | Annotated[list[None | int], Len(min_length=2, max_length=3)] | None = None, fileformat: Literal['gif', 'jpeg', 'png', 'tif'] | None = None, vrange: Annotated[list[None | Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration of various image selection and visualization types of processors.

Parameters:
  • animation (bool, optional) – Create an animation for an image stack (ignored for a single image), defaults to False.

  • axis (Union[int, str], optional) – Axis direction or name for the image slice(s), defaults to 0.

  • coord_range (Union[float, list[float]], optional) – Coordinate value range of the selected image slice(s), up to three floating point numbers (start, end, step), defaults to None, which enables index_range to select the image slice(s). Include only coord_range or index_range, not both.

  • index_range (Union[int, list[int]], optional) – Array index range of the selected image slice(s), up to three integers (start, end, step). Set index_range to -1 to select the center image slice of an image stack in the axis direction. Only used when coord_range = None. Defaults to None, which will include all slices.

  • vrange (list[float, float]) – Data value range in image slice(s), defaults to None, which uses the full data value range in the slice(s). Specify as [None, float] or [float, None] to set only the upper or lower limit of the value range.

Variables:

fileformat – Image (stack) return file type, defaults to ‘png’ for a single image, ‘tif’ for an image stack, or ‘gif’ for an animation.

animation: bool | None
axis: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None
coord_range: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=3)] | None
fileformat: Literal['gif', 'jpeg', 'png', 'tif'] | None
index_range: int | Annotated[list[None | int], Len(min_length=2, max_length=3)] | None
model_config: ClassVar[ConfigDict] = {}

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

classmethod validate_index_range(index_range)

Validate the index_range.

Variables:

index_range – Array index range of the selected image slice(s), defaults to None..

Returns:

Validated index_range.

Return type:

list[int]

classmethod validate_vrange(vrange)

Validate the vrange.

Variables:

vrange – Data value range in image slice(s), defaults to None..

Returns:

Validated vrange.

Return type:

list[float, float]

vrange: Annotated[list[None | Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None
class UnstructuredToStructuredConfig(*, nxpath: str | None = None, signals: str | Annotated[list[str], Len(min_length=1, max_length=None)] | None = None, unstructured_axes: str | Annotated[list[str], Len(min_length=1, max_length=None)] | None = None)

Bases: CHAPBaseModel

Configuration class to reshape data in an NXdata from an “unstructured” to a “structured” representation.

Parameters:
  • nxpath (str, optional) – Path to a specific NeXus NXdata object in the NeXus file tree to read the input data from.

  • signals (Union[str, list[str]], optional) – Paths to the dataset’s signal-like fields to reshape (in addition to possible ones in the optional nxpath object).

  • unstructured_axes (Union[str, list[str]], optional) – Names of the dataset’s unstructured axes fields. Defaults to the ‘unstructured axis’ attribute of the default NeXus NXdata object or that specified in nxpath if present. If nxpath is unspecified and there is no default NeXus NXdata object, the unstructured_axes is required and has to contain full paths to the unstructured axes fields.

model_config: ClassVar[ConfigDict] = {}

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

nxpath: str | None
signals: str | Annotated[list[str], Len(min_length=1, max_length=None)] | None
unstructured_axes: str | Annotated[list[str], Len(min_length=1, max_length=None)] | None
classmethod validate_nxpath(nxpath)

Validate nxpath.

Parameters:

nxpath (str) – Path to a specific NeXus NXdata object in the NeXus file tree to read the input data from.

Returns:

nxpath.

Return type:

str

classmethod validate_signals(signals)

Validate signals.

Parameters:

signals (Union[str, list[str]]) – The (additional) dataset’s signal-like fields.

Returns:

signals.

Return type:

list[str]

classmethod validate_unstructured_axes(unstructured_axes)

Validate unstructured_axes.

Parameters:

unstructured_axes (Union[str, list[str]]) – The dataset’s unstructured axes

Returns:

unstructured_axes.

Return type:

list[str]

CHAP.common.models.integration module

pyFAI integration related Pydantic model classes.

class AzimuthalIntegratorConfig(*, id: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], shape: tuple[int, int] | None = None, attrs: Annotated[dict, FieldInfo(annotation=NoneType, required=True, validate_default=True)] | None = {}, mask_file: Annotated[Path, PathType(path_type=file)] | None = None, params: dict | None = None, poni_file: Annotated[Path, PathType(path_type=file)] | None = None)

Bases: Detector, CHAPBaseModel

Azimuthal integrator configuration class to represent a single detector used in the experiment.

Parameters:
  • mask_file (FilePath, optional) – Path to the mask file.

  • poni_file (FilePath, optional) – Path to the PONI file, specify either poni_file or params, not both.

  • params (dict, optional) – Azimuthal integrator configuration parameters, specify either poni_file or params, not both.

property ai

Return the azimuthal integrator.

property mask_data

Return the mask array to use for this detector from the data in the file specified with the mask_file field. Return None if mask_file is None.

mask_file: Annotated[Path, PathType(path_type=file)] | None
model_config: ClassVar[ConfigDict] = {}

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

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

params: dict | None
poni_file: Annotated[Path, PathType(path_type=file)] | None
validate_ai()

Set the default azimuthal integrator.

Returns:

Validated configuration class.

Return type:

AzimuthalIntegratorConfig

classmethod validate_root(data)

Make sure data contains either poni_file _or_ params, not both, and that the field that is used defines a valid pyFAI.azimuthalIntegrator.AzimuthalIntegrator object.

class Integrate1dConfig(*, error_model: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, attrs: dict | None = {}, method: str | Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]], Len(min_length=3, max_length=3)] | None = None, npt: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 1800)

Bases: IntegrateConfig

Class with the input parameters to perform 1D azimuthal integration with pyFAI.

Variables:
  • method – For pyFAI.azimuthalIntegrator.AzimuthalIntegrator a registered integration method or a 3-tuple (splitting, algorithm, implementation), defaults to csr. For pyFAI.multi_geometry.MultiGeometry a registered integration method, defaults to splitpixel.

  • npt – Number of integration points, defaults to 1800.

method: str | Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]], Len(min_length=3, max_length=3)] | None
model_config: ClassVar[ConfigDict] = {}

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

npt: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
class Integrate2dConfig(*, error_model: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, attrs: dict | None = {}, method: str | None = None, npt_azim: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 3600, npt_rad: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 1800)

Bases: IntegrateConfig

Class with the input parameters to perform 2D azimuthal (cake) integration with pyFAI.

Variables:
  • method – Registered integration method, defaults to bbox for pyFAI.azimuthalIntegrator.AzimuthalIntegrator or splitpixel for pyFAI.multi_geometry.MultiGeometry.

  • npt_azim – Number of points for the integration in the azimuthal direction, defaults to 3600.

  • npt_rad – Number of points for the integration in the radial direction, defaults to 1800.

method: str | None
model_config: ClassVar[ConfigDict] = {}

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

npt_azim: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
npt_rad: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
class IntegrateConfig(*, error_model: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, attrs: dict | None = {})

Bases: CHAPBaseModel

Class with the input parameters to perform various integrations with pyFAI.

Variables:

error_model – When the variance is unknown, an error model can be given (ignored for radial integration): poisson (variance = I) or azimuthal (variance = (I-<I>)^2).

attrs: dict | None
error_model: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None
model_config: ClassVar[ConfigDict] = {}

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

class IntegrateRadialConfig(*, ais: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]], Len(min_length=1, max_length=None)], azimuth_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=-180, lt=None, le=360), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = [-180.0, 180.0], radial_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=180), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = [0.0, 180.0], unit: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = 'q_A^-1', chi_disc: int | None = 180, empty: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 0.0, wavelength: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, error_model: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, attrs: dict | None = {}, radial_unit: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = 'q_A^-1', method: str | None = 'csr', npt: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 1800)

Bases: IntegrateConfig, MultiGeometryConfig

Class with the input parameters to perform radial integration with pyFAI.

Variables:
  • method – Registered integration method, defaults to csr.

  • radial_unit – Unit used for radial representation, defaults to ‘q_A^-1’.

  • npt – Number of integration points, defaults to 1800.

method: str | None
model_config: ClassVar[ConfigDict] = {}

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

npt: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
radial_unit: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None
class MultiGeometryConfig(*, ais: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]], Len(min_length=1, max_length=None)], azimuth_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=-180, lt=None, le=360), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = [-180.0, 180.0], radial_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=180), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = [0.0, 180.0], unit: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = 'q_A^-1', chi_disc: int | None = 180, empty: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 0.0, wavelength: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration for treating simultaneously multiple detector configuration within a single integration

Variables:
  • ais – List of detector IDs of azimuthal integrators.

  • azimuth_range – Common azimuthal range for integration, defaults to [-180.0, 180.0].

  • radial_range – Common range for integration, defaults to [0.0, 180.0].

  • unit – Output unit, defaults to ‘q_A^-1’.

ais: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]], Len(min_length=1, max_length=None)]
azimuth_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=-180, lt=None, le=360), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None
chi_disc: int | None
empty: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
model_config: ClassVar[ConfigDict] = {}

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

radial_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=180), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None
unit: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None
classmethod validate_ais(ais)

Validate the detector IDs of the azimuthal integrators.

Parameters:

ais (str, list[str]) – The detector IDs.

Returns:

The detector ais.

Return type:

list[str]

wavelength: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
class PyfaiIntegrationConfig(*, azimuthal_integrators: Annotated[list[AzimuthalIntegratorConfig], Len(min_length=1, max_length=None)] | None = None, integrations: Annotated[list[PyfaiIntegratorConfig], Len(min_length=1, max_length=None)], sum_axes: bool | None = False)

Bases: CHAPBaseModel

Class defining components needed for performing one or more integrations on the same set of 2D input data with saxswaxs.PyfaiIntegrationProcessor.

azimuthal_integrators: Annotated[list[AzimuthalIntegratorConfig], Len(min_length=1, max_length=None)] | None
integrations: Annotated[list[PyfaiIntegratorConfig], Len(min_length=1, max_length=None)]
model_config: ClassVar[ConfigDict] = {}

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

sum_axes: bool | None
classmethod validate_config(data)

Ensure that a valid configuration was provided and finalize PONI filepaths.

Parameters:

data (GiwaxsConversionConfig, pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator data object.

Returns:

The currently validated list of class properties.

Return type:

dict

zarr_tree(dataset_shape, dataset_chunks='auto')

Return a dictionary representing a zarr.group that can be used to contain results from saxswaxs.PyfaiIntegrationProcessor.

class PyfaiIntegratorConfig(*, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], integration_method: Literal['integrate1d', 'integrate2d', 'integrate_radial'], multi_geometry: MultiGeometryConfig | None = None, integration_params: Integrate1dConfig | Integrate2dConfig | IntegrateRadialConfig | None = None, right_handed: bool = True)

Bases: CHAPBaseModel

Class representing the configuration for detector data integrator for pyFAI.

Variables:

right_handed – For radial and cake integration, reverse the direction of the azimuthal coordinate from pyFAI’s convention, defaults to True.

get_axes_indices(dataset_ndims)

Return the index of each coordinate orienting a single frame of results from this integration.

get_placeholder_data(ais)

Return empty input data of the correct shape for use in init_placeholder_data.

init_placeholder_results(ais)

Get placeholder results for this integration so we can fill in the datasets for results of coordinates when setting up a zarr tree for holding results of saxswaxs.PyfaiIntegrationProcessor.

integrate(azimuthal_integrators, data)

Perform the integration and return the results.

Parameters:
  • azimuthal_integrators (list[AzimuthalIntegratorConfig]) – List of single-detector integrator configurations.

  • data (dict[str, np.ndarray]) – Dictionary of 2D detector frames to be integrated.

Returns:

Integrated intensities and coordinates for every frame (or set of frames) in input_data.

Return type:

dict[str, object]

integration_method: Literal['integrate1d', 'integrate2d', 'integrate_radial']
integration_params: Integrate1dConfig | Integrate2dConfig | IntegrateRadialConfig | None
model_config: ClassVar[ConfigDict] = {}

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

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

multi_geometry: MultiGeometryConfig | None
name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
property result_coords

Return a dictionary representing the zarr.array objects for the coordinates of a single frame of results from this integration.

property result_shape

Return shape of one frame of results from this integration.

right_handed: bool
classmethod validate_config(data)

Validate the input integration configuration.

Parameters:

data (PyfaiIntegratorConfig, pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator data object.

Returns:

The currently validated list of class properties.

Return type:

dict

zarr_tree(dataset_shape, dataset_chunks='auto')

Return a dictionary representing a zarr.group that can be used to contain results from this integration.

CHAP.common.models.map module

Map related Pydantic model classes.

class CHAPSlice(*, start: int | None = 0, end: int | None = None, step: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 1)

Bases: CHAPBaseModel

Class representing a slice configuration for any particular dimension of a data set.

Variables:
  • start – Starting index for slicing, defaults to 0.

  • end – Ending index for slicing, defaults to -1.

  • step – Slicing step, defaults to 1.

end: int | None
model_config: ClassVar[ConfigDict] = {}

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

start: int | None
step: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
tolist()
toslice()
class CorrectionsData(*, label: Literal['presample_intensity', 'postsample_intensity', 'dwell_time_actual'], units: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], data_type: Literal['scan_column', 'smb_par'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None)

Bases: PointByPointScanData

Class representing the special instances of PointByPointScanData that are used by certain kinds of CorrectionConfig tools.

Variables:
  • label – One of the reserved values required by CorrectionConfig.

  • data_type – Represents how these data were recorded at time of data collection.

data_type: Literal['scan_column', 'smb_par']
label: Literal['presample_intensity', 'postsample_intensity', 'dwell_time_actual']
model_config: ClassVar[ConfigDict] = {}

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

classmethod reserved_labels()

Return a list of all the labels reserved for corrections-related scalar data.

Returns:

A list of reserved labels.

Return type:

list[str]

class Detector(*, id: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], shape: tuple[int, int] | None = None, attrs: Annotated[dict, FieldInfo(annotation=NoneType, required=True, validate_default=True)] | None = {})

Bases: CHAPBaseModel

Class representing a single detector.

Variables:
  • id – The detector id (e.g. name or channel index).

  • shape – Shape of detector’s raw data.

  • attrs – Additional detector configuration attributes.

attrs: Annotated[dict, FieldInfo(annotation=NoneType, required=True, validate_default=True)] | None
get_id()
id_: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
model_config: ClassVar[ConfigDict] = {}

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

shape: tuple[int, int] | None
classmethod validate_attrs(attrs)

Validate any additional detector configuration attributes.

Parameters:

attrs (dict) – Any additional attributes to Detector.

Raises:

ValueError – Invalid attribute.

Returns:

The validated field for attrs.

Return type:

dict

classmethod validate_id(id_)

Validate the detector id.

Parameters:

id (int, str) – The detector id (e.g. name or channel index).

Returns:

The detector id.

Return type:

str

class DetectorConfig(*, detectors: Annotated[list[Detector], Len(min_length=0, max_length=None)], roi: Annotated[list[CHAPSlice], Len(min_length=2, max_length=2)] | None = None)

Bases: CHAPBaseModel

Class representing a detector configuration.

Variables:
  • detectors – Detector list.

  • roi – Detector ROI.

detectors: Annotated[list[Detector], Len(min_length=0, max_length=None)]
model_config: ClassVar[ConfigDict] = {}

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

roi: Annotated[list[CHAPSlice], Len(min_length=2, max_length=2)] | None
classmethod validate_roi(roi)

Validate the detector ROI.

Parameters:

roi (list[CHAPSlice, CHAPSlice]) – Detector ROI.

Returns:

The validated detector ROI

Return type:

list[CHAPSlice, CHAPSlice]

class DwellTimeActual(*, label: Literal['dwell_time_actual'] = 'dwell_time_actual', units: Literal['s'] = 's', data_type: Literal['scan_column', 'smb_par'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None)

Bases: CorrectionsData

Class representing a source of raw data for the actual dwell time at each scan point in SPEC (with some scan types, this value can vary slightly point-to-point from the dwell time specified in the command).

Variables:
  • label – Must be ‘dwell_time_actual’.

  • units – Must be ‘s’.

label: Literal['dwell_time_actual']
model_config: ClassVar[ConfigDict] = {}

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

units: Literal['s']
class IndependentDimension(*, label: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], units: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], data_type: Literal['spec_motor', 'spec_motor_absolute', 'scan_column', 'smb_par', 'expression', 'detector_log_timestamps'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None, start: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = 0, end: int | None = None, step: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 1)

Bases: PointByPointScanData

Class representing the source of data to identify the coordinate values along one dimension of a MapConfig.

Variables:
  • start – Sarting index for slicing all datasets of a MapConfig along this axis, defaults to 0.

  • end – Ending index for slicing all datasets of a MapConfig along this axis, defaults to the total number of unique values along this axis in the associated MapConfig.

  • step – Step for slicing all datasets of a MapConfig along this axis, defaults to 1.

end: int | None
model_config: ClassVar[ConfigDict] = {}

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

start: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None
step: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
class MapConfig(*, validate_data_present: bool = True, did: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=None)] | None = None, title: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], station: Literal['id1a3', 'id3a', 'id3b', 'id4b'], experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM'], sample: Sample, spec_scans: Annotated[list[SpecScans], Len(min_length=1, max_length=None)], scalar_data: Annotated[list[PointByPointScanData], Len(min_length=0, max_length=None)] | None = [], independent_dimensions: Annotated[list[IndependentDimension], Len(min_length=1, max_length=None)], presample_intensity: PresampleIntensity | None = None, dwell_time_actual: DwellTimeActual | None = None, postsample_intensity: PostsampleIntensity | None = None, attrs: dict = {})

Bases: CHAPBaseModel

Class representing an experiment consisting of one or more SPEC scans.

Param:

did: FOXDEN data identifier.

Variables:
  • title – The title for the map configuration.

  • station – The name of the station at which the map was collected.

  • experiment_type – Experiment type.

  • sample – The sample metadata configuration.

  • spec_scans – A list of the SPEC scans that compose the map.

  • scalar_data – A list of the sources of data representing other scalar raw data values collected at each point on the map. In the NeXus file representation of the map, datasets for these values will be included, defaults to [].

  • independent_dimensions – A list of the sources of data representing the raw values of each independent dimension of the map.

  • presample_intensity – A source of point-by-point presample beam intensity data. Required when applying a CorrectionConfig tool.

  • dwell_time_actual – A source of point-by-point actual dwell times for SPEC scans. Required when applying a CorrectionConfig tool.

  • postsample_intensity – A source of point-by-point postsample beam intensity data. Required when applying a CorrectionConfig tool with correction_type=’flux_absorption’ or correction_type=’flux_absorption_background’.

  • attrs – Additional Map configuration attributes.

property all_scalar_data

Return a list of all instances of PointByPointScanData for which this map configuration will collect dataset-like data (as opposed to axes-like data).

This will be any and all of the items in the corrections-data-related fields, as well as any additional items in the optional scalar_data field.

attrs: dict
property coords

Return a dictionary of the values of each independent dimension across the map.

did: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=None)] | None
property dims

Return a tuple of the independent dimension labels for the map.

dwell_time_actual: DwellTimeActual | None
experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']
get_coords(map_index)

Return a dictionary of the coordinate names and values of each independent dimension for a given point on the map.

Parameters:

map_index (tuple) – The map index to return coordinates for.

Returns:

A list of coordinate values.

Return type:

dict

get_detector_data(detector_name, map_index)

Return detector data collected by this map for a given point on the map.

Parameters:
  • detector_name (str) – Name of the detector for which to return data. Usually the value of the detector’s EPICS areaDetector prefix macro, $P.

  • map_index (tuple) – The map index to return detector data for.

Returns:

One frame of raw detector data.

Return type:

np.ndarray

get_scan_step_index(map_index)

Return parameters to identify a single SPEC scan step that corresponds to the map point at the index provided.

Parameters:

map_index (tuple) – The index of a map point to identify as a specific SPEC scan step index.

Returns:

A SpecScans configuration, scan number, and scan step index.

Return type:

tuple[SpecScans, int, int]

static get_smb_par_attr(class_fields, label, units='-', name=None, unique=True)

Read an SMB par file attribute.

Parameters:
  • class_fields (Any) – The Map configuration class fields.

  • label (str) – An attrs field key, the user-defined label for referring to this data in the NeXus file and in other tools.

  • units (str) – The attrs’ field unit, defaults to ‘-’.

  • name (str, optional.) – The attrs’ field name, the name with which these raw data were recorded at time of data collection, defaults to label.

get_value(data, map_index)

Return the raw data collected by a single device at a single point in the map.

Parameters:
  • data (PointByPointScanData) – The device configuration to return a value of raw data for.

  • map_index (tuple) – The map index to return raw data for.

Returns:

Raw data value.

independent_dimensions: Annotated[list[IndependentDimension], Len(min_length=1, max_length=None)]
model_config: ClassVar[ConfigDict] = {}

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

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

postsample_intensity: PostsampleIntensity | None
presample_intensity: PresampleIntensity | None
sample: Sample
scalar_data: Annotated[list[PointByPointScanData], Len(min_length=0, max_length=None)] | None
property scan_step_indices

Return an ordered list in which we can look up the SpecScans object, the scan number, and scan step index for every point on the map.

property shape

Return the shape of the map – a tuple representing the number of unique values of each dimension across the map.

spec_scans: Annotated[list[SpecScans], Len(min_length=1, max_length=None)]
station: Literal['id1a3', 'id3a', 'id3b', 'id4b']
title: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
classmethod validate_attrs(attrs, info)

Validate any additional attributes depending on the values for the station and experiment_type fields.

Parameters:
  • attrs (dict) – Any additional attributes to the MapConfig class.

  • info (pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator info object.

Raises:

ValueError – Invalid attribute.

Returns:

The validated field for attrs.

Return type:

dict

classmethod validate_before(data)
validate_data_present: bool
classmethod validate_experiment_type(experiment_type, info)

Ensure values for the station and experiment_type fields are compatible.

Parameters:
  • experiment_type (dict) – The value of experiment_type to validate.

  • info (pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator info object.

Raises:

ValueError – Invalid experiment type.

Returns:

The validated field for experiment_type.

Return type:

str

classmethod validate_mapconfig_before(data, info)

Ensure that a valid configuration was provided and finalize spec_file filepaths.

Parameters:

data (MapConfig, pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator data object.

Returns:

The currently validated list of class properties.

Return type:

dict

class PointByPointScanData(*, label: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], units: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], data_type: Literal['spec_motor', 'spec_motor_absolute', 'scan_column', 'smb_par', 'expression', 'detector_log_timestamps'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None)

Bases: CHAPBaseModel

Class representing a source of raw scalar-valued data for which a value was recorded at every point in a MapConfig.

Variables:
  • label – A user-defined label for referring to this data in the NeXus file and in other tools.

  • units – The units in which the data were recorded.

  • data_type – Represents how these data were recorded at time of data collection.

  • name – Represents the name with which these raw data were recorded at time of data collection.

data_type: Literal['spec_motor', 'spec_motor_absolute', 'scan_column', 'smb_par', 'expression', 'detector_log_timestamps']
get_value(spec_scans, scan_number, scan_step_index=0, scalar_data=None, relative=True, ndigits=None)

Return the value recorded for this instance of PointByPointScanData at a specific scan step.

Parameters:
  • spec_scans (SpecScans) – An instance of SpecScans in which the requested scan step occurs.

  • scan_number (int) – The number of the scan in which the requested scan step occurs.

  • scan_step_index (int, optional) – The index of the requested scan step, defaults to 0.

  • scalar_data (list[PointByPointScanData], optional) – list of scalar data configurations used to get values for PointByPointScanData objects with data_type == ‘expression’.

  • relative (bool, optional) – Whether to return a relative value or not, defaults to True (only applies to SPEC motor values).

Params ndigits:

Round SPEC motor values to the specified number of decimals if set.

Returns:

The value recorded of the data represented by this instance of PointByPointScanData at the scan step requested.

Return type:

float

label: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
model_config: ClassVar[ConfigDict] = {}

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

name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None
units: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
validate_for_scalar_data(scalar_data)

Used for PointByPointScanData objects with a data_type of ‘expression’. Validate that the scalar_data field of a MapConfig object contains all the items necessary for evaluating the expression.

Parameters:

scalar_data (list[PointByPointScanData]) – the scalar_data field of a MapConfig that this PointByPointScanData object will be validated against.

Raises:

ValueError – if scalar_data does not contain items needed for evaluating the expression.

validate_for_spec_scans(spec_scans, scan_step_index='all')

Validate this instance of PointByPointScanData for a list of SpecScans.

Parameters:
  • spec_scans (list[SpecScans]) – A list of SpecScans whose raw data will be checked for the presence of the data represented by this instance of PointByPointScanData.

  • scan_step_index (Union[Literal['all'],int], optional) – A specific scan step index to validate, defaults to ‘all’.

Raises:

RuntimeError – If the data represented by this instance of PointByPointScanData is missing for the specified scan steps.

validate_for_station(station)

Validate this instance of PointByPointScanData for a certain choice of station (beamline).

Parameters:

station (str) – The name of the station (in ‘idxx’ format).

Raises:

TypeError – If the station is not compatible with the value of the data_type attribute for this instance of PointByPointScanData.

classmethod validate_label(label)

Validate that the supplied label does not conflict with any of the values for label reserved for certain data needed to perform corrections.

Parameters:

label (str) – The value of label to validate.

Raises:

ValueError – If label is one of the reserved values.

Returns:

The originally supplied value label.

Return type:

str

class PostsampleIntensity(*, label: Literal['postsample_intensity'] = 'postsample_intensity', units: Literal['counts'] = 'counts', data_type: Literal['scan_column', 'smb_par'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None)

Bases: CorrectionsData

Class representing a source of raw data for the intensity of the beam that has passed through the sample.

Variables:
  • label – Must be ‘postsample_intensity’.

  • units – Must be ‘counts’.

label: Literal['postsample_intensity']
model_config: ClassVar[ConfigDict] = {}

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

units: Literal['counts']
class PresampleIntensity(*, label: Literal['presample_intensity'] = 'presample_intensity', units: Literal['counts'] = 'counts', data_type: Literal['scan_column', 'smb_par'], name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], ndigits: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None)

Bases: CorrectionsData

Class representing a source of raw data for the intensity of the beam that is incident on the sample.

Variables:
  • label – Must be ‘presample_intensity”.

  • units – Must be ‘counts’.

label: Literal['presample_intensity']
model_config: ClassVar[ConfigDict] = {}

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

units: Literal['counts']
class Sample(*, name: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], description: str | None = '')

Bases: CHAPBaseModel

Class representing a sample metadata configuration.

Variables:
  • name – The name of the sample.

  • description – A description of the sample.

description: str | None
model_config: ClassVar[ConfigDict] = {}

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

name: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
class SpecConfig(*, station: Literal['id1a3', 'id3a', 'id3b', 'id4b'], experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM'], spec_scans: Annotated[list[SpecScans], Len(min_length=1, max_length=None)])

Bases: CHAPBaseModel

Class representing the raw data for one or more SPEC scans.

Variables:
  • station – The name of the station at which the data was collected.

  • spec_scans – A list of the SPEC scans that compose the set.

  • experiment_type – Experiment type.

experiment_type: Literal['EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']
model_config: ClassVar[ConfigDict] = {}

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

spec_scans: Annotated[list[SpecScans], Len(min_length=1, max_length=None)]
station: Literal['id1a3', 'id3a', 'id3b', 'id4b']
classmethod validate_experiment_type(experiment_type, info)

Ensure values for the station and experiment_type fields are compatible.

Parameters:
  • experiment_type (str) – The value of experiment_type to validate.

  • info (pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator info object.

Raises:

ValueError – Invalid experiment type.

Returns:

The validated field for experiment_type.

Return type:

str

classmethod validate_specconfig_before(data)

Ensure that a valid configuration was provided and finalize spec_file filepaths.

Parameters:

data (SpecConfig, pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator data object.

Returns:

The currently validated list of class properties.

Return type:

dict

class SpecScans(*, spec_file: Annotated[Path, PathType(path_type=file)], scan_numbers: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | Annotated[list[Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]], Len(min_length=1, max_length=None)], par_file: Annotated[Path, PathType(path_type=file)] | None = None)

Bases: CHAPBaseModel

Class representing a set of scans from a single SPEC file.

Variables:
  • spec_file – Path to the SPEC file.

  • scan_numbers – List of scan numbers to use.

  • par_file – Path to a non-default SMB par file.

get_detector_data(detectors, scan_number, scan_step_index)

Return the raw data from the specified detectors at the specified scan number and scan step index.

Parameters:
  • detectors (list[str]) – List of detector prefixes to get raw data for.

  • scan_number (int) – Scan number to get data for.

  • scan_step_index (int) – Scan step index to get data for.

Returns:

Data from the specified detectors for the specified scan number and scan step index.

Return type:

list[np.ndarray]

get_index(scan_number, scan_step_index, map_config)

Return a tuple representing the index of a specific step in a specific SPEC scan within a map.

Parameters:
  • scan_number (int) – Scan number to get index for.

  • scan_step_index (int) – Scan step index to get index for.

  • map_config (MapConfig) – Map configuration to get index for.

Returns:

Index for the specified scan number and scan step index within the specified map configuration.

Return type:

tuple

get_scanparser(scan_number)

Return a ScanParser for the specified scan number in the specified SPEC file.

Parameters:

scan_number (int) – Scan number to get a ScanParser for.

Returns:

ScanParser for the specified scan number.

Return type:

ScanParser

model_config: ClassVar[ConfigDict] = {}

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

par_file: Annotated[Path, PathType(path_type=file)] | None
scan_numbers: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | Annotated[list[Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]], Len(min_length=1, max_length=None)]
property scanparsers

Returns the list of ScanParser`s for each of the scans specified by the SPEC file and scan numbers belonging to this instance of `SpecScans.

spec_file: Annotated[Path, PathType(path_type=file)]
classmethod validate_par_file(par_file)

Validate the specified SMB par file.

Parameters:

par_file (str) – Path to a non-default SMB par file.

Raises:

ValueError – If the SMB par file is invalid.

Returns:

Absolute path to the SMB par file.

Return type:

str

classmethod validate_scan_numbers(scan_numbers, info)

Validate the specified list of scan numbers.

Parameters:
  • scan_numbers (Union(int, list[int], str)) – List of scan numbers.

  • info (pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator info object.

Raises:

ValueError – If a specified scan number is not found in the SPEC file.

Returns:

List of scan numbers.

Return type:

list[int]

classmethod validate_spec_file(spec_file)

Validate the specified SPEC file.

Parameters:

spec_file (str) – Path to the SPEC file.

Raises:

ValueError – If the SPEC file is invalid.

Returns:

Absolute path to the SPEC file.

Return type:

str

get_available_scan_numbers(spec_file)

Get the available scan numbers.

Parameters:

spec_file (str) – Path to the SPEC file.

get_detector_data(detector_prefixes, spec_file, scan_number, scan_step_index)

Get the detector data.

Parameters:
  • detector_prefixes (Union[tuple[str], list[str]]) – The detector prefixes.

  • scan_number (int) – Scan number to get data for.

  • scan_step_index (int) – The scan step index.

Variables:

spec_file – Path to the SPEC file.

get_detector_log_timestamps(spec_file, scan_number, detector_prefix)

Return the list of detector timestamps for the given scan & detector prefix.

Parameters:
  • spec_file – Location of a SPEC file in which the requested scan occurs.

  • scan_number (int) – The number of the scan for which to return detector log timestamps.

  • detector_prefix – The prefix of the detecotr whose log file should be used.

Returns:

All detector log timestamps for the given scan.

Return type:

list[float]

get_expression_value(spec_scans, scan_number, scan_step_index, expression, scalar_data)

Return the value of an evaluated expression of other sources of point-by-point scalar scan data for a single point.

Parameters:
  • spec_scans (SpecScans) – An instance of SpecScans in which the requested scan step occurs.

  • scan_number (int) – The number of the scan in which the requested scan step occurs.

  • scan_step_index (int) – The index of the requested scan step.

  • expression (str) – The string expression to evaluate.

  • scalar_data (list[PointByPointScanData]) – the scalar_data field of a MapConfig object (used to provide values for variables used in expression).

Returns:

The value of the .par file value for the scan requested.

Return type:

float

get_scanparser(spec_file, scan_number, par_file=None)

Get the scanparser.

Parameters:
  • spec_file (str) – Path to the SPEC file.

  • scan_number (int) – Scan number to get data for.

  • par_file (str, optional) – Path to a SMB par file.

get_smb_par_value(spec_file, scan_number, par_name)

Return the value recorded for a specific scan in SMB-tyle .par file.

Parameters:
  • spec_file – Location of a SPEC file in which the requested scan step occurs.

  • scan_number (int) – The number of the scan in which the requested scan step occurs.

  • par_name (str) – The name of the column in the .par file.

Returns:

The value of the .par file value for the scan requested.

Return type:

float

get_spec_counter_value(spec_file, scan_number, scan_step_index, spec_column_label)

Return the value recorded for a SPEC counter at a specific scan step.

Parameters:
  • spec_file – Location of a SPEC file in which the requested scan step occurs.

  • scan_number (int) – The number of the scan in which the requested scan step occurs.

  • scan_step_index (int) – The index of the requested scan step.

  • spec_column_label (str) – The label of a SPEC data column.

Returns:

The value of the counter at the scan step requested.

Return type:

float

get_spec_motor_value(spec_file, scan_number, scan_step_index, spec_mnemonic, relative=True, ndigits=None)

Return the value recorded for a SPEC motor at a specific scan step.

Parameters:
  • spec_file – Location of a SPEC file in which the requested scan step occurs.

  • scan_number (int) – The number of the scan in which the requested scan step occurs.

  • scan_step_index (int) – The index of the requested scan step.

  • spec_mnemonic (str) – The menmonic of a SPEC motor.

  • relative (bool, optional) – Whether to return a relative value or not, defaults to True.

Params ndigits:

Round SPEC motor values to the specified number of decimals if set.

Returns:

The value of the motor at the scan step requested.

Return type:

float

import_scanparser(station, experiment)

Given the name of a CHESS station and experiment type, import the corresponding subclass of ScanParser as ScanParser.

Parameters:
  • station (str) – The station name (‘IDxx’, not the beamline acronym).

  • experiment (Literal[ 'EDD', 'GIWAXS', 'SAXSWAXS', 'TOMO', 'XRF', 'HDRM']) – The experiment type.

validate_data_source_for_map_config(data_source, info)

Confirm that an instance of PointByPointScanData is valid for the station and scans provided by a map configuration dictionary.

Parameters:
  • data_source (PointByPointScanData) – The input object to validate.

  • info (pydantic_core._pydantic_core.ValidationInfo) – Pydantic validator info object.

Raises:

Exception – If data_source cannot be validated.

Returns:

The validated data_source instance.

Return type:

PointByPointScanData

Module contents

This subpackage contains PipelineItems that are common to various processing workflows.