CHAP.giwaxs package
PipelineItems unique to GIWAXS data processing workflows.
This module contains all the PipelineItems (Processors, Readers and Writers) that are unique to the GIWAXS workflow. Any of these PipelineItems can be used as items in a CHAP Pipeline or instantiated from a user Python script.
Note
Using the GIWAXS workflow pipeline items in a CHAP Pipeline and running it, requires a GIWAXS conda environent or access to the appropriate CHAP GIWAXS executable, see GIWAXS subpackage (CHAP.giwaxs)
Submodules summary
- models
Pydantic model configuration classes unique to the GIWAXS workflow.
- processor
Processors unique to the GIWAXS workflow.
- reader
Readers unique to the GIWAXS workflow.
- writer
Writers unique to the GIWAXS workflow.
Submodules
CHAP.giwaxs.models module
Pydantic model configuration classes unique to the the tomography workflow.
- class AzimuthalIntegratorConfig[source]
Bases:
IntegratorConfigAzimuthal integrator configuration class to represent a single detector used in the experiment.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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 initialize 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.
- class FiberIntegratorConfig[source]
Bases:
IntegratorConfigFiber or grazing incidence integrator configuration class to represent a single detector used in the experiment.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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 initialize 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.
- validate_azimuthalintegratorconfig_after()[source]
Set the default azimuthal integrator.
- Returns:
Validated configuration class.
- Return type:
- class GiwaxsConversionConfig[source]
Bases:
CHAPBaseModelConfiguration for the wedge correction processor
GiwaxsConversionProcessor.- Variables:
azimuthal_integrators (list[FiberIntegratorConfig]) – List of azimuthal integrator configurations.
integrations (list[PyfaiIntegratorConfig]) – Azimuthal integrator configurations.
scan_step_indices (int or list[int] or str, optional) – Optional scan step indices to convert. If not specified, all images will be converted.
save_raw_data (bool, optional) – Save the raw data in the NeXus output, defaults to False.
skip_animation (bool, optional) – Skip the animation (subject to save_figures being True), defaults to False.
- azimuthal_integrators: Annotated[list[FiberIntegratorConfig], Len(min_length=1, max_length=None)]
- integrations: Annotated[list[PyfaiIntegratorConfig], Len(min_length=1, max_length=None)]
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- save_raw_data: bool | None
- scan_step_indices: Annotated[list[Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None]], Len(min_length=1, max_length=None)] | None
- skip_animation: bool | None
- class Integrate1dConfig[source]
Bases:
CHAPBaseModelClass with the input parameters to performs 1D azimuthal integration with pyFAI.
- Variables:
error_model (str, optional) – When the variance is unknown, an error model can be given: poisson (variance = I) or azimuthal (variance = (I-<I>)^2).
method (list[str, str, str], optional) – Integration method: 3-tuple with (splitting, algorithm, implementation), defaults to [‘bbox’, ‘csr’, ‘cython’]
npt (int, optional) – Number of integration points, defaults to 1800.
attrs (dict, optional) – Additional 1D azimuthal integration configuration attributes.
- 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, ascii_only=None)] | None
- method: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)]], Len(min_length=3, max_length=3)] | None
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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[source]
Bases:
CHAPBaseModelClass with the input parameters to performs 2D azimuthal integration with pyFAI.
- Variables:
error_model (str, optional) – When the variance is unknown, an error model can be given: poisson (variance = I) or azimuthal (variance = (I-<I>)^2).
method (list[str, str, str], optional) – Integration method: 3-tuple with (splitting, algorithm, implementation), defaults to [‘bbox’, ‘csr’, ‘cython’]
npt_azim (int, optional) – Number of points for the integration in the azimuthal direction, defaults to 3600.
npt_rad (int, optional) – Number of points for the integration in the radial direction, defaults to 1800.
attrs (dict, optional) – Additional 2D azimuthal integration configuration attributes.
- 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, ascii_only=None)] | None
- method: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)]], Len(min_length=3, max_length=3)] | None
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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 Integrate2dGIConfig[source]
Bases:
CHAPBaseModelClass with the input parameters to performs 2D grazing incidence integration with pyFAI.
- Variables:
ais (str) – Detector prefix.
method (list[str, str, str], optional) – Integration method: 3-tuple with (splitting, algorithm, implementation), defaults to [‘no’, ‘histogram’, ‘cython’]
npt_ip (int, optional) – Number of points along the in-plane axis direction, defaults to 1000.
npt_oop (int, optional) – Number of points along the out-of-plane axis direction, defaults to 1000.
sample_orientation (int, optional) – orientation of according to EXIF orientation values, defaults to 2, or 4 for ais equal to EIG1 or PIL5, and 1 otherwise.
unit_ip (str, optional) – In-plane unit, defaults to qip_A^-1.
unit_oop (str, optional) – Out-of-plane unit, defaults to qoop_A^-1.
attrs (dict, optional) – Additional 2D grazing incidence integration configuration attributes.
- ais: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)]
- attrs: dict | None
- method: Annotated[list[Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)]], Len(min_length=3, max_length=3)] | None
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- npt_ip: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
- npt_oop: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
- sample_orientation: Annotated[int, None, Interval(gt=None, ge=1, lt=None, le=8), None] | None
- unit_ip: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)] | None
- unit_oop: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)] | None
- classmethod validate_sample_orientation(sample_orientation, info)[source]
Validate the sample orientation.
- Parameters:
sample_orientation (int) – Sample orientation.
info (pydantic.ValidationInfo) – Model parameter validation information.
- Returns:
Validated sample orientation.
- Return type:
int
- class IntegratorConfig[source]
Bases:
Detector,CHAPBaseModelIntegrator configuration class to represent a single detector used in the experiment.
- Variables:
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 model’s integrator.
- Type:
pyFAI.integrator.azimuthal.AzimuthalIntegrator
- mask_file: Annotated[Path, PathType(path_type=file)] | None
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- params: dict | None
- poni_file: Annotated[Path, PathType(path_type=file)] | None
- class MultiGeometryConfig[source]
Bases:
CHAPBaseModelClass representing the configuration for treating simultaneously multiple detector configuration within a single integration
- Variables:
ais (str or list[str]) – List of detector IDs of azimuthal integrators
azimuth_range (list[float, float], optional) – Common azimuthal range for integration, defaults to [-180.0, 180.0].
radial_range (list[float, float], optional) – Common range for integration, defaults to [0.0, 180.0].
unit (str, optional) – Output unit, defaults to q_A^-1.
chi_disc (int, optional) – chi discontinuity value, defaults to 180.
empty (float, optional) – Value for empty pixels, defaults to 0.
wavelength (float, optional) – Wave length used in meters.
- 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, ascii_only=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] = {'arbitrary_types_allowed': True}
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, ascii_only=None)] | None
- classmethod validate_ais(ais)[source]
Validate the detector IDs of the azimuthal integrators.
- Parameters:
ais (str or list[str]) – Detector IDs.
- Returns:
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[source]
Bases:
CHAPBaseModelConfiguration for the azimuthal integrator processor
PyfaiIntegrationProcessor.- Variables:
azimuthal_integrators (list[AzimuthalIntegratorConfig]) – List of azimuthal integrator configurations.
integrations (list[PyfaiIntegratorConfig]) – Azimuthal integrator configurations.
sum_axes (bool, optional) – Sum the detector data over the independent coordinates before integration, defaults to False.
- 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] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sum_axes: bool | None
- class PyfaiIntegratorConfig[source]
Bases:
CHAPBaseModelClass representing the configuration for detector data integrator for pyFAI.
- Variables:
name (str) – Integration type name, e.g. cake, or wedge.
integration_method (Literal[ 'integrate1d', 'integrate2d', 'integrate_radial', 'integrate2d_grazing_incidence']) – Integration method.
multi_geometry (MultiGeometryConfig) – Multiple detector configuration.
integration_params (Integrate1dConfig or Integrate2dConfig or Integrate2dGIConfig) – Integration parameter configuration.
right_handed (bool, optional) – For radial and cake integration, reverse the direction of the azimuthal coordinate from pyFAI’s convention, defaults to True.
- integrate(ais, data, masks=None, thetas=None)[source]
Perform the azimuthal integration.
- Parameters:
ais (dict) – Azimuthal integrators.
data (dict) – Detector image(s).
masks (numpy.ndarray, optional) – Detector mask(s).
thetas (numpy.ndarray, optional) – Tilt of the sample stage towards the beam (only relevant to wedge or grazing-incidence integration)
- Returns:
Integration results.
- Return type:
dict
- integration_method: Literal['integrate1d', 'integrate2d', 'integrate_radial', 'integrate2d_grazing_incidence']
- integration_params: Integrate1dConfig | Integrate2dConfig | Integrate2dGIConfig | None
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- 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, ascii_only=None)]
- right_handed: bool
CHAP.giwaxs.processor module
Module for Processors unique to the GIWAXS workflow.
Add discription of GIWAXS
- class GiwaxsConversionProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO')[source]
Bases:
ProcessorA processor for converting GIWAXS images from curved to rectangular coordinates (wedge correction).
- Variables:
config (dict, optional) – Initialization parameters for an instance of
GiwaxsConversionConfig.nxmemory (int, optional) – Maximum memory usage when reading NeXus files.
nxpath (str, optional) – Path to a specific location in the NeXus file tree to read the intensity data from.
save_figures (bool, optional) – Save .pngs of plots for checking inputs & outputs of this Processor, defaults to False.
- config: GiwaxsConversionConfig
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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 initialize 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.
- nxmemory: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
- nxpath: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None, ascii_only=None)] | None
- pipeline_fields: dict
- process(data)[source]
Process the GIWAXS input images & configuration and return a map of the images in rectangular coordinates as a NeXus style NXroot object.
- Parameters:
data (list[PipelineData]) – Results of
MapProcessorcontaining a map with the GIWAXS input images.- Returns:
Converted GIWAXS images.
- Return type:
nexusformat.nexus.NXroot
- save_figures: bool | None
- class PyfaiIntegrationProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO')[source]
Bases:
ProcessorA processor for azimuthally integrating images.
- Variables:
config (dict, optional) – Initialization parameters for an instance of
PyfaiIntegrationConfig.nxmemory (int, optional) – Maximum memory usage when reading NeXus files.
- config: PyfaiIntegrationConfig
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
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 initialize 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.
- nxmemory: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
- pipeline_fields: dict
- process(data)[source]
Process the input images & configuration and return a map of the azimuthally integrated images as a NeXus style NXroot object.
- Parameters:
data (list[PipelineData]) – Results of
MapProcessoror other suitable preprocessor of the raw detector data containing the map of input images.- Returns:
Integrated images.
- Return type:
nexusformat.nexus.NXroot
CHAP.giwaxs.reader module
Module for Readers unique to the GIWAXS workflow.
CHAP.giwaxs.writer module
Module for Writers unique to the GIWAXS workflow.