pyFAI package#

pyFAI Package#

pyFAI.__init__.benchmarks(*arg, **kwarg)#

Run the integrated benchmarks.

See the documentation of pyFAI.benchmark.run_benchmark

pyFAI.__init__.calc_hexversion(major=0, minor=0, micro=0, releaselevel='dev', serial=0, string=None)#

Calculate the hexadecimal version number from the tuple version_info:

Parameters:
  • major – integer

  • minor – integer

  • micro – integer

  • relev – integer or string

  • serial – integer

  • string – version number as a string

Returns:

integer always increasing with revision numbers

pyFAI.__init__.detector_factory(name, config=None)#

Create a new detector.

Parameters:
  • name (str) – name of a detector

  • config (dict) – configuration of the detector supporting dict or JSON representation.

Returns:

an instance of the right detector, set-up if possible

Return type:

pyFAI.detectors.Detector

pyFAI.__init__.load(filename, type_='AzimuthalIntegrator')#

Load an azimuthal integrator from a filename description.

Parameters:

filename (str) – name of the file to load, or dict of config or ponifile …

Returns:

instance of Geometry of AzimuthalIntegrator set-up with the parameter from the file.

pyFAI.__init__.tests(deprecation=False)#

Runs the test suite of the installed version

Parameters:

deprecation – enable/disables deprecation warning in the tests

integrator.azimuthal Module#

class pyFAI.integrator.azimuthal.AzimuthalIntegrator(dist=1, poni1=0, poni2=0, rot1=0, rot2=0, rot3=0, pixel1=None, pixel2=None, splinefile=None, detector=None, wavelength=None, orientation=0)#

Bases: Integrator

This class is an azimuthal integrator based on P. Boesecke’s geometry and histogram algorithm by Manolo S. del Rio and V.A Sole

All geometry calculation are done in the Geometry class

main methods are:

>>> tth, I = ai.integrate1d(data, npt, unit="2th_deg")
>>> q, I, sigma = ai.integrate1d(data, npt, unit="q_nm^-1", error_model="poisson")
>>> regrouped = ai.integrate2d(data, npt_rad, npt_azim, unit="q_nm^-1")[0]
guess_max_bins(redundancy=1, search_range=None, unit='q_nm^-1', radial_range=None, azimuth_range=None)#

Guess the maximum number of bins, considering the expected minimum redundancy:

Parameters:
  • redundancy – minimum number of pixel per bin

  • search_range – the minimum and maximum number of bins to be considered

  • unit – the unit to be considered like “2th_deg” or “q_nm^-1”

  • radial_range – radial range to be considered, depends on unit !

  • azimuth_range – azimuthal range to be considered

Returns:

the minimum bin number providing the provided redundancy

guess_polarization(img, npt_rad=None, npt_azim=360, unit='2th_deg', method=('no', 'csr', 'cython'), target_rad=None)#

Guess the polarization factor for the given image

For this one performs several integration with different polarization factors and take the one with the lowest std along the outer-most ring.

Parameters:
  • img – diffraction image, preferable with beam-stop centered.

  • npt_rad – number of point in the radial dimension, can be guessed, better avoid oversampling.

  • npt_azim – number of point in the azimuthal dimension, 1 per degree is usually OK

  • unit – radial unit for the integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation). The default one is pretty optimal: no splitting, CSR for the speed of the integration

  • target_rad – position of the outer-most complete ring, can be guessed.

Returns:

polarization factor (#, polarization angle)

inpainting(data, mask, npt_rad=1024, npt_azim=512, *, unit='r_m', method=('full', 'csr', 'cython'), poissonian=False, grow_mask=3)#

Re-invent the values of masked pixels

Parameters:
  • data – input image as 2d numpy array

  • mask – masked out pixels array

  • npt_rad – number of radial points

  • npt_azim – number of azimuthal points

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • poissonian – If True, add some poisonian noise to the data to make then more realistic

  • grow_mask – grow mask in polar coordinated to accommodate pixel splitting algorithm

Returns:

inpainting object which contains the restored image as .data

integrate1d(data, npt, *, filename=None, correctSolidAngle=True, variance=None, error_model=None, radial_range=None, azimuth_range=None, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, absorption=None, method=('bbox', 'csr', 'cython'), unit=q_nm ^ -1, safe=True, normalization_factor=1.0, metadata=None)#

Calculate the azimuthal integration (1d) of a 2D image.

Multi algorithm implementation (tries to be bullet proof), suitable for SAXS, WAXS, … and much more Takes extra care of normalization and performs proper variance propagation.

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt (int) – number of points in the output pattern

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • variance (ndarray) – array containing the variance of the data.

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (min, max). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (min, max). Values outside the range are ignored.

  • mask (ndarray) – array with 0 for valid pixels, all other are masked (static mask)

  • dummy (float) – value for dead/masked pixels (dynamic mask)

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction, True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • absorption (ndarray) – absorption correction image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • unit (Unit) – Output units, can be “q_nm^-1” (default), “2th_deg”, “r_mm” for now.

  • safe (bool) – Perform some extra checks to ensure LUT/CSR is still valid. False is faster.

  • normalization_factor (float) – Value of a normalization monitor

  • metadata – JSON serializable object containing the metadata, usually a dictionary.

  • absorption – detector absorption

Returns:

Integrate1dResult namedtuple with (q,I,sigma) +extra information in it.

integrate1d_ng(data, npt, *, filename=None, correctSolidAngle=True, variance=None, error_model=None, radial_range=None, azimuth_range=None, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, absorption=None, method=('bbox', 'csr', 'cython'), unit=q_nm ^ -1, safe=True, normalization_factor=1.0, metadata=None)#

Calculate the azimuthal integration (1d) of a 2D image.

Multi algorithm implementation (tries to be bullet proof), suitable for SAXS, WAXS, … and much more Takes extra care of normalization and performs proper variance propagation.

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt (int) – number of points in the output pattern

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • variance (ndarray) – array containing the variance of the data.

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (min, max). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (min, max). Values outside the range are ignored.

  • mask (ndarray) – array with 0 for valid pixels, all other are masked (static mask)

  • dummy (float) – value for dead/masked pixels (dynamic mask)

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction, True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • absorption (ndarray) – absorption correction image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • unit (Unit) – Output units, can be “q_nm^-1” (default), “2th_deg”, “r_mm” for now.

  • safe (bool) – Perform some extra checks to ensure LUT/CSR is still valid. False is faster.

  • normalization_factor (float) – Value of a normalization monitor

  • metadata – JSON serializable object containing the metadata, usually a dictionary.

  • absorption – detector absorption

Returns:

Integrate1dResult namedtuple with (q,I,sigma) +extra information in it.

integrate2d(data, npt_rad, npt_azim=360, *, filename=None, correctSolidAngle=True, variance=None, error_model=None, radial_range=None, azimuth_range=None, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('bbox', 'csr', 'cython'), unit=q_nm ^ -1, safe=True, normalization_factor=1.0, metadata=None)#

Calculate the azimuthal regrouped 2d image in q(nm^-1)/chi(deg) by default

Multi algorithm implementation (tries to be bullet proof)

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_rad (int) – number of points in the radial direction

  • npt_azim (int) – number of points in the azimuthal direction

  • filename (str) – output image (as edf format)

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • variance (ndarray) – array containing the variance of the data. If not available, no error propagation is done

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (str) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • unit (pyFAI.units.Unit) – Output units, can be “q_nm^-1”, “q_A^-1”, “2th_deg”, “2th_rad”, “r_mm” for anything defined as pyFAI.units.RADIAL_UNITS can also be a 2-tuple of (RADIAL_UNITS, AZIMUTHAL_UNITS) (advanced usage)

  • safe (bool) – Do some extra checks to ensure LUT is still valid. False is faster.

  • normalization_factor (float) – Value of a normalization monitor

  • metadata – JSON serializable object containing the metadata, usually a dictionary.

Returns:

azimuthaly regrouped intensity, q/2theta/r pos. and chi pos.

Return type:

Integrate2dResult, dict

integrate2d_ng(data, npt_rad, npt_azim=360, *, filename=None, correctSolidAngle=True, variance=None, error_model=None, radial_range=None, azimuth_range=None, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('bbox', 'csr', 'cython'), unit=q_nm ^ -1, safe=True, normalization_factor=1.0, metadata=None)#

Calculate the azimuthal regrouped 2d image in q(nm^-1)/chi(deg) by default

Multi algorithm implementation (tries to be bullet proof)

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_rad (int) – number of points in the radial direction

  • npt_azim (int) – number of points in the azimuthal direction

  • filename (str) – output image (as edf format)

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • variance (ndarray) – array containing the variance of the data. If not available, no error propagation is done

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (str) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • unit (pyFAI.units.Unit) – Output units, can be “q_nm^-1”, “q_A^-1”, “2th_deg”, “2th_rad”, “r_mm” for anything defined as pyFAI.units.RADIAL_UNITS can also be a 2-tuple of (RADIAL_UNITS, AZIMUTHAL_UNITS) (advanced usage)

  • safe (bool) – Do some extra checks to ensure LUT is still valid. False is faster.

  • normalization_factor (float) – Value of a normalization monitor

  • metadata – JSON serializable object containing the metadata, usually a dictionary.

Returns:

azimuthaly regrouped intensity, q/2theta/r pos. and chi pos.

Return type:

Integrate2dResult, dict

integrate_radial(data, npt, npt_rad=100, *, correctSolidAngle=True, radial_range=None, azimuth_range=None, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('bbox', 'csr', 'cython'), unit=chi_deg, radial_unit=q_nm ^ -1, normalization_factor=1.0)#

Calculate the radial integrated profile curve as I = f(chi)

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt (int) – number of points in the output pattern

  • npt_rad (int) – number of points in the radial space. Too few points may lead to huge rounding errors.

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • radial_range (Tuple(float, float)) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • azimuth_range (Tuple(float, float)) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • unit (pyFAI.units.Unit) – Output units, can be “chi_deg” or “chi_rad”

  • radial_unit (pyFAI.units.Unit) – unit used for radial representation, can be “q_nm^-1”, “q_A^-1”, “2th_deg”, “2th_rad”, “r_mm” for now

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

medfilt1d(data, npt_rad=1024, npt_azim=512, *, correctSolidAngle=True, radial_range=None, azimuth_range=None, polarization_factor=None, dark=None, flat=None, method='splitpixel', unit=q_nm ^ -1, percentile=50, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None)#

Perform the 2D integration and filter along each row using a median filter

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points

  • npt_azim – number of azimuthal points

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction, True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • percentile – which percentile use for cutting out percentile can be a 2-tuple to specify a region to average out

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

Returns:

Integrate1D like result like

medfilt1d_legacy(data, npt_rad=1024, npt_azim=512, *, correctSolidAngle=True, radial_range=None, azimuth_range=None, polarization_factor=None, dark=None, flat=None, method='splitpixel', unit=q_nm ^ -1, percentile=50, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None)#

Perform the 2D integration and filter along each row using a median filter

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points

  • npt_azim – number of azimuthal points

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). 0 for circular polarization or random, None for no correction, True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • percentile – which percentile use for cutting out percentile can be a 2-tuple to specify a region to average out

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

Returns:

Integrate1D like result like

medfilt1d_ng(data, npt=1024, *, correctSolidAngle=True, polarization_factor=None, variance=None, error_model=ErrorModel.NO, radial_range=None, azimuth_range=None, dark=None, flat=None, absorption=None, method=('full', 'csr', 'cython'), unit=q_nm ^ -1, percentile=50, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None, safe=True, **kwargs)#

Performs a median filter in azimuthal space:

All pixels contributing to an azimuthal bin are sorted according to their corrected intensity (i.e. signal/norm). Then a cumulative sum is performed on their weight which allows to determine the location of the different quantiles. The percentile parameter (in the range [1:100]) can be: - either a single scalar, then the pixel with the nearest value to the quantile is used (i.e. the default value 50 provides the median). - either a 2-tuple, then the weighted average is calculated for all pixels between the two quantiles provided.

Unlike sigma-clipping, this method is compatible with any kind of pixel splitting but much slower.

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • polarization_factor (float) – polarization factor between: -1 (vertical) +1 (horizontal). - 0 for circular polarization or random, - None for no correction, - True for using the former correction

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • absorption (ndarray) – Detector absorption (image)

  • variance (ndarray) – the variance of the signal

  • error_model (str) – can be “poisson” to assume a poissonian detector (variance=I) or “azimuthal” to take the std² in each ring (better, more expenive)

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • percentile – which percentile use for cutting out. percentile can be a 2-tuple to specify a region to average out, like: (25,75) to average the second and third quartile.

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

  • safe – set to False to skip some tests

Returns:

Integrate1D like result like

The difference with the previous medfilt_legacy implementation is that there is no 2D regrouping.

separate(data, npt=1024, *, unit='2th_deg', method=('full', 'csr', 'cython'), polarization_factor=None, percentile=50, mask=None, restore_mask=True)#

Separate bragg signal from powder/amorphous signal using azimuthal median filering and projected back before subtraction.

Parameters:
  • data – input image as numpy array

  • npt – number of radial points

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • polarization_factor – Value of the polarization factor (from -1 to +1), None to disable correction.

  • percentile – which percentile use for cutting out

  • mask – masked out pixels array

  • restore_mask – masked pixels have the same value as input data provided

Returns:

SeparateResult which the bragg & amorphous signal

Note: the filtered 1D spectrum can be retrieved from SeparateResult.radial and SeparateResult.intensity attributes

sigma_clip(data, npt=1024, *, correctSolidAngle=True, polarization_factor=None, variance=None, error_model=ErrorModel.NO, radial_range=None, azimuth_range=None, dark=None, flat=None, absorption=None, method=('no', 'csr', 'cython'), unit=q_nm ^ -1, thres=5.0, max_iter=5, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None, safe=True, **kwargs)#

Performs iteratively the 1D integration with variance propagation and performs a sigm-clipping at each iteration, i.e. all pixel which intensity differs more than thres*std is discarded for next iteration.

Keep only pixels with intensty:

|I - <I>| < thres * σ(I)

This enforces a symmetric, bell-shaped distribution (i.e. gaussian-like) and is very good at extracting background or amorphous isotropic scattering out of Bragg peaks.

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • polarization_factor (float) – polarization factor between: -1 (vertical) +1 (horizontal). - 0 for circular polarization or random, - None for no correction, - True for using the former correction

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • absorption (ndarray) – Detector absorption (image)

  • variance (ndarray) – the variance of the signal

  • error_model (str) – can be “poisson” to assume a poissonian detector (variance=I) or “azimuthal” to take the std² in each ring (better, more expenive)

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • thres – cut-off for n*sigma: discard any values with (I-<I>)/sigma > thres.

  • max_iter – maximum number of iterations

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

  • safe – set to False to skip some tests

Returns:

Integrate1D like result like

The difference with the previous sigma_clip_legacy implementation is that there is no 2D regrouping. Pixel splitting should be avoided with this implementation. The standard deviation is usually smaller than previously and the signal cleaner. It is also slightly faster.

The case neither error_model, nor variance is provided, fall-back on a poissonian model.

sigma_clip_legacy(data, npt_rad=1024, npt_azim=512, *, correctSolidAngle=True, polarization_factor=None, radial_range=None, azimuth_range=None, dark=None, flat=None, method=('full', 'histogram', 'cython'), unit=q_nm ^ -1, thres=3, max_iter=5, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None, safe=True, **kwargs)#

Perform first a 2D integration and then an iterative sigma-clipping filter along each row. See the doc of scipy.stats.sigmaclip for the options thres and max_iter.

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points (alias: npt)

  • npt_azim – number of azimuthal points

  • correctSolidAngle (bool) – correct for solid angle of each pixel when set

  • polarization_factor (float) –

    polarization factor between -1 (vertical) and +1 (horizontal).

    • 0 for circular polarization or random,

    • None for no correction,

    • True for using the former correction

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • thres – cut-off for n*sigma: discard any values with |I-<I>| > thres*σ. The threshold can be a 2-tuple with sigma_low and sigma_high.

  • max_iter – maximum number of iterations

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

  • safe – unset to save some checks on sparse matrix shape/content.

Kwargs:

unused, just for signature compatibility when used within Worker.

Returns:

Integrate1D like result like

Nota: The initial 2D-integration requires pixel splitting

sigma_clip_ng(data, npt=1024, *, correctSolidAngle=True, polarization_factor=None, variance=None, error_model=ErrorModel.NO, radial_range=None, azimuth_range=None, dark=None, flat=None, absorption=None, method=('no', 'csr', 'cython'), unit=q_nm ^ -1, thres=5.0, max_iter=5, dummy=None, delta_dummy=None, mask=None, normalization_factor=1.0, metadata=None, safe=True, **kwargs)#

Performs iteratively the 1D integration with variance propagation and performs a sigm-clipping at each iteration, i.e. all pixel which intensity differs more than thres*std is discarded for next iteration.

Keep only pixels with intensty:

|I - <I>| < thres * σ(I)

This enforces a symmetric, bell-shaped distribution (i.e. gaussian-like) and is very good at extracting background or amorphous isotropic scattering out of Bragg peaks.

Parameters:
  • data – input image as numpy array

  • npt_rad – number of radial points

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • polarization_factor (float) – polarization factor between: -1 (vertical) +1 (horizontal). - 0 for circular polarization or random, - None for no correction, - True for using the former correction

  • radial_range ((float, float), optional) – The lower and upper range of the radial unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • azimuth_range ((float, float), optional) – The lower and upper range of the azimuthal angle in degree. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored.

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • absorption (ndarray) – Detector absorption (image)

  • variance (ndarray) – the variance of the signal

  • error_model (str) – can be “poisson” to assume a poissonian detector (variance=I) or “azimuthal” to take the std² in each ring (better, more expenive)

  • unit – unit to be used for integration

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • thres – cut-off for n*sigma: discard any values with (I-<I>)/sigma > thres.

  • max_iter – maximum number of iterations

  • mask – masked out pixels array

  • normalization_factor (float) – Value of a normalization monitor

  • metadata (JSON serializable dict) – any other metadata,

  • safe – set to False to skip some tests

Returns:

Integrate1D like result like

The difference with the previous sigma_clip_legacy implementation is that there is no 2D regrouping. Pixel splitting should be avoided with this implementation. The standard deviation is usually smaller than previously and the signal cleaner. It is also slightly faster.

The case neither error_model, nor variance is provided, fall-back on a poissonian model.

integrator.fiber Module#

class pyFAI.integrator.fiber.FiberIntegrator(*args, **kwargs)#

Bases: AzimuthalIntegrator

This Integrator is made for Fiber / Grazing-Incidence experiments It inherits the methods from AzimuthalIntegrator plus provides a new API with methods:

  • integrate1d_grazing_incidence

  • integrate2d_grazing_incidence

  • integrate1d_exitangles

  • integrate2d_exitangles

  • integrate1d_polar

  • integrate2d_polar

Example: result_gi = fi.integrate2d_grazing_incidence(data=data,

incident_angle=0.12, #degrees angle_unit=”deg”, tilt_angle=0.001, sample_orientation=6, )

__init__(*args, **kwargs)#
Parameters:
  • dist (float) – distance sample - detector plan (orthogonal distance, not along the beam), in meter.

  • poni1 (float) – coordinate of the point of normal incidence along the detector’s first dimension, in meter

  • poni2 (float) – coordinate of the point of normal incidence along the detector’s second dimension, in meter

  • rot1 (float) – first rotation from sample ref to detector’s ref, in radians

  • rot2 (float) – second rotation from sample ref to detector’s ref, in radians

  • rot3 (float) – third rotation from sample ref to detector’s ref, in radians

  • pixel1 (float) – Deprecated. Pixel size of the fist dimension of the detector, in meter. If both pixel1 and pixel2 are not None, detector pixel size is overwritten. Prefer defining the detector pixel size on the provided detector object. Prefer defining the detector pixel size on the provided detector object (detector.pixel1 = 5e-6).

  • pixel2 (float) – Deprecated. Pixel size of the second dimension of the detector, in meter. If both pixel1 and pixel2 are not None, detector pixel size is overwritten. Prefer defining the detector pixel size on the provided detector object (detector.pixel2 = 5e-6).

  • splinefile (str) – Deprecated. File containing the geometric distortion of the detector. If not None, pixel1 and pixel2 are ignored and detector spline is overwritten. Prefer defining the detector spline manually (detector.splineFile = "file.spline").

  • detector (str or pyFAI.Detector) – name of the detector or Detector instance. String description is deprecated. Prefer using the result of the detector factory: pyFAI.detector_factory("eiger4m")

  • wavelength (float) – Wave length used in meter

  • orientation (int) – orientation of the detector, see pyFAI.detectors.orientation.Orientation

property incident_angle: float#

Pitch angle: projection angle of the beam in the sample. Its rotation axis is the horizontal axis of the lab system.

integrate1d_exitangles(angle_degrees=True, vertical_integration=True, **kwargs)#

Calculate the integrated profile curve along the one of the exit angles (with the origin at the sample horizon)

Parameters:
  • bool (vertical_integration) – if True, exit angles in degrees, else in radians

  • bool – if True, the output profile is I vs vertical_angle, if False (I vs horizontal_angle)

Calls method integrate_fiber ->

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate1d_fiber(data, npt_ip=None, unit_ip=None, ip_range=None, npt_oop=None, unit_oop=None, oop_range=None, vertical_integration=True, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate1dFiberResult#

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate1d_grazing_incidence(data, npt_ip=None, unit_ip=None, ip_range=None, npt_oop=None, unit_oop=None, oop_range=None, vertical_integration=True, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate1dFiberResult#

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate1d_polar(polar_degrees=True, radial_unit='nm^-1', radial_integration=False, **kwargs)#

Calculate the integrated profile curve along the polar angle=arctan(qOOP / qIP) or as a function of the polar angle along q modulus

Parameters:
  • bool (radial_integration) – if True, polar angle in degrees, else in radians

  • str (radial_unit) – unit of q modulus: nm^-1 or A^-1

  • bool – if False, the output profile is I vs q, if True (I vs polar_angle)

Calls method integrate_fiber ->

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate2d_exitangles(angle_degrees=True, **kwargs)#

Reshapes the data pattern as a function of exit angles with the origin at the sample horizon

Parameters:

bool (angle_degrees) – if True, exit angles in degrees, else in radians

Calls method integrate2d_fiber ->

Reshapes the data pattern as a function of two FiberUnits, additional inputs for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

  • use_missing_wedge (bool) – when set, mask-out all bins present in the missing edge and restores compatibility with pixel-splitting methods

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate2d_fiber(data, npt_ip=1000, unit_ip=None, ip_range=None, npt_oop=1000, unit_oop=None, oop_range=None, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate2dFiberResult#

Reshapes the data pattern as a function of two FiberUnits, additional inputs for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

  • use_missing_wedge (bool) – when set, mask-out all bins present in the missing edge and restores compatibility with pixel-splitting methods

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate2d_grazing_incidence(data, npt_ip=1000, unit_ip=None, ip_range=None, npt_oop=1000, unit_oop=None, oop_range=None, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate2dFiberResult#

Reshapes the data pattern as a function of two FiberUnits, additional inputs for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

  • use_missing_wedge (bool) – when set, mask-out all bins present in the missing edge and restores compatibility with pixel-splitting methods

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate2d_polar(polar_degrees=True, radial_unit='nm^-1', rotate=False, **kwargs)#

Reshapes the data pattern as a function of polar angle=arctan(qOOP / qIP) versus q modulus.

Parameters:
  • bool (rotate) – if True, polar angle in degrees, else in radians

  • str (radial_unit) – unit of q modulus: nm^-1 or A^-1

  • bool – if False, polar_angle vs q, if True q vs polar_angle

Calls method integrate2d_fiber ->

Reshapes the data pattern as a function of two FiberUnits, additional inputs for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

  • use_missing_wedge (bool) – when set, mask-out all bins present in the missing edge and restores compatibility with pixel-splitting methods

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate_fiber(data, npt_ip=None, unit_ip=None, ip_range=None, npt_oop=None, unit_oop=None, oop_range=None, vertical_integration=True, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate1dFiberResult#

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate_grazing_incidence(data, npt_ip=None, unit_ip=None, ip_range=None, npt_oop=None, unit_oop=None, oop_range=None, vertical_integration=True, sample_orientation=None, filename=None, correctSolidAngle=True, mask=None, dummy=None, delta_dummy=None, polarization_factor=None, dark=None, flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, angle_unit='rad', **kwargs) Integrate1dFiberResult#

Calculate the integrated profile curve along a specific FiberUnit, additional input for sample_orientation

Parameters:
  • data (ndarray) – 2D array from the Detector/CCD camera

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

  • filename (str) – output filename in 2/3 column ascii format

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • mask (ndarray) – array (same size as image) with 1 for masked pixels, and 0 for valid pixels

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • flat (ndarray) – flat field image

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

reset_integrator(incident_angle, tilt_angle, sample_orientation)#

Reset the cache values for the gi/fiber parameters :param incident_angle: tilting of the sample towards the beam (analog to rot2): in radians :param tilt_angle: tilting of the sample orthogonal to the beam direction (analog to rot3): in radians :param int sample_orientation: 1-8, orientation of the fiber axis according to EXIF orientation values (see def sample_orientation)

property sample_orientation: int#

Orientation of the fiber axis according to EXIF orientation values

Sample orientations 1 - No changes are applied to the image 2 - Image is mirrored (flipped horizontally) 3 - Image is rotated 180 degrees 4 - Image is rotated 180 degrees and mirrored 5 - Image is mirrored and rotated 90 degrees counter clockwise 6 - Image is rotated 90 degrees counter clockwise 7 - Image is mirrored and rotated 90 degrees clockwise 8 - Image is rotated 90 degrees clockwise

property tilt_angle: float#

Roll angle. Its rotation axis is the beam axis. Tilting of the horizon for grazing incidence in thin films.

pyFAI.integrator.fiber.get_deprecated_params_1d(**kwargs) dict#
pyFAI.integrator.fiber.get_deprecated_params_2d(**kwargs) dict#
pyFAI.integrator.fiber.get_missing_wedge_mask(result: Integrate2dFiberResult, threshold_bins=None) ndarray#

Calculate a mask for the missing wedge after calculating a count threshold.

Parameters:
  • result – Integrate2dFiberResult

  • threshold_bins – number of bins to histogram the normalization values

pyFAI.integrator.fiber.get_missing_wedge_mask_by_percentile(result: Integrate2dFiberResult, percentile=20) ndarray#

Calculate a mask for the missing wedge based on the percentage of bins of result.count array falling into the missing wedge.

Parameters:
  • result – Integrate2DFiberResult, the return of a FiberIntegrator.integrate2d_grazing_incidence

  • percentile – float (0 -> 100), upper limit of bins to filter out of the result.count array

pyFAI.integrator.fiber.get_missing_wedge_threshold(intensity: ndarray, threshold_bins=None) float#

Calculate the count threshold to mask the missing wedge.

Parameters:
  • numpy.ndarray (intensity) – 2d array with the bin-wise normalization values

  • threshold_bins – number of bins to histogram the normalization values, defaults to max(intensity.shape)

Returns:

float: The count threshold to mask the missing wedge

average Module#

exception pyFAI.average.AlgorithmCreationError#

Bases: RuntimeError

Exception returned if creation of an ImageReductionFilter is not possible

class pyFAI.average.Average#

Bases: object

Process images to generate an average using different algorithms.

__init__()#

Constructor

add_algorithm(algorithm)#

Defines another algorithm which will be computed on the source.

Parameters:

algorithm (ImageReductionFilter) – An averaging algorithm.

get_counter_frames()#

Returns the number of frames used for the process.

Return type:

int

get_fabio_images()#

Returns source images as fabio images.

Return type:

list(fabio.fabioimage.FabioImage)

get_image_reduction(algorithm)#

Returns the result of an algorithm. The process must be already done.

Parameters:

algorithm (ImageReductionFilter) – An averaging algorithm

Return type:

numpy.ndarray

process()#

Process source images to all defined averaging algorithms defined using defined parameters. To access to the results you have to define a writer (AverageWriter). To follow the process forward you have to define an observer (AverageObserver).

set_correct_flat_from_dark(correct_flat_from_dark)#

Defines if the dark must be applied on the flat.

Parameters:

correct_flat_from_dark (bool) – If true, the dark is applied.

set_dark(dark_list)#

Defines images used as dark.

Parameters:

dark_list (list) – List of dark used

set_flat(flat_list)#

Defines images used as flat.

Parameters:

flat_list (list) – List of dark used

set_images(image_list)#

Defines the set set of source images to used to process an average.

Parameters:

image_list (list) – List of filename, numpy arrays, fabio images used as source for the computation.

set_monitor_name(monitor_name)#

Defines the monitor name used to correct images before processing the average. This monitor must be part of the file header, else the image is skipped.

Parameters:

monitor_name (str) – Name of the monitor available on the header file

set_observer(observer)#

Set an observer to the average process.

Parameters:

observer (AverageObserver) – An observer

set_pixel_filter(threshold, minimum, maximum)#

Defines the filter applied on each pixels of the images before processing the average.

Parameters:
  • threshold – what is the upper limit? all pixel > max*(1-threshold) are discarded.

  • minimum – minimum valid value or True

  • maximum – maximum valid value

set_writer(writer)#

Defines the object write which will be used to store the result.

Parameters:

writer (AverageWriter) – The writer to use.

class pyFAI.average.AverageDarkFilter(filter_name, cut_off, quantiles)#

Bases: ImageStackFilter

Filter based on the algorithm of average_dark

TODO: Must be split according to each filter_name, and removed

__init__(filter_name, cut_off, quantiles)#
get_parameters()#

Return a dictionary containing filter parameters

property name#
class pyFAI.average.AverageObserver#

Bases: object

algorithm_finished(algorithm)#

Called when an algorithm is finished

algorithm_started(algorithm)#

Called when an algorithm is started

frame_processed(algorithm, frame_index, frames_count)#

Called after providing a frame to an algorithm

image_loaded(fabio_image, image_index, images_count)#

Called when an input image is loaded

process_finished()#

Called when the full process is finished

process_started()#

Called when the full processing is started

result_processing(algorithm)#

Called before the result of an algorithm is computed

class pyFAI.average.AverageWriter#

Bases: object

Interface for using writer in Average process.

close()#

Close the writer. Must not be used anymore.

write_header(merged_files, nb_frames, monitor_name)#

Write the header of the average

Parameters:
  • merged_files (list) – List of files used to generate this output

  • nb_frames (int) – Number of frames used

  • monitor_name (str) – Name of the monitor used. Can be None.

write_reduction(algorithm, data)#

Write one reduction

Parameters:
class pyFAI.average.ImageAccumulatorFilter#

Bases: ImageReductionFilter

Filter applied in a set of images in which it is possible to reduce data step by step into a single merged image.

add_image(image)#

Add an image to the filter.

Parameters:

image (numpy.ndarray) – image to add

get_result()#

Get the result of the filter.

Returns:

result filter

Return type:

numpy.ndarray

init(max_images=None)#

Initialize the filter before using it.

Parameters:

max_images (int) – Max images supported by the filter

class pyFAI.average.ImageReductionFilter#

Bases: object

Generic filter applied in a set of images.

add_image(image)#

Add an image to the filter.

Parameters:

image (numpy.ndarray) – image to add

get_parameters()#

Return a dictionary containing filter parameters

Return type:

dict

get_result()#

Get the result of the filter.

Returns:

result filter

init(max_images=None)#

Initialize the filter before using it.

Parameters:

max_images (int) – Max images supported by the filter

class pyFAI.average.ImageStackFilter#

Bases: ImageReductionFilter

Filter creating a stack from all images and computing everything at the end.

add_image(image)#

Add an image to the filter.

Parameters:

image (numpy.ndarray) – image to add

get_result()#

Get the result of the filter.

Returns:

result filter

init(max_images=None)#

Initialize the filter before using it.

Parameters:

max_images (int) – Max images supported by the filter

class pyFAI.average.MaxAveraging#

Bases: ImageAccumulatorFilter

name = 'max'#
class pyFAI.average.MeanAveraging#

Bases: SumAveraging

get_result()#

Get the result of the filter.

Returns:

result filter

Return type:

numpy.ndarray

name = 'mean'#
class pyFAI.average.MinAveraging#

Bases: ImageAccumulatorFilter

name = 'min'#
class pyFAI.average.MultiFilesAverageWriter(file_name_pattern, file_format, dry_run=False)#

Bases: AverageWriter

Write reductions into multi files. File headers are duplicated.

__init__(file_name_pattern, file_format, dry_run=False)#
Parameters:
  • file_name_pattern (str) – File name pattern for the output files. If it contains “{method_name}”, it is updated for each reduction writing with the name of the reduction.

  • file_format (str) – File format used. It is the default extension file.

  • dry_run (bool) – If dry_run, the file is created on memory but not saved on the file system at the end

close()#

Close the writer. Must not be used anymore.

get_fabio_image(algorithm)#

Get the constructed fabio image

Return type:

fabio.fabioimage.FabioImage

write_header(merged_files, nb_frames, monitor_name)#

Write the header of the average

Parameters:
  • merged_files (list) – List of files used to generate this output

  • nb_frames (int) – Number of frames used

  • monitor_name (str) – Name of the monitor used. Can be None.

write_reduction(algorithm, data)#

Write one reduction

Parameters:
class pyFAI.average.SumAveraging#

Bases: ImageAccumulatorFilter

name = 'sum'#
pyFAI.average.average_dark(lstimg, center_method='mean', cutoff=None, quantiles=(0.5, 0.5))#

Averages a series of dark (or flat) images. Centers the result on the mean or the median … but averages all frames within cutoff*std

Parameters:
  • lstimg – list of 2D images or a 3D stack

  • center_method (str) – is the center calculated by a “mean”, “median”, “quantile”, “std”

  • cutoff (float or None) – keep all data where (I-center)/std < cutoff

  • quantiles (tuple(float, float) or None) – 2-tuple of floats average out data between the two quantiles

Returns:

2D image averaged

pyFAI.average.average_images(listImages, output=None, threshold=0.1, minimum=None, maximum=None, darks=None, flats=None, filter_='mean', correct_flat_from_dark=False, cutoff=None, quantiles=None, fformat='edf', monitor_key=None)#
Takes a list of filenames and create an average frame discarding all

saturated pixels.

Parameters:
  • listImages – list of string representing the filenames

  • output – name of the optional output file

  • threshold – what is the upper limit? all pixel > max*(1-threshold) are discarded.

  • minimum – minimum valid value or True

  • maximum – maximum valid value

  • darks – list of dark current images for subtraction

  • flats – list of flat field images for division

  • filter – can be “min”, “max”, “median”, “mean”, “sum”, “quantiles” (default=’mean’)

  • correct_flat_from_dark – shall the flat be re-corrected ?

  • cutoff – keep all data where (I-center)/std < cutoff

  • quantiles – 2-tuple containing the lower and upper quantile (0<q<1) to average out.

  • fformat – file format of the output image, default: edf

  • str (monitor_key) – Key containing the monitor. Can be none.

Returns:

filename with the data or the data ndarray in case format=None

pyFAI.average.bounding_box(img)#

Tries to guess the bounding box around a valid massif

Parameters:

img – 2D array like

Returns:

4-tuple (d0_min, d1_min, d0_max, d1_max)

pyFAI.average.common_prefix(string_list)#

Return the common prefix of a list of strings

TODO: move it into utils package

Parameters:

string_list (list(str)) – List of strings

Return type:

str

pyFAI.average.create_algorithm(filter_name, cut_off=None, quantiles=None)#

Factory to create algorithm according to parameters

Parameters:
  • cutoff (float or None) – keep all data where (I-center)/std < cutoff

  • quantiles (tuple(float, float) or None) – 2-tuple of floats average out data between the two quantiles

Returns:

An algorithm

Return type:

ImageReductionFilter

Raises:

AlgorithmCreationError – If it is not possible to create the algorithm

pyFAI.average.is_algorithm_name_exists(filter_name)#

Return true if the name is a name of a filter algorithm

pyFAI.average.remove_saturated_pixel(ds, threshold=0.1, minimum=None, maximum=None)#

Remove saturated fixes from an array in place.

Parameters:
  • ds – a dataset as ndarray

  • threshold (float) – what is the upper limit? all pixel > max*(1-threshold) are discarded.

  • minimum (float) – minimum valid value (or True for auto-guess)

  • maximum (float) – maximum valid value

Returns:

the input dataset

multi_geometry Module#

Module for treating simultaneously multiple detector configuration within a single integration

class pyFAI.multi_geometry.MultiGeometry(ais, unit='2th_deg', radial_range=None, azimuth_range=None, wavelength=None, empty=0.0, chi_disc=180, threadpoolsize=4)#

Bases: object

This is an Azimuthal integrator containing multiple geometries, for example when the detector is on a goniometer arm

__init__(ais, unit='2th_deg', radial_range=None, azimuth_range=None, wavelength=None, empty=0.0, chi_disc=180, threadpoolsize=4)#

Constructor of the multi-geometry integrator

Parameters:
  • ais – list of azimuthal integrators

  • radial_range – common range for integration

  • azimuthal_range – (2-tuple) common azimuthal range for integration

  • empty – value for empty pixels

  • chi_disc – if 0, set the chi_discontinuity at 0, else π

  • threadpoolsize – By default, use a thread-pool to parallelize histogram/CSC integrator over as many threads as cores, set to False/0 to serialize

property empty#
integrate1d(lst_data, npt=1800, correctSolidAngle=True, lst_variance=None, error_model=None, polarization_factor=None, normalization_factor=None, lst_mask=None, lst_flat=None, method=('full', 'histogram', 'cython'))#

Perform 1D azimuthal integration

Parameters:
  • lst_data – list of numpy array

  • npt – number of points int the integration

  • correctSolidAngle – correct for solid angle (all processing are then done in absolute solid angle !)

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • polarization_factor – Apply polarization correction ? is None: not applies. Else provide a value from -1 to +1

  • normalization_factor – normalization monitors value (list of floats)

  • all – return a dict with all information in it (deprecated, please refer to the documentation of Integrate1dResult).

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method – integration method, a string or a registered method

Returns:

2th/I or a dict with everything depending on “all”

Return type:

Integrate1dResult, dict

integrate2d(lst_data, npt_rad=1800, npt_azim=3600, correctSolidAngle=True, lst_variance=None, error_model=None, polarization_factor=None, normalization_factor=None, lst_mask=None, lst_flat=None, method=('full', 'histogram', 'cython'))#

Performs 2D azimuthal integration of multiples frames, one for each geometry

Parameters:
  • lst_data – list of numpy array

  • npt – number of points int the integration

  • correctSolidAngle – correct for solid angle (all processing are then done in absolute solid angle !)

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • error_model (str) – When the variance is unknown, an error model can be given: “poisson” (variance = I), “azimuthal” (variance = (I-<I>)^2)

  • polarization_factor – Apply polarization correction ? is None: not applies. Else provide a value from -1 to +1

  • normalization_factor – normalization monitors value (list of floats)

  • all – return a dict with all information in it (deprecated, please refer to the documentation of Integrate2dResult).

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method – integration method (or its name)

Returns:

I/2th/chi or a dict with everything depending on “all”

Return type:

Integrate2dResult, dict

property nb_geometry#
reset(collect_garbage=True)#

Clean up all caches for all integrators, resets the thread-pool as well.

Parameters:

collect_garbage – set to False to prevent garbage collection, faster

set_wavelength(value)#
property wavelength#
class pyFAI.multi_geometry.MultiGeometryFiber(fis, unit=('qip_nm^-1', 'qoop_nm^-1'), ip_range=None, oop_range=None, incident_angle=None, tilt_angle=None, sample_orientation=None, wavelength=None, empty=0.0, chi_disc=180, threadpoolsize=4)#

Bases: object

This is a Fiber integrator containing multiple geometries, for example when the detector is on a goniometer arm

__init__(fis, unit=('qip_nm^-1', 'qoop_nm^-1'), ip_range=None, oop_range=None, incident_angle=None, tilt_angle=None, sample_orientation=None, wavelength=None, empty=0.0, chi_disc=180, threadpoolsize=4)#

Constructor of the multi-geometry integrator

Parameters:
  • ais – list of azimuthal integrators

  • ip_range – (2-tuple) in-plane range for integration

  • oop_range – (2-tuple) out-of-plane range for integration

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-4, four different orientation of the fiber axis regarding the detector main axis, from 1 to 4 is +90º

  • empty – value for empty pixels

  • chi_disc – if 0, set the chi_discontinuity at 0, else π

  • threadpoolsize – By default, use a thread-pool to parallelize histogram/CSC integrator over as many threads as cores, set to False/0 to serialize

integrate1d(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, vertical_integration=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 1D fiber integration of multiples frames, one for each geometry, It wraps the method integrate_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate1d_fiber(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, vertical_integration=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 1D fiber integration of multiples frames, one for each geometry, It wraps the method integrate_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate1d_grazing_incidence(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, vertical_integration=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 1D fiber integration of multiples frames, one for each geometry, It wraps the method integrate_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate2d(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 2D azimuthal integration of multiples frames, one for each geometry, It wraps the method integrate2d_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • sample_orientation (int) – 1-4, four different orientation of the fiber axis regarding the detector main axis, from 1 to 4 is +90º

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate2d_fiber(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 2D azimuthal integration of multiples frames, one for each geometry, It wraps the method integrate2d_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • sample_orientation (int) – 1-4, four different orientation of the fiber axis regarding the detector main axis, from 1 to 4 is +90º

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate2d_grazing_incidence(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 2D azimuthal integration of multiples frames, one for each geometry, It wraps the method integrate2d_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • unit_ip (pyFAI.units.UnitFiber/str) – unit to describe the in-plane axis. If not provided, it takes qip_nm^-1

  • ip_range (list) – The lower and upper range of the in-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • unit_oop (pyFAI.units.UnitFiber/str) – unit to describe the out-of-plane axis. If not provided, it takes qoop_nm^-1

  • oop_range (list) – The lower and upper range of the out-of-plane unit. If not provided, range is simply (data.min(), data.max()). Values outside the range are ignored. Optional.

  • sample_orientation (int) – 1-4, four different orientation of the fiber axis regarding the detector main axis, from 1 to 4 is +90º

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

regrouped intensity and unit arrays

Return type:

Integrate2dResult

integrate_fiber(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, vertical_integration=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 1D fiber integration of multiples frames, one for each geometry, It wraps the method integrate_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

integrate_grazing_incidence(lst_data, npt_ip=1000, npt_oop=1000, correctSolidAngle=True, vertical_integration=True, lst_mask=None, dummy=None, delta_dummy=None, lst_variance=None, polarization_factor=None, dark=None, lst_flat=None, method=('no', 'histogram', 'cython'), normalization_factor=1.0, **kwargs)#

Performs 1D fiber integration of multiples frames, one for each geometry, It wraps the method integrate_fiber of pyFAI.integrator.fiber.FiberIntegrator

Parameters:
  • lst_data – list of numpy array

  • npt_ip (int) – number of points to be used along the in-plane axis

  • npt_oop (int) – number of points to be used along the out-of-plane axis

  • vertical_integration (bool) – If True, integrates along unit_ip; if False, integrates along unit_oop

  • correctSolidAngle (bool) – correct for solid angle of each pixel if True

  • lst_mask – numpy.Array or list of numpy.array which mask the lst_data.

  • dummy (float) – value for dead/masked pixels

  • delta_dummy (float) – precision for dummy value

  • lst_variance (list of ndarray) – list of array containing the variance of the data. If not available, no error propagation is done

  • polarization_factor (float) – polarization factor between -1 (vertical) and +1 (horizontal). * 0 for circular polarization or random, * None for no correction, * True for using the former correction

  • dark (ndarray) – dark noise image

  • lst_flat – numpy.Array or list of numpy.array which flat the lst_data.

  • method (IntegrationMethod) – IntegrationMethod instance or 3-tuple with (splitting, algorithm, implementation)

  • normalization_factor (float) – Value of a normalization monitor

Returns:

chi bins center positions and regrouped intensity

Return type:

Integrate1dResult

reset(collect_garbage=True)#

Clean up all caches for all integrators, resets the thread-pool as well.

Parameters:

collect_garbage – set to False to prevent garbage collection, faster

set_wavelength(value)#

Changes the wavelength of a group of fiber integrators

geometryRefinement Module#

Module used to perform the geometric refinement of the model

class pyFAI.geometryRefinement.GeometryRefinement(data=None, calibrant=None, dist=1, poni1=None, poni2=None, rot1=0, rot2=0, rot3=0, pixel1=None, pixel2=None, splinefile=None, detector=None, wavelength=None, **kwargs)#

Bases: AzimuthalIntegrator

PARAM_ORDER = ('dist', 'poni1', 'poni2', 'rot1', 'rot2', 'rot3', 'wavelength')#
__init__(data=None, calibrant=None, dist=1, poni1=None, poni2=None, rot1=0, rot2=0, rot3=0, pixel1=None, pixel2=None, splinefile=None, detector=None, wavelength=None, **kwargs)#
Parameters:
  • data – ndarray float64 shape = n, 3 col0: pos in dim0 (in pixels) col1: pos in dim1 (in pixels) col2: ring index in calibrant object

  • calibrant – instance of pyFAI.calibrant.Calibrant containing the d-Spacing

  • dist – guessed sample-detector distance (optional, in m)

  • poni1 – guessed PONI coordinate along the Y axis (optional, in m)

  • poni2 – guessed PONI coordinate along the X axis (optional, in m)

  • rot1 – guessed tilt of the detector around the Y axis (optional, in rad)

  • rot2 – guessed tilt of the detector around the X axis (optional, in rad)

  • rot3 – guessed tilt of the detector around the incoming beam axis (optional, in rad)

  • pixel1 – Pixel size along the vertical direction of the detector (in m), almost mandatory

  • pixel2 – Pixel size along the horizontal direction of the detector (in m), almost mandatory

  • splinefile – file describing the detector as 2 cubic splines. Replaces pixel1 & pixel2

  • detector – name of the detector or Detector instance. Replaces splineFile, pixel1 & pixel2

  • wavelength – wavelength in m (1.54e-10)

anneal(maxiter=1000000)#
calc_2th(rings, wavelength=None)#
Parameters:
  • rings – indices of the rings. starts at 0 and self.dSpacing should be long enough !!!

  • wavelength – wavelength in meter

calc_param7(param, free, const)#

Calculate the “legacy” 6/7 parameters from a number of free and fixed parameters

chi2(param=None)#
chi2_wavelength(param=None)#
confidence(with_rot=True)#

Confidence interval obtained from the second derivative of the error function next to its minimum value.

Note the confidence interval increases with the number of points which is “surprising”

Parameters:

with_rot – if true include rot1 & rot2 in the parameter set.

Returns:

std_dev, confidence

curve_fit(with_rot=True)#

Refine the geometry and provide confidence interval Use curve_fit from scipy.optimize to not only refine the geometry (unconstrained fit)

Parameters:

with_rot – include rotation intro error measurement

Returns:

std_dev, confidence

property dist_max#
property dist_min#
get_dist_max()#
get_dist_min()#
get_poni1_max()#
get_poni1_min()#
get_poni2_max()#
get_poni2_min()#
get_rot1_max()#
get_rot1_min()#
get_rot2_max()#
get_rot2_min()#
get_rot3_max()#
get_rot3_min()#
get_wavelength_max()#
get_wavelength_min()#
guess_poni(fixed=None)#

PONI can be guessed by the centroid of the ring with lowest 2Theta

It may try to fit an ellipse and sometimes it works

property poni1_max#
property poni1_min#
property poni2_max#
property poni2_min#
refine1()#
refine2(maxiter=1000000, fix=None)#
refine2_wavelength(maxiter=1000000, fix=None)#

Refine all parameters including the wavelength.

This implies that it enforces an upper limit to the wavelength depending on the number of rings.

refine3(maxiter=1000000, fix=None)#

Same as refine2 except it does not rely on upper_bound == lower_bound to fix parameters

This is a work around the regression introduced with scipy 1.5

Parameters:
  • maxiter – maximum number of iteration for finding the solution

  • fix – parameters to be fixed. Does not assume the wavelength to be fixed by default

Returns:

$sum_(2 heta_e-2 heta_i)²$

residu1(param, d1, d2, rings)#
residu1_wavelength(param, d1, d2, rings)#
residu2(param, d1, d2, rings)#
residu2_wavelength(param, d1, d2, rings)#
residu2_wavelength_weighted(param, d1, d2, rings, weight)#
residu2_weighted(param, d1, d2, rings, weight)#
residu3(param, free, const, d1, d2, rings, weights=None)#

Perform the calculation of $sum_(2 heta_e-2 heta_i)²$

roca()#

run roca to optimise the parameter set

property rot1_max#
property rot1_min#
property rot2_max#
property rot2_min#
property rot3_max#
property rot3_min#
set_dist_max(value)#
set_dist_min(value)#
set_poni1_max(value)#
set_poni1_min(value)#
set_poni2_max(value)#
set_poni2_min(value)#
set_rot1_max(value)#
set_rot1_min(value)#
set_rot2_max(value)#
set_rot2_min(value)#
set_rot3_max(value)#
set_rot3_min(value)#
set_tolerance(value=10)#

Set the tolerance for a refinement of the geometry; in percent of the original value

Parameters:

value – Tolerance as a percentage

set_wavelength_max(value)#
set_wavelength_min(value)#
simplex(maxiter=1000000)#
update_values(dist=None, wavelength=None, poni1=None, poni2=None, rot1=None, rot2=None, rot3=None, fixed=None)#

Update values taking care of fixed parameters.

property wavelength_max#
property wavelength_min#

goniometer Module#

Everything you need to calibrate a detector mounted on a goniometer or any translation table

class pyFAI.goniometer.BaseTransformation(funct, param_names, pos_names=None)#

Bases: object

This class, once instantiated, behaves like a function (via the __call__ method). It is responsible for taking any input geometry and translate it into a set of parameters compatible with pyFAI, i.e. a tuple with: (dist, poni1, poni2, rot1, rot2, rot3)

This class relies on a user provided function which does the work.

__init__(funct, param_names, pos_names=None)#

Constructor of the class

Parameters:
  • funct – function which takes as parameter the param_names and the pos_name

  • param_names – list of names of the parameters used in the model

  • pos_names – list of motor names for gonio with >1 degree of freedom

to_dict()#

Export the instance representation for serialization as a dictionary

class pyFAI.goniometer.ExtendedTransformation(dist_expr=None, poni1_expr=None, poni2_expr=None, rot1_expr=None, rot2_expr=None, rot3_expr=None, wavelength_expr=None, param_names=None, pos_names=None, constants=None, content=None)#

Bases: object

This class behaves like GeometryTransformation and extends transformation to the wavelength parameter.

This function uses numexpr for formula evaluation.

__init__(dist_expr=None, poni1_expr=None, poni2_expr=None, rot1_expr=None, rot2_expr=None, rot3_expr=None, wavelength_expr=None, param_names=None, pos_names=None, constants=None, content=None)#

Constructor of the class

Parameters:
  • dist_expr – formula (as string) providing with the dist

  • poni1_expr – formula (as string) providing with the poni1

  • poni2_expr – formula (as string) providing with the poni2

  • rot1_expr – formula (as string) providing with the rot1

  • rot2_expr – formula (as string) providing with the rot2

  • rot3_expr – formula (as string) providing with the rot3

  • wavelength_expr – formula (as a string) to calculate wavelength used in angstrom

  • param_names – list of names of the parameters used in the model

  • pos_names – list of motor names for gonio with >1 degree of freedom

  • constants – a dictionary with some constants the user may want to use

  • content – Should be None or the name of the class (may be used in the future to dispatch to multiple derivative classes)

to_dict()#

Export the instance representation for serialization as a dictionary

class pyFAI.goniometer.GeometryTransformation(dist_expr, poni1_expr, poni2_expr, rot1_expr, rot2_expr, rot3_expr, param_names, pos_names=None, constants=None, content=None)#

Bases: object

This class, once instantiated, behaves like a function (via the __call__ method). It is responsible for taking any input geometry and translate it into a set of parameters compatible with pyFAI, i.e. a tuple with: (dist, poni1, poni2, rot1, rot2, rot3) This function uses numexpr for formula evaluation.

__init__(dist_expr, poni1_expr, poni2_expr, rot1_expr, rot2_expr, rot3_expr, param_names, pos_names=None, constants=None, content=None)#

Constructor of the class

Parameters:
  • dist_expr – formula (as string) providing with the dist

  • poni1_expr – formula (as string) providing with the poni1

  • poni2_expr – formula (as string) providing with the poni2

  • rot1_expr – formula (as string) providing with the rot1

  • rot2_expr – formula (as string) providing with the rot2

  • rot3_expr – formula (as string) providing with the rot3

  • param_names – list of names of the parameters used in the model

  • pos_names – list of motor names for gonio with >1 degree of freedom

  • constants – a dictionary with some constants the user may want to use

  • content – Should be None or the name of the class (may be used in the future to dispatch to multiple derivative classes)

property dist_expr#
property poni1_expr#
property poni2_expr#
property rot1_expr#
property rot2_expr#
property rot3_expr#
to_dict()#

Export the instance representation for serialization as a dictionary

pyFAI.goniometer.GeometryTranslation#

alias of GeometryTransformation

class pyFAI.goniometer.Goniometer(param, trans_function, detector='Detector', wavelength=None, param_names=None, pos_names=None)#

Bases: object

This class represents the goniometer model. Unlike this name suggests, it may include translation in addition to rotations

__init__(param, trans_function, detector='Detector', wavelength=None, param_names=None, pos_names=None)#

Constructor of the Goniometer class.

Parameters:
  • param – vector of parameter to refine for defining the detector position on the goniometer

  • trans_function – function taking the parameters of the goniometer and the goniometer position and return the 6 parameters [dist, poni1, poni2, rot1, rot2, rot3]

  • detector – detector mounted on the moving arm

  • wavelength – the wavelength used for the experiment

  • param_names – list of names to “label” the param vector.

  • pos_names – list of names to “label” the position vector of the gonio.

file_version = 'Goniometer calibration v2'#
get_ai(position)#

Creates an azimuthal integrator from the motor position

Parameters:

position – the goniometer position, a float for a 1 axis goniometer

Returns:

A freshly build AzimuthalIntegrator

get_mg(positions, unit='2th_deg', radial_range=(0, 180), azimuth_range=(-180, 180), empty=0.0, chi_disc=180)#

Creates a MultiGeometry integrator from a list of goniometer positions.

Parameters:
  • positions – A list of goniometer positions

  • radial_range – common range for integration

  • azimuthal_range – common range for integration

  • empty – value for empty pixels

  • chi_disc – if 0, set the chi_discontinuity at 0, else pi

Returns:

A freshly build multi-geometry

get_wavelength() float#

Get the current wavelength, checking if it depends on motors.

save(filename)#

Save the goniometer configuration to file

Parameters:

filename – name of the file to save configuration to

set_wavelength(value: float) None#

Set the wavelength if it is not a fitted parameter.

classmethod sload(filename)#

Class method for instantiating a Goniometer object from a JSON file

Parameters:

filename – name of the JSON file

Returns:

Goniometer object

to_dict()#

Export the goniometer configuration to a dictionary

Returns:

Ordered dictionary

property wavelength: float#

Get the current wavelength, checking if it depends on motors.

write(filename)#

Save the goniometer configuration to file

Parameters:

filename – name of the file to save configuration to

class pyFAI.goniometer.GoniometerRefinement(param, pos_function, trans_function, detector='Detector', wavelength=None, param_names=None, pos_names=None, bounds=None)#

Bases: Goniometer

This class allow the translation of a goniometer geometry into a pyFAI geometry using a set of parameter to refine.

__init__(param, pos_function, trans_function, detector='Detector', wavelength=None, param_names=None, pos_names=None, bounds=None)#

Constructor of the GoniometerRefinement class

Parameters:
  • param – vector of parameter to refine for defining the detector position on the goniometer

  • pos_function – a function taking metadata and extracting the goniometer position

  • trans_function – function taking the parameters of the goniometer and the gonopmeter position and return the 6/7 parameters [dist, poni1, poni2, rot1, rot2, rot3, wavelength]

  • detector – detector mounted on the moving arm

  • wavelength – the wavelength used for the experiment

  • param_names – list of names to “label” the param vector.

  • pos_names – list of names to “label” the position vector of the gonio.

  • bounds – list of 2-tuple with the lower and upper bound of each function

calc_param3(fit_param, free, const)#

Function that calculate the param vector

Parameters:
  • fit_param – numpy array of float

  • free – names of the free parameters, array of same size as fit_param

  • const – dict with constant (non-fitted) parameters

Returns:

the parameter vector as in self.param

chi2(param=None)#

Calculate the average of the square of the error for a given parameter set

get_wavelength() float#

Get the wavelength using the Goniometer logic.

new_geometry(label, image=None, metadata=None, control_points=None, calibrant=None, geometry=None)#

Add a new geometry for calibration

Parameters:
  • label – usually a string

  • image – 2D numpy array with the Debye scherrer rings

  • metadata – some metadata

  • control_points – an instance of ControlPoints

  • calibrant – the calibrant used for calibrating

  • geometry – poni or AzimuthalIntegrator instance.

refine2(method='slsqp', **options)#

Geometry refinement tool

See https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.minimize.html

Nota: When upper and lower bounds are equal, the jacobian gets NaN since scipy 1.5.

Parameters:
  • method – name of the minimizer

  • options – options for the minimizer

Returns:

refined set of parameter

refine3(fix=None, method='slsqp', verbose=True, **options)#

Geometry refinement tool

Parameters:
  • fixed – list of parameters to be fixed (others are left free for refinement)

  • method – name of the minimizer

  • options – options for the minimizer

Returns:

refined set of parameter

residu2(param)#

Actually performs the calculation of the average of the error squared

residu3(fit_param, free, const)#

Evaluate the cost function:

Parameters:
  • fit_param – numpy array of float

  • free – names of the free parameters, array of same size as fit_param

  • const – dict with constant (non-fitted) parameters

Returns:

cost function value

set_bounds(name, mini=None, maxi=None)#

Redefines the bounds for the refinement

Parameters:
  • name – name of the parameter or index in the parameter set

  • mini – minimum value

  • maxi – maximum value

set_wavelength(value: float) None#

Set the wavelength using Goniometer logic, and propagate to single geometries.

classmethod sload(filename, pos_function=None)#

Class method for instantiating a Goniometer object from a JSON file

Parameters:
  • filename – name of the JSON file

  • pos_function – a function taking metadata and extracting the goniometer position

Returns:

Goniometer object

property wavelength: float#

Get the wavelength using the Goniometer logic.

class pyFAI.goniometer.PoniParam(dist, poni1, poni2, rot1, rot2, rot3)#

Bases: tuple

dist#

Alias for field number 0

poni1#

Alias for field number 1

poni2#

Alias for field number 2

rot1#

Alias for field number 3

rot2#

Alias for field number 4

rot3#

Alias for field number 5

class pyFAI.goniometer.SingleGeometry(label, image=None, metadata=None, pos_function=None, control_points=None, calibrant=None, detector=None, geometry=None)#

Bases: object

This class represents a single geometry of a detector position on a goniometer arm

__init__(label, image=None, metadata=None, pos_function=None, control_points=None, calibrant=None, detector=None, geometry=None)#

Constructor of the SingleGeometry class, used for calibrating a multi-geometry setup with a moving detector.

Parameters:
  • label – name of the geometry, a string or anything immutable

  • image – image with Debye-Scherrer rings as 2d numpy array

  • metadata – anything which contains the goniometer position

  • pos_function – a function which takes the metadata as input and returns the goniometer arm position

  • control_points – a pyFAI.control_points.ControlPoints instance (optional parameter)

  • calibrant – a pyFAI.calibrant.Calibrant instance. Contains the wavelength to be used (optional parameter)

  • detector – a pyFAI.detectors.Detector instance or something like that Contains the mask to be used (optional parameter)

  • geometry – an azimuthal integrator or a ponifile (or a dict with the geometry) (optional parameter)

extract_cp(max_rings=None, pts_per_deg=1.0, Imin=0)#

Performs an automatic keypoint extraction and update the geometry refinement part

Parameters:
  • max_ring – extract at most N rings from the image

  • pts_per_deg – number of control points per azimuthal degree (increase for better precision)

get_ai()#

Create a new azimuthal integrator to be used.

Returns:

Azimuthal Integrator instance

get_position()#

This method is in charge of calculating the motor position from metadata/label/…

get_wavelength() float#

Get or set the wavelength, ensuring consistency between calibrant and geometry_refinement.

set_wavelength(value: float) None#
property wavelength: float#

Get or set the wavelength, ensuring consistency between calibrant and geometry_refinement.

spline Module#

This is piece of software aims at manipulating spline files describing for geometric corrections of the 2D detectors using cubic-spline.

Mainly used at ESRF with FReLoN CCD camera.

class pyFAI.spline.Spline(filename=None)#

Bases: object

This class is a python representation of the spline file

Those file represent cubic splines for 2D detector distortions and makes heavy use of fitpack (dierckx in netlib) — A Python-C wrapper to FITPACK (by P. Dierckx). FITPACK is a collection of FORTRAN programs for curve and surface fitting with splines and tensor product splines. See _http://www.cs.kuleuven.ac.be/cwis/research/nalag/research/topics/fitpack.html or _http://www.netlib.org/dierckx/index.html

__init__(filename=None)#

This is the constructor of the Spline class.

Parameters:

filename (str) – name of the ascii file containing the spline

array2spline(smoothing=1000, timing=False)#

Calculates the spline coefficients from the displacements matrix using fitpack.

Parameters:
  • smoothing (float) – the greater the smoothing, the fewer the number of knots remaining

  • timing (bool) – print the profiling of the calculation

bin(binning=None)#

Performs the binning of a spline (same camera with different binning)

Parameters:

binning – binning factor as integer or 2-tuple of integers

Type:

int or (int, int)

comparison(ref, verbose=False)#

Compares the current spline distortion with a reference

Parameters:
  • ref (Spline) – another spline file

  • verbose (bool) – print or not pylab plots

Returns:

True or False depending if the splines are the same or not

Return type:

bool

correct(pos)#
fliplr(fit=True)#

Flip the spline horizontally

Parameters:

fit (bool) – set to False to disable fitting of the coef, or provide a value for the smoothing factor

Returns:

new spline object

fliplrud(fit=True)#

Flip the spline upside-down and horizontally

Parameters:

fit (bool) – set to False to disable fitting of the coef, or provide a value for the smoothing factor

Returns:

new spline object

flipud(fit=True)#

Flip the spline upside-down

Parameters:

fit (bool) – set to False to disable fitting of the coef, or provide a value for the smoothing factor

Returns:

new spline object

getDetectorSize()#

Returns the size of the detector.

Return type:

Tuple[int,int]

Returns:

Size y then x

getPixelSize()#

Return the size of the pixel from as a 2-tuple of floats expressed in meters.

Returns:

the size of the pixel from a 2D detector

Return type:

2-tuple of floats expressed in meter.

read(filename)#

read an ascii spline file from file

Parameters:

filename (str) – file containing the cubic spline distortion file

setPixelSize(pixelSize)#

Sets the size of the pixel from a 2-tuple of floats expressed in meters.

Param:

pixel size in meter

spline2array(timing=False)#

Calculates the displacement matrix using fitpack bisplev(x, y, tck, dx = 0, dy = 0)

Parameters:

timing (bool) – profile the calculation or not

Returns:

xDispArray, yDispArray

Return type:

2-tuple of ndarray

Evaluate a bivariate B-spline and its derivatives. Return a rank-2 array of spline function values (or spline derivative values) at points given by the cross-product of the rank-1 arrays x and y. In special cases, return an array or just a float if either x or y or both are floats.

splineFuncX(x, y, list_of_points=False)#

Calculates the displacement matrix using fitpack for the X direction on the given grid.

Parameters:
  • x (ndarray) – points of the grid in the x direction

  • y (ndarray) – points of the grid in the y direction

  • list_of_points – if true, consider the zip(x,y) instead of the of the square array

Returns:

displacement matrix for the X direction

Return type:

ndarray

splineFuncY(x, y, list_of_points=False)#

calculates the displacement matrix using fitpack for the Y direction

Parameters:
  • x (ndarray) – points in the x direction

  • y (ndarray) – points in the y direction

  • list_of_points – if true, consider the zip(x,y) instead of the of the square array

Returns:

displacement matrix for the Y direction

Return type:

ndarray

tilt(center=(0.0, 0.0), tiltAngle=0.0, tiltPlanRot=0.0, distanceSampleDetector=1.0, timing=False)#

The tilt method apply a virtual tilt on the detector, the point of tilt is given by the center

Parameters:
  • center (2-tuple of floats) – position of the point of tilt, this point will not be moved.

  • tiltAngle (float in the range [-90:+90] degrees) – the value of the tilt in degrees

  • tiltPlanRot (Float in the range [-180:180]) – the rotation of the tilt plan with the Ox axis (0 deg for y axis invariant, 90 deg for x axis invariant)

  • distanceSampleDetector (float) – the distance from sample to detector in meter (along the beam, so distance from sample to center)

Returns:

tilted Spline instance

Return type:

Spline

write(filename)#

save the cubic spline in an ascii file usable with Fit2D or SPD

Parameters:

filename (str) – name of the file containing the cubic spline distortion file

writeEDF(basename)#

save the distortion matrices into a couple of files called basename-x.edf and basename-y.edf

Parameters:

basename (str) – base of the name used to save the data

zeros(xmin=0.0, ymin=0.0, xmax=2048.0, ymax=2048.0, pixSize=None)#

Defines a spline file with no ( zero ) displacement.

Parameters:
  • xmin (float) – minimum coordinate in x, usually zero

  • xmax (float) – maximum coordinate in x (+1) usually 2048

  • ymin (float) – minimum coordinate in y, usually zero

  • ymax (float) – maximum coordinate y (+1) usually 2048

  • pixSize (float) – size of the pixel

zeros_like(other)#

Defines a spline file with no ( zero ) displacement with the same shape as the other one given.

Parameters:

other (Spline instance) – another Spline instance

control_points Module#

ControlPoints: a set of control points associated with a calibration image

PointGroup: a group of points

class pyFAI.control_points.ControlPoints(filename=None, calibrant=None, wavelength=None)#

Bases: object

This class contains a set of control points with (optionally) their ring number hence d-spacing and diffraction 2Theta angle…

__init__(filename=None, calibrant=None, wavelength=None)#
append(points, ring=None, annotate=None, plot=None)#

Append a group of points to a given ring

Parameters:
  • point – list of points

  • ring – ring number

  • annotate – matplotlib.annotate reference

  • plot – matplotlib.plot reference

Returns:

PointGroup instance

append_2theta_deg(points, angle=None, ring=None)#

Append a group of points to a given ring

Parameters:
  • point – list of points

  • angle – 2-theta angle in degrees

Param:

ring: ring number

check()#

check internal consistency of the class, disabled for now

property dspacing#
get(ring=None, lbl=None)#

Retrieves the last group of points for a given ring (by default the last)

Parameters:
  • ring – index of ring to search for

  • lbl – label of the group to retrieve

getList()#

Retrieve the list of control points suitable for geometry refinement with ring number

getList2theta()#

Retrieve the list of control points suitable for geometry refinement

getListRing()#

Retrieve the list of control points suitable for geometry refinement with ring number

getWeightedList(image)#

Retrieve the list of control points suitable for geometry refinement with ring number and intensities :param image: :return: a (x,4) array with pos0, pos1, ring nr and intensity

#TODO: refine the value of the intensity using 2nd order polynomia

get_dSpacing()#
get_labels()#

Retrieve the list of labels

Returns:

list of labels as string

get_wavelength()#
load(filename)#

load all control points from a file

pop(ring=None, lbl=None)#

Remove the set of points, either from its code or from a given ring (by default the last)

Parameters:
  • ring – index of ring of which remove the last group

  • lbl – code of the ring to remove

readRingNrFromKeyboard()#

Ask the ring number values for the given points

reset()#

remove all stored values and resets them to default

save(filename)#

Save a set of control points to a file :param filename: name of the file :return: None

setWavelength_change2th(value=None)#
setWavelength_changeDs(value=None)#

This is probably not a good idea, but who knows !

set_dSpacing(lst)#
set_wavelength(value=None)#
property wavelength#
class pyFAI.control_points.PointGroup(points=None, ring=None, annotate=None, plot=None, force_label=None)#

Bases: object

Class contains a group of points … They all belong to the same Debye-Scherrer ring

__init__(points=None, ring=None, annotate=None, plot=None, force_label=None)#

Constructor

Parameters:
  • points – list of points

  • ring – ring number

  • annotate – reference to the matplotlib annotate output

  • plot – reference to the matplotlib plot

  • force_label – allows to enforce the label

property code#

Numerical value for the label: mainly for sorting

classmethod get_label()#

return the next label

get_ring() int#
property label#
last_label = 0#
classmethod reset_label()#

reset internal counter

property ring: int#
classmethod set_label(label)#

update the internal counter if needed

set_ring(value: int) None#

massif Module#

class pyFAI.massif.Massif(data=None, mask=None, median_prefilter=False)#

Bases: object

A massif is defined as an area around a peak, it is used to find neighboring peaks

TARGET_SIZE = 1024#
__init__(data=None, mask=None, median_prefilter=False)#

Constructor of the Massif class

Parameters:
  • data – 2D array or filename (discouraged)

  • mask – array with non zero for invalid data

  • median_prefilter – apply a 3x3 median prefilter to the data to sieve out outliers

calculate_massif(x)#

defines a map of the massif around x and returns the mask

property cleaned_data#
find_peaks(x, nmax=200, annotate=None, massif_contour=None, stdout=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)#

All in one function that finds a maximum from the given seed (x) then calculates the region extension and extract position of the neighboring peaks.

Parameters:
  • x (Tuple[int]) – coordinates of the peak, seed for the calculation

  • nmax (int) – maximum number of peak per region

  • annotate – callback method taking number of points + coordinate as input.

  • massif_contour – callback to show the contour of a massif with the given index.

  • stdout – this is the file where output is written by default.

Returns:

list of peaks

get_binned_data()#
Returns:

binned data

get_blurred_data()#
Returns:

a blurred image

get_labeled_massif(pattern=None, reconstruct=True)#
Parameters:
  • pattern – 3x3 matrix

  • reconstruct – if False, split massif at masked position, else reconstruct missing part.

Returns:

an image composed of int with a different value for each massif

get_median_data()#
Returns:

a spatial median filtered image 3x3

init_valley_size()#
log_info#

If true, more information is displayed in the logger relative to picking.

nearest_peak(x)#
Parameters:

x – coordinates of the peak

Returns:

the coordinates of the nearest peak

peaks_from_area(mask, Imin=np.float64(-1.7976931348623157e+308), keep=1000, dmin=0.0, seed=None, **kwarg)#

Return the list of peaks within an area

Parameters:
  • mask – 2d array with mask.

  • Imin – minimum of intensity above the background to keep the point

  • keep – maximum number of points to keep

  • kwarg – ignored parameters

  • dmin – minimum distance to another peak

  • seed – list of good guesses to start with

Returns:

list of peaks [y,x], [y,x], …]

property valley_size#

Defines the minimum distance between two massifs

blob_detection Module#

class pyFAI.blob_detection.BlobDetection(img, cur_sigma=0.25, init_sigma=0.5, dest_sigma=1, scale_per_octave=2, mask=None)#

Bases: object

Performs a blob detection: http://en.wikipedia.org/wiki/Blob_detection using a Difference of Gaussian + Pyramid of Gaussians

__init__(img, cur_sigma=0.25, init_sigma=0.5, dest_sigma=1, scale_per_octave=2, mask=None)#

Performs a blob detection: http://en.wikipedia.org/wiki/Blob_detection using a Difference of Gaussian + Pyramid of Gaussians

Parameters:
  • img – input image

  • cur_sigma – estimated smoothing of the input image. 0.25 correspond to no interaction between pixels.

  • init_sigma – start searching at this scale (sigma=0.5: 10% interaction with first neighbor)

  • dest_sigma – sigma at which the resolution is lowered (change of octave)

  • scale_per_octave – Number of scale to be performed per octave

  • mask – mask where pixel are not valid

direction()#

Perform and plot the two main directions of the peaks, considering their previously calculated scale ,by calculating the Hessian at different sizes as the combination of gaussians and their first and second derivatives

nearest_peak(p, refine=True, Imin=None)#

Return the nearest peak from a position

Parameters:
  • p – input position (y,x) 2-tuple of float

  • refine – shall the position be refined on the raw data

  • Imin – minimum of intensity above the background

peaks_from_area(mask, keep=None, refine=True, Imin=None, dmin=0.0, **kwargs)#

Return the list of peaks within an area

Parameters:
  • mask – 2d array with mask.

  • refine – shall the position be refined on the raw data

  • Imin – minimum of intensity above the background

  • kwarg – ignored parameters

Returns:

list of peaks [y,x], [y,x], …]

process(max_octave=None)#

Perform the keypoint extraction for max_octave cycles or until all octaves have been processed. :param max_octave: number of octave to process

refine_Hessian(kpx, kpy, kps)#

Refine the keypoint location based on a 3 point derivative, and delete non-coherent keypoints.

Parameters:
  • kpx – x_pos of keypoint

  • kpy – y_pos of keypoint

  • kps – s_pos of keypoint

Returns:

arrays of corrected coordinates of keypoints, values and locations of keypoints

refine_Hessian_SG(kpx, kpy, kps)#

Savitzky Golay algorithm to check if a point is really the maximum :param kpx: x_pos of keypoint :param kpy: y_pos of keypoint :param kps: s_pos of keypoint :return: array of corrected keypoints

refinement()#
show_neighboor()#
show_stats()#

Shows a window with the repartition of keypoint in function of scale/intensity

tresh = 0.6#
pyFAI.blob_detection.image_test()#
pyFAI.blob_detection.local_max(dogs, mask=None, n_5=True)#
Parameters:
  • dogs – 3d array with (sigma,y,x) containing difference of gaussians

  • mask – mask out keypoint next to the mask (or inside the mask)

  • n_5 – look for a larger neighborhood

pyFAI.blob_detection.make_gaussian(im, sigma, xc, yc)#

calibrant Module#

Calibrant

A module containing classical calibrant and also tools to generate d-spacing.

This class is mostly empty and is left for compatibility purposes. It should be DEPRECATED once modification related to crystallography are done and tutorial updated.

class pyFAI.calibrant.Calibrant(filename: str | None = None, dspacing: list[float] | None = None, wavelength: float | None = None, config: CalibrantConfig | None = None, **kwargs)#

Bases: object

A calibrant is a named reference compound where the d-spacing are known.

The d-spacing (interplanar distances) are expressed in Angstrom (in the file).

If the access is don’t from a file, the IO are delayed. If it is not desired one could explicitly access to load_file().

c = Calibrant()
c.load_file("my_calibrant.D")
Parameters:
  • filename – A filename containing the description (usually with .D extension). The access to the file description is delayed until the information is needed.

  • dspacing – A list of d spacing in Angstrom.

  • wavelength – A wavelength in meter

  • config – instance of pyFAI.io.calibrant_config.CalibrantConfig dataclass

__init__(filename: str | None = None, dspacing: list[float] | None = None, wavelength: float | None = None, config: CalibrantConfig | None = None, **kwargs)#
append_2th(value: float)#

Insert a 2th position at the right position of the dSpacing list

append_dSpacing(value: float)#

Insert a d position at the right position of the dspacing list

append_dspacing(value: float)#

Insert a d position at the right position of the dspacing list

count_registered_dSpacing() int#

Count of registered dspacing positions.

count_registered_dspacing() int#

Count of registered dspacing positions.

property dSpacing#
property dspacing: list[float]#
property energy#
fake_calibration_image(ai, shape: tuple | None = None, Imax: float = 1.0, Imin: float | ndarray = 0.0, resolution: _ResolutionFunction | float = 0.1, **kwargs) ndarray#

Generates a fake calibration image from an azimuthal integrator.

Parameters:
  • ai – azimuthal integrator

  • Imax – maximum intensity of rings

  • Imin – minimum intensity of the signal (background)

  • resolution – either the FWHM (static, in degree) or a pyFAI.crystallography.resolution._ResolutionFunction class instance

Deprecated options: :param U, V, W: width of the peak from Caglioti’s law (FWHM^2 = Utan(th)^2 + Vtan(th) + W) –> deprecated :return: an image

fake_xrpdp(nbpt: int = 1000, tth_range: tuple = (0, 120), background: float = 0.0, Imax: float = 1.0, resolution: float = 0.1, unit: ~pyFAI.units.Unit | str = 2th_deg)#

Generate a fake powder diffraction pattern from this calibrant

Parameters:
  • nbpt – number of point in the powder pattern

  • tth_range – diffraction angle 2theta, unit as specified in unit parameter, deg by default.

  • background – value or array (gonna be interpolated)

  • Imax – intensity of the scattering signal

  • resolution – pic width δ(°) or resolution function

  • unit – can be a string or an instance

Returns:

Integrate1dResult with unit in 2th_deg

property filename: str#
classmethod from_cell(cell)#

Alternative constructor from a cell-object

Parameters:

cell – Instance of Cell

Returns:

Calibrant instance

get_2th() list[float]#

Returns the 2theta positions for all peaks (cached)

get_2th_index(angle: float, delta: float | None = None) int#

Returns the index in the 2theta angle index.

Parameters:
  • angle – expected angle in radians

  • delta – precision on angle

Returns:

0-based index or None

get_dSpacing() list[float]#
get_filename() str#
get_max_wavelength(index: int | None = None)#

Calculate the maximum wavelength assuming the ring at index is visible.

Bragg’s law says: $lambda = 2d sin(theta)$ So at 180° $lambda = 2d$

Parameters:

index – Ring number, otherwise assumes all rings are visible

Returns:

the maximum visible wavelength

get_peaks(unit: units.Units | str = 2th_deg)#

Calculate the peak position as this unit.

Returns:

numpy array (unlike other methods which return lists)

load_file(filename: str)#

Load a calibrant.from file.

Parameters:

filename – The filename containing the calibrant description.

property name: str#

Returns a short name describing the calibrant.

It’s the name of the file or the resource.

save_dSpacing(filename: str | None = None)#

Save the d-spacing into a file.

Parameters:

filename – name of the file

Returns:

None

save_dspacing(filename: str | None = None)#

Save the d-spacing into a file.

Parameters:

filename – name of the file

Returns:

None

setWavelength_change2th(value: float | None = None)#

Set a new wavelength.

setWavelength_changeDs(value: float | None = None)#

Set a new wavelength and only update the dSpacing list.

This is probably not a good idea, but who knows!

set_wavelength(value: float | None = None)#

Set a new wavelength .

property wavelength: float | None#

Returns the used wavelength.

class pyFAI.calibrant.Cell(a: float = 1.0, b: float = 1.0, c: float = 1.0, alpha: float = 90.0, beta: float = 90.0, gamma: float = 90.0, lattice: str = 'triclinic', lattice_type: str = 'P')#

Bases: object

This is a cell object, able to calculate the volume and d-spacing according to formula from:

http://geoweb3.princeton.edu/research/MineralPhy/xtalgeometry.pdf

__init__(a: float = 1.0, b: float = 1.0, c: float = 1.0, alpha: float = 90.0, beta: float = 90.0, gamma: float = 90.0, lattice: str = 'triclinic', lattice_type: str = 'P')#

Constructor of the Cell class:

Crystallographic units are Angstrom for distances and degrees for angles !

Parameters:
  • a,b,c – unit cell length in Angstrom

  • gamma (alpha, beta,) – unit cell angle in degrees

  • lattice – “cubic”, “tetragonal”, “hexagonal”, “rhombohedral”, “orthorhombic”, “monoclinic”, “triclinic”

  • lattice_type – P, I, F, C or R

build_calibrant_config(dmin=1.0)#

Build a CalibrantConfig from the cell

calculate_dspacing(dmin=1.0)#

Calculate all d-spacing down to dmin

Applies registered selection rules

Parameters:

dmin – minimum value of spacing requested

Returns:

dict d-spacing as string, list of tuple with Miller indices preceded with the numerical value

classmethod cubic(a, lattice_type='P')#

Factory for cubic lattices

Parameters:

a – unit cell length

d(hkl: tuple | Miller) float#

Calculate the actual d-spacing for a 3-tuple of integer representing a family of Miller plans

Parameters:

hkl – 3-tuple of integers

Returns:

the inter-planar distance in Angstrom

classmethod diamond(a)#

Factory for Diamond type FCC like Si and Ge

Parameters:

a – unit cell length

get_type(lattice_type)#
classmethod hexagonal(a, c, lattice_type='P')#

Factory for hexagonal lattices

Parameters:
  • a – unit cell length

  • c – unit cell length

lattices = ('cubic', 'tetragonal', 'hexagonal', 'rhombohedral', 'orthorhombic', 'monoclinic', 'triclinic')#
classmethod monoclinic(a, b, c, beta, lattice_type='P')#

Factory for hexagonal lattices

Parameters:
  • a – unit cell length

  • b – unit cell length

  • c – unit cell length

  • beta – unit cell angle

classmethod orthorhombic(a, b, c, lattice_type='P')#

Factory for orthorhombic lattices

Parameters:
  • a – unit cell length

  • b – unit cell length

  • c – unit cell length

classmethod rhombohedral(a, alpha, lattice_type='P')#

Factory for hexagonal lattices

Parameters:
  • a – unit cell length

  • alpha – unit cell angle

save(name, long_name=None, doi=None, dmin=1.0, dest_dir=None)#

Save information about the cell in a d-spacing file, usable as Calibrant

Parameters:
  • name – name of the calibrant

  • doi – reference of the publication used to parametrize the cell

  • dmin – minimal d-spacing

  • dest_dir – name of the directory where to save the result

selection_rules#

contains a list of functions returning True(allowed)/False(forbidden)/None(unknown), see space_groups.py

set_type(lattice_type)#
classmethod tetragonal(a, c, lattice_type='P')#

Factory for tetragonal lattices

Parameters:
  • a – unit cell length

  • c – unit cell length

to_calibrant(dmin=1.0)#

Convert a Cell object to a Calibrant object

Parameters:

dmin – minimum d-spacing to include in calibrant (in Angstrom)

Returns:

Calibrant object

property type#
types: ClassVar[dict] = {'A': 'a-End centered', 'B': 'b-End centered', 'C': 'c-End centered', 'F': 'Face centered', 'I': 'Body centered', 'P': 'Primitive', 'R': 'Rhombohedral'}#
property volume#
class pyFAI.calibrant.ReflectionCondition#

Bases: object

This class contains selection rules for most space-groups

All methods are static and take a triplet hkl as input representing a family of Miller plans. They return True if the reflection is allowed by symmetry, False otherwise.

Most of those methods are AI-generated (Co-Pilot) and about 80% of them are still WRONG unless tagged “validated” in the docstring.

Help is welcome to polish this class and fix the non-validated ones.

static default(h: int, k: int, l: int) bool#

Default selection rule: h=k=l=0 is forbidden

static group100_P4bm(h: int, k: int, l: int) bool#

Space group 100: P4bm. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): h even [implied by symmetry] - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even [implied by symmetry] See ITC Vol. A, Section 2.1.3.13 (v) on reflection conditions for full compliance. See also http://img.chem.ucl.ac.uk/sgp/large/100az2.htm validated

static group101_P42cm(h: int, k: int, l: int) bool#

Space group 101: P42cm. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): l even - 00l (h=0, k=0): l even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/101az2.htm validated

static group102_P42nm(h: int, k: int, l: int) bool#

Space group 102: P42nm. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h + l even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/102az2.htm validated

static group103_P4cc(h: int, k: int, l: int) bool#

Space group 103: P4cc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): l even - hhl (h=k): l even - 00l (h=0, k=0): l even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/103az2.htm validated

static group104_P4nc(h: int, k: int, l: int) bool#

Space group 104: P4nc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l = 2n - h0l (k=0): h + l = 2n - hhl (h=k): l even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/104az2.htm validated

static group105_P42mc(h: int, k: int, l: int) bool#

Space group 105: P4₂mc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - hhl (h = k): l even - 00l (h = 0, k = 0): l even validated

static group106_P42bc(h: int, k: int, l: int) bool#

Space group 106: P4₂bc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): h even - hhl (h=k): l even - 00l (h=0, k=0): l even - h00 (h≠0, k=0, l=0): h even - 0k0 (h=0, k≠0, l=0): k even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/106az2.htm validated

static group107_I4mm(h: int, k: int, l: int) bool#

Space group 107: I4mm. Tetragonal. I-centering. Valid reflections must satisfy: - General kl: h + k + l = 2n - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=0,k=0): l even - h00 (k=0,l=0): h even validated

static group108_I4cm(h: int, k: int, l: int) bool#

Space group 108: I4cm. Tetragonal. I-centering. Valid reflections must satisfy: - General hkl: h + k + l even (I-centering) - hk0 (l=0): h + k even - 0kl (h=0): k, l even - hhl (h=k): l even - 00l (h=0,k=0): l even - h00 (k=0,l=0): h even - h0l (k=0): h, l even - 0k0 (h=0,l=0): k even Source for rules: http://img.chem.ucl.ac.uk/sgp/large/108az2.htm validated

static group109_I41md(h: int, k: int, l: int) bool#

Space group 109: I4₁md. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even (I-centering) - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): 2h + l= 4n - 00l (h=0,k=0): l= 4n - h00 (k=0,l=0): h even - hh0 (h=k,l=0): h even validated

static group10_P2m(h: int, k: int, l: int) bool#

Space group 10: P2/m. Monoclinic, unique axis b.

All reflections are allowed; no systematic absences. validated

static group110_I41cd(h: int, k: int, l: int) bool#

Space group 110: I4₁cd. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l = 2n - hk0 (l=0): h + k even - 0kl (h=0): k, l even - hhl (h=k): 2h + l = 4n - 00l (h=k=0): l = 4n - h00 (k=l=0): h even - hh̅0 (k=-h, l=0): h even - h0l (k=0): h, l even - 0k0 (h=0, l=0): k even - hh0 (h=k, l=0): h even Source for rules: Combination of ITC and http://img.chem.ucl.ac.uk/sgp/large/110az2.htm validated

static group111_P4bar_2m(h: int, k: int, l: int) bool#

Space group 111: P4̅2m. Tetragonal. Primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences validated

static group112_P4bar_2c(h: int, k: int, l: int) bool#

Space group 112: P4̅2c. Tetragonal. Primitive lattice. Valid reflections must satisfy: - hhl (h = k): l even - 00l (h = 0, k = 0): l even validated

static group113_P4bar_21m(h: int, k: int, l: int) bool#

Space group 113: P4̅2₁m. Tetragonal. Primitive lattice. Valid reflections must satisfy: - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even Source for rules: ITC and http://img.chem.ucl.ac.uk/sgp/large/113az2.htm validated

static group114_P4bar_21c(h: int, k: int, l: int) bool#

Space group 114: P4̅2₁c. Tetragonal. Primitive lattice. Valid reflections must satisfy: - hhl (h = k): l even - 00l (h = 0, k = 0): l even - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even Source for rules: ITC and http://img.chem.ucl.ac.uk/sgp/large/114az2.htm validated

static group115_P4bar_m2(h: int, k: int, l: int) bool#

Space group 115: P4̅m2. Tetragonal. Primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group116_P4bar_c2(h: int, k: int, l: int) bool#

Space group 116: P4̅c2. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h = 0): l even - 00l (h = 0, k = 0): l even - h0l (k = 0): l even Source for rules: ITC and http://img.chem.ucl.ac.uk/sgp/large/116az2.htm validated

static group117_P4bar_b2(h: int, k: int, l: int) bool#

Space group 117: P4̅b2. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h00 (k=0, l=0): h even - h0l (k=0): h even - 0k0 (h=0, l=0): k even Source for rules: ITC and http://img.chem.ucl.ac.uk/sgp/large/117az2.htm validated

static group118_P4bar_n2(h: int, k: int, l: int) bool#

Space group 118: P4̅n2. Tetragonal. Primitive lattice. Valid reflections must satisfy:

  • 0kl (h = 0): k + l even

  • h0l (k = 0): h + l even

  • h00 (k = 0, l = 0): h even

  • 0k0 (h = 0, l = 0): k even

  • 00l (h = 0, k = 0): l even

Source: http://img.chem.ucl.ac.uk/sgp/large/118az2.htm

static group119_I4bar_m2(h: int, k: int, l: int) bool#

Space group 119: I4̅m2. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l = 2n - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even Source: ITC validated

static group11_P21m(h: int, k: int, l: int) bool#

Space group 11: P2₁/m. Monoclinic, unique axis b.

Valid reflections must satisfy: - 0k0 (h = 0, l = 0): k even

Source: ITC validated

static group120_I4bar_c2(h: int, k: int, l: int) bool#

Space group 120: I4̅c2. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k even and l even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - h0l (k=0): h + l even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/120az2.htm validated

static group121_I4bar_2m(h: int, k: int, l: int) bool#

Space group 121: I4̅2m. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even validated

static group122_I4bar_2d(h: int, k: int, l: int) bool#

Space group 122: I4̅2d. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): 2h + l = 4n - 00l (h=k=0): l = 4n - h00 (k=l=0): h even - hh0 (h=k, l=0): h even - h0l (k=0): h + l even - 0k0 (h=0, l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/122az2.htm validated

static group123_P4mmm(h: int, k: int, l: int) bool#

Space group 123: P4/mmm. Tetragonal. Primitive lattice. Valid reflections must satisfy: — all (h, k, l) allowed No systematic absences. validated

static group124_P4mcc(h: int, k: int, l: int) bool#

Space group 124: P4/mcc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l = 2n - hhl (h=k): l = 2n - 00l (h=k=0): l = 2n - h0l (k=0): l = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/124az2.htm validated

static group125_P4nbm(h: int, k: int, l: int) bool#

Space group 125: P4/nbm. Tetragonal. Primitive lattice.. Valid reflections must satisfy: - hk0 (l=0): h + k = 2n - 0kl (h=0): k = 2n - h00 (k=l=0): h = 2n - h0l (k=0): h = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/125az2.htm validated

static group126_P4nnc(h: int, k: int, l: int) bool#

Space group 126: P4/nnc. Tetragonal. Primitive lattice. Valid reflections must satisfy: - hk0 (l=0): h + k = 2n - 0kl (h=0): k + l = 2n - hhl (h=k): l = 2n - 00l (h=k=0): l = 2n - h00 (k=l=0): h = 2n - h0l (k=0): h + l = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/126az2.htm validated

static group127_P4mbm(h: int, k: int, l: int) bool#

Space group 127: P4/mbm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - 0kl (h=0): k = 2n - h00 (k=l=0): h = 2n - h0l (k=0): h = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/127az2.htm validated

static group128_P4mnc(h: int, k: int, l: int) bool#

Space group 128: P4/mnc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - 0kl (h=0): k + l = 2n - hhl (h=k): l = 2n - 00l (h=k=0): l = 2n - h00 (k=l=0): h = 2n - h0l (k=0): h + l = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/128az2.htm validated

static group129_P4nmm(h: int, k: int, l: int) bool#

Space group 129: P4/nmm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k = 2n - h00 (k=l=0): h = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/129az2.htm validated

static group12_C2m(h: int, k: int, l: int) bool#

Space group 12: C2/m. Monoclinic, unique axis b.

Valid reflections must satisfy: - General hkl: h + k even - h0l (k = 0): h even - 0kl (h = 0): k even - hk0 (l = 0): h + k even - 0k0 (h = 0, l = 0): k even - h00 (k = 0, l = 0): h even

Source: ITC validated

static group130_P4ncc(h: int, k: int, l: int) bool#

Space group 130: P4/ncc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k = 2n - 0kl (h=0): l = 2n - hhl (h=k): l = 2n - 00l (h=k=0): l = 2n - h00 (k=l=0): h = 2n - h0l (k=0): l = 2n - 0k0 (h=l=0): k = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/130az2.htm validated

static group131_P42mmc(h: int, k: int, l: int) bool#

Space group 131: P42/mmc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hhl (h=k): l even - 00l (h=k=0): l even validated

static group132_P42mcm(h: int, k: int, l: int) bool#

Space group 132: P42/mcm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - 0kl (h=0): l = 2n - 00l (h=k=0): l = 2n - h0l (k=0): l = 2n Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/132az2.htm validated

static group133_P42nbc(h: int, k: int, l: int) bool#

Space group 133: P42/nbc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k even - 0kl (h=0): k even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - 0k0 (h=l=0): k even - h0l (k=0): h even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/133az2.htm validated

static group134_P42nnm(h: int, k: int, l: int) bool#

Space group 134: P42/nnm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k even - 0kl (h=0): k + l even - 00l (h=k=0): l even - h00 (k=l=0): h even - h0l (k=0): h + l even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/134az2.htm validated

static group135_P42mbc(h: int, k: int, l: int) bool#

Space group 135: P42/mbc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - 0kl (h=0): k even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - 0k0 (h=l=0): k even - h0l (k=0): h even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/135az2.htm validated

static group136_P42mnm(h: int, k: int, l: int) bool#

Space group 136: P42/mnm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - 0kl (h=0): k + l even - 00l (h=k=0): l even - h00 (k=l=0): h even - h0l (k=0): h + l even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/136az2.htm validated

static group137_P42nmc(h: int, k: int, l: int) bool#

Space group 137: P42/nmc. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/137az2.htm validated

static group138_P42ncm(h: int, k: int, l: int) bool#

Space group 138: P42/ncm. Tetragonal. Primitive lattice (P-centering). Valid reflections must satisfy: - hk0 (l=0): h + k even - 0kl (h=0): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - 0k0 (h=l=0): k even - h0l (k=0): l even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/138az2.htm validated

static group139_I4mmm(h: int, k: int, l: int) bool#

Space group 139: I4/mmm. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - h0l (k=0): h + l even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/139az2.htm validated

static group13_P2c(h: int, k: int, l: int) bool#

Space group 13: P2/c. Monoclinic, unique axis b.

Valid reflections must satisfy: - h0l (k = 0): l even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group140_I4mcm(h: int, k: int, l: int) bool#

Space group 140: I4/mcm. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k and l even - hhl (h=k): l even - 00l (h=k=0): l even - h00 (k=l=0): h even - h0l (k=0): h and l even - 0k0 (h=l=0): k even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/140az2.htm validated

static group141_I41amd(h: int, k: int, l: int) bool#

Space group 141: I41/amd. Tetragonal. I-centering. Valid reflections must satisfy: - hkl (general): h + k + l even - hk0 (l=0): h and k even - 0kl (h=0): k + l even - hhl (h=k): 2h + l = 4n - 00l (h=k=0): l = 4n - h00 (k=l=0): h even - hh0 (h=k, l=0): h even - 0k0 (h=l=0): k even - h0l (k=0): h + l even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/141az2.htm validated

static group142_I41acd(h: int, k: int, l: int) bool#

Space group 142: I41/acd. Tetragonal. I-centering. Valid reflections must satisfy: - hkl (general): h + k + l even - hk0 (l=0): h and k even - 0kl (h=0): k and l even - hhl (h=k): 2h + l =4n - 00l (h=k=0): l = 4n - h00 (k=l=0): h even - hh0 (h=k, l=0): h even - 0k0 (h=l=0): k even - h0l (k=0): h and l even Source: ITC and http://img.chem.ucl.ac.uk/sgp/large/142az2.htm validated

static group143_P3(h: int, k: int, l: int) bool#

Space group 143: P3. Trigonal. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group144_P31(h: int, k: int, l: int) bool#

Space group 144: P31. Trigonal. Valid reflections must satisfy: - 00l (h = k = 0): l = 3n Source: http://img.chem.ucl.ac.uk/sgp/large/144az2.htm validated

static group145_P32(h: int, k: int, l: int) bool#

Space group 145: P32. Trigonal. Valid reflections must satisfy: - 00l (h = k = 0): l = 3n Source: http://img.chem.ucl.ac.uk/sgp/large/145az2.htm validated

static group146_R3(h: int, k: int, l: int) bool#

Space group 146: R3. Trigonal, Rhombohedral (R). Valid reflections must satisfy:

  • hkil (general): -h + k + l = 3n

  • hki0 (l = 0): -h + k = 3n

  • hh(-2h)l: l = 3n

  • h(-h)0l (i = 0): k = -h ⇒ h + l = 3n

  • 000l (h = k = i = 0): l = 3n

  • h(-h)00 (i = l = 0): k = -h,

    l = 0 ⇒ h = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l) using the relation i = -(h + k). validated.

static group147_P3bar(h: int, k: int, l: int) bool#

Space group 147: P-3 (P3̅). Trigonal system. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC validated

static group148_R3bar(h: int, k: int, l: int) bool#

Space group 148: R-3 (R3̅). Trigonal, Rhombohedral (R). Valid reflections must satisfy: - hkil (general): -h + k + l = 3n - hki0 (l = 0): -h + k = 3n - hh(-2h)l: l = 3n - h(-h)0l (i = 0): h + l = 3n - 000l (h = k = i = 0): l = 3n - h(-h)00 (i = l = 0): h = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated.

static group149_P312(h: int, k: int, l: int) bool#

Space group 149: P3₁2. Trigonal. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated.

static group14_P21c(h: int, k: int, l: int) bool#

Space group 14: P2₁/c. Monoclinic, unique axis b.

Valid reflections must satisfy: - h0l (k = 0): l even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group150_P321(h: int, k: int, l: int) bool#

Space group 150: P3₂1. Trigonal. No reflection conditions — all (h, k, l) are allowed. No systematic absences.

static group151_P3112(h: int, k: int, l: int) bool#

Space group 151: P3₁12. Trigonal. Valid reflections must satisfy: - 000l (h = k = 0): l = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated.

static group152_P3121(h: int, k: int, l: int) bool#

Space group 152: P3₁21. Trigonal. Valid reflections must satisfy: - 000l (h = k = 0): l = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated.

static group153_P3212(h: int, k: int, l: int) bool#

Space group 153: P3₂12. Trigonal. Valid reflections must satisfy: - 000l (h = k = 0): l = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated

static group154_P3221(h: int, k: int, l: int) bool#

Space group 154: P3₂21. Trigonal. Valid reflections must satisfy: - 000l (h = k = 0): l = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated

static group155_R32(h: int, k: int, l: int) bool#

Space group 155: R32. Trigonal, Rhombohedral (R). Valid reflections must satisfy: - hkil (general): -h + k + l = 3n - hki0 (l = 0): -h + k = 3n - hh(-2h)l: l = 3n - h(-h)0l (i = 0): k = -h ⇒ h + l = 3n - 000l (h = k = i = 0): l = 3n - h(-h)00 (i = l = 0): k = -h ⇒ h = 3n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k).

validated

static group156_P3m1(h: int, k: int, l: int) bool#

Space group 156: P3m1. Trigonal. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group157_P31m(h: int, k: int, l: int) bool#

Space group 157: P31m. Trigonal. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group158_P3c1(h: int, k: int, l: int) bool#

Space group 158: P3c1. Trigonal. Valid reflections must satisfy: - 0kl (h = 0): l = 2n - h0l (k = 0): l = 2n - h(-h)0l (h = -k): l = 2n - 00l (h = k = 0): l = 2n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k), and http://img.chem.ucl.ac.uk/sgp/large/158az2.htm

validated

static group159_P31c(h: int, k: int, l: int) bool#

Space group 159: P31c. Trigonal. Valid reflections must satisfy: - hh(-2h)l: l = 2n - 000l (h = k = 0): l = 2n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k)

validated

static group15_C2c(h: int, k: int, l: int) bool#

Space group 15: C 2/c. Monoclinic, unique axis b.

Valid reflections must satisfy: - General hkl: h + k even - h0l (k = 0): h, l even - 0kl (h = 0): k even - hk0 (l = 0): h + k even - 0k0 (h = 0, l = 0): k even - h00 (k = 0, l = 0): h even - 00l (h = 0, k = 0): l even

Source: https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-hkl?gnum=15 ITC, p 261 There are different rules for different cell choices and other unique axis.

validated

static group160_R3m(h: int, k: int, l: int) bool#

Space group 160: R3m. Trigonal (Rhombohedral setting, hexagonal axes). Valid reflections must satisfy: - hkil: -h + k + l = 3n - hki0 (l = 0): -h + k = 3n - hh(-2h)l: l = 3n - h(-h)0l (k = -h, l ≠ 0): h + l = 3n - 000l (h = k = 0): l = 3n - h(-h)00 (k = -h, l = 0): h = 3n Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k) JKC: http://img.chem.ucl.ac.uk/sgp/large/160bz2.htm

validated

static group161_R3c(h: int, k: int, l: int) bool#

Space group 161: R3c. Trigonal (Rhombohedral centring, hexagonal axes). Valid reflections must satisfy: - General hkl: -h + k + l = 3n - 0kl (h = 0): l = 2n and k + l = 3n - h0l (k = 0): l = 2n and h - l = 3n - hk0 (l = 0): h - k = 3n - hhl (h = k): l = 3n - h00 (k = 0, l = 0): h = 3n - 0k0 (h = 0, l = 0): k = 3n - 00l (h = 0, k = 0): l = 6n

Source:

http://img.chem.ucl.ac.uk/sgp/large/161bz2.htm

validated

static group162_P3bar_m(h: int, k: int, l: int) bool#

Space group 162: P3̅1m. Primitive lattice. Trigonal (hexagonal axes). No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group163_P3_1c(h: int, k: int, l: int) bool#

Space group 163: P3̅1c. Trigonal (hexagonal axes), primitive lattice. Valid reflections must satisfy: - hh(-2h)l: l = 2n - 000l (h = k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil notation), adapted to (h, k, l) using the relation i = -(h + k).

validated

static group164_P3bar_m1(h: int, k: int, l: int) bool#

Space group 164: P3̅m1. Primitive lattice. Trigonal (hexagonal axes). No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group165_P3c1(h: int, k: int, l: int) bool#

Space group 165: P3c1. Trigonal (hexagonal axes), primitive lattice. Valid reflections must satisfy: - h(-h)0l (k = -h): l = 2n - 000l (h = k = 0): l = 2n - 0kl (h = 0): l = 2n - h0l (k = 0): l = 2n

Source: Reflection conditions from ITC (given in hkil), adapted to (h, k, l)

using the relation i = -(h + k), and http://img.chem.ucl.ac.uk/sgp/large/165az2.htm

validated

static group166_R3bar_m(h: int, k: int, l: int) bool#

Space group 166: R3̅m. Trigonal (hexagonal axes), rhombohedral lattice. Valid reflections must satisfy: - hkil: -h + k + l = 3n - hki0 (l = 0): -h + k = 3n - hh(-2h)l: l = 3n - h(-h)0l (i = 0, k = -h): h + l = 3n - 000l (h = k = 0): l = 3n - h(-h)00 (l = 0, k = -h): h = 3n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/166bz2.htm

validated

static group167_R3bar_c(h: int, k: int, l: int) bool#

Space group 167: R3̅c. Trigonal (hexagonal axes), rhombohedral lattice. Used for Corundum. Valid reflections must satisfy: - hkil: -h + k + l = 3n - hki0 (l = 0): -h + k = 3n - hh(-2h)l: l = 3n - h(-h)0l (i = 0, k = -h): h + l = 3n and l = 2n - 000l (h = k = 0): l = 6n - h(-h)00 (l = 0, k = -h): h = 3n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k).

validated

static group168_P6(h: int, k: int, l: int) bool#

Space group 168: P6. Hexagonal system. Primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC validated

static group169_P61(h: int, k: int, l: int) bool#

Space group 169: P6₁. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 6n

Source: ITC validated

static group16_P222(h: int, k: int, l: int) bool#

Space group 16: P222. Orthorhombic. All reflections are allowed; no systematic absences. validated

static group170_P65(h: int, k: int, l: int) bool#

Space group 170: P6₅. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 6n

Source: ITC validated

static group171_P62(h: int, k: int, l: int) bool#

Space group 171: P6₂. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 3n

Source: ITC validated

static group172_P64(h: int, k: int, l: int) bool#

Space group 172: P6₄. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 3n

Source: ITC validated

static group173_P63(h: int, k: int, l: int) bool#

Space group 173: P6₃. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 2n

Source: ITC validated

static group174_P6bar(h: int, k: int, l: int) bool#

Space group 174: P6̅. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC validated

static group175_P6_m(h: int, k: int, l: int) bool#

Space group 175: P6/m. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source:ITC validated

static group176_P63_m(h: int, k: int, l: int) bool#

Space group 176: P6₃/m. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 2n

Source: ITC validated

static group177_P622(h: int, k: int, l: int) bool#

Space group 177: P622. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC validated

static group178_P6122(h: int, k: int, l: int) bool#

Space group 178: P6₁22. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 6n

Source: ITC validated

static group179_P6522(h: int, k: int, l: int) bool#

Space group 179: P6₅22. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 6n

Source: ITC validated

static group17_P2221(h: int, k: int, l: int) bool#

Space group 17: P222₁. Orthorhombic.

Valid reflections must satisfy: - 00l (h = 0, k = 0): l even

Source: ITC validated

static group180_P6222(h: int, k: int, l: int) bool#

Space group 180: P6₂22. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 3n

Source: ITC validated

static group181_P6422(h: int, k: int, l: int) bool#

Space group 181: P6₄22. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 3n

Source: ITC validated

static group182_P6322(h: int, k: int, l: int) bool#

Space group 182: P6₃22. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 2n

Source: ITC validated

static group183_P6mm(h: int, k: int, l: int) bool#

Space group 183: P6mm. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences.

Source: ITC validated

static group184_P6cc(h: int, k: int, l: int) bool#

Space group 184: P6cc. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 2n - 0kl (h = 0): l = 2n - h0l (k = 0): l = 2n - hh(-2h)l (k = h): l = 2n - h(-h)0l (k = -h): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/184az2.htm

validated

static group185_P63cm(h: int, k: int, l: int) bool#

Space group 185: P6₃cm. Hexagonal system, primitive lattice. Valid reflections must satisfy: - 000l (h = 0, k = 0): l = 2n - h0l (k = 0): l = 2n - 0kl (h = 0): l = 2n - h(-h)0l (k = -h): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/185az2.htm

validated

static group186_P63mc(h: int, k: int, l: int) bool#

Space group 186: P6₃mc. Hexagonal system, primitive lattice. Valid reflections must satisfy: - hh(-2h)l (k = h): l = 2n - 000l (h = 0, k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k).

validated

static group187_P6bar_m2(h: int, k: int, l: int) bool#

Space group 187: P6̅m2. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences.

Source: ITC validated

static group188_P6c2bar(h: int, k: int, l: int) bool#

Space group 188: P6c2 (P6̅c2). Hexagonal system, primitive lattice. Valid reflections must satisfy: - 0kl (h = 0): l = 2n - h0l (k = 0): l = 2n - h(-h)0l (k = -h): l = 2n - 000l (h = 0, k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/188bz2.htm

validated

static group189_P6bar_m2(h: int, k: int, l: int) bool#

Space group 189: P6̅2m. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC validated

static group18_P21212(h: int, k: int, l: int) bool#

Space group 18: P2₁2₁2. Orthorhombic.

Valid reflections must satisfy: - h00 (k = 0, l = 0) : h even - 0k0 (h = 0, l = 0): k even

Source: ITC validated

static group190_P6bar_2c(h: int, k: int, l: int) bool#

Space group 190: P6̅2c. Hexagonal system, primitive lattice. Valid reflections must satisfy: - hh(-2h)l (k = h): l = 2n - 000l (h = 0, k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k).

validated

static group191_P6_mmm(h: int, k: int, l: int) bool#

Space group 191: P6/mmm. Hexagonal system, primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. Source: ITC

validated

static group192_P6_mcc(h: int, k: int, l: int) bool#

Space group 192: P6/mcc. Hexagonal system, primitive lattice. Valid reflections must satisfy: - hh(-2h)l (k = h): l = 2n - h(-h)0l (k = -h): l = 2n - 000l (h = 0, k = 0): l = 2n - 0kl (h = 0): l = 2n - h0l (k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/192az2.htm validated

static group193_P63_mcm(h: int, k: int, l: int) bool#

Space group 193: P63/mcm. Hexagonal system, primitive lattice. Valid reflections must satisfy:

  • h(-h)0l (k = -h): l = 2n

  • 000l (h = 0, k = 0): l = 2n

  • 0kl (h = 0): l = 2n

  • h0l (k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using i = -(h + k). JKC: http://img.chem.ucl.ac.uk/sgp/large/193az2.htm validated

static group194_P63_mmc(h: int, k: int, l: int) bool#

Space group 194: P63/mmc. Hexagonal system, primitive lattice. Valid reflections must satisfy:

  • hh(-2h)l (k = h): l = 2n

  • 000l (h = 0, k = 0): l = 2n

Source:

Reflection conditions from ITC (in hkil), adapted to (h, k, l) using the relation i = -(h + k). validated

static group195_P23(h: int, k: int, l: int) bool#

Space group 195: P23. Primitive cubic. All reflections are allowed; no systematic absences. validated

static group196_F23(h: int, k: int, l: int) bool#

Space group 196: F23. Face-centred cubic. Conditions are cyclically permutable. Valid reflections must satisfy - General hkl: h + k, h + l, k + l all even - 0kl (h=0): k, l even - hhl (h=k): h + l even - h00 (k=0, l=0): h even

validated

static group197_I23(h: int, k: int, l: int) bool#

Space group 197: I23. Body-centred cubic. Conditions are cyclically permutable. Valid reflections must satisfy - General hkl: h + k + l even - 0kl (h=0): k + l even - hhl (h=k): l even - h00 (k=0, l=0): h even

validated

static group198_P213(h: int, k: int, l: int) bool#

Space group 198: P2₁3. Primitive cubic. Conditions are cyclically permutable. Valid reflections must satisfy - h00 (k=0, l=0): h = 2n - 0k0 (h=0, l=0): k = 2n - 00l (h=0, k=0): l = 2n

Source: http://img.chem.ucl.ac.uk/sgp/large/198az2.htm validated

static group199_I213(h: int, k: int, l: int) bool#

Space group 199: I2₁3. Body-centred cubic. Conditions are cyclically permutable.

Valid reflections must satisfy - General hkl: h + k + l = 2n - 0kl (h=0): k + l = 2n - hhl (h=k): l = 2n - h00 (k=0,l=0): h = 2n

validated

static group19_P212121(h: int, k: int, l: int) bool#

Space group 19: P2₁2₁2₁. Orthorhombic.

Valid reflections must satisfy: - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group1_P1(h: int, k: int, l: int) bool#

Space group 1: P1. Triclinic.

All reflections are allowed; no systematic absences. validated

static group200_Pm3bar(h: int, k: int, l: int) bool#

Space group 200: Pm3̅. Primitive cubic. Conditions are cyclically permutable. All reflections are allowed; no systematic absences. validated

static group201_Pn3bar(h: int, k: int, l: int) bool#

Space group 201: Pn3̅. Cubic system, primitive lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - 0kl (h = 0): k + l = 2n - h00 (k = 0, l = 0): h = 2n

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/201az2.htm

validated

static group202_Fm3bar(h: int, k: int, l: int) bool#

Space group 202: Fm3̅. Cubic system, face-centred lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - General hkl: h + k, h + l, k + l = 2n - 0kl (h = 0): k, l = 2n - hhl (h = k): h + l = 2n - h00 (k = 0, l = 0): h = 2n

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/202az2.htm validated

static group203_Fd3bar(h: int, k: int, l: int) bool#

Space group 203: Fd3̅. Cubic system, face-centred lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h+l, k+l=2n - 0kl (h = 0): k + l = 4n and k,l=2n - hhl: h + l = 2n - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/203az2.htm

validated

static group204_Im3bar(h: int, k: int, l: int) bool#

Space group 204: Im3̅. Cubic system, body-centred lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - General hkl: h + k + l even - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/204az2.htm

validated

static group205_Pa3bar(h: int, k: int, l: int) bool#

Space group 205: Pa3̅. Cubic system, primitive lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - 0kl (h = 0): k even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/205az2.htm

validated

static group206_Ia3bar(h: int, k: int, l: int) bool#

Space group 206: Ia3̅. Cubic system, body-centred lattice. Reflection conditions are cyclically permutable.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k, l = 2n - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/206az2.htm

validated

static group207_P432(h: int, k: int, l: int) bool#

Space group 207: P432. Primitive cubic. All reflections are allowed; no systematic absences. validated

static group208_P4232(h: int, k: int, l: int) bool#

Space group 208: P4₂32. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/208az2.htm

validated

static group209_F432(h: int, k: int, l: int) bool#

Space group 209: F432. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k, h + l, k + l all even - 0kl (h = 0): k, l even - hhl (h = k): h + l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/209az2.htm

validated

static group20_C2221(h: int, k: int, l: int) bool#

Space group 20: C 2 2 21. Orthorhombic

Valid reflections must satisfy: - General hkl: h + k even - 0kl (h = 0): k even - h0l (k = 0): h even - hk0 (l = 0): h + k even - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-hkl?gnum=20 validated

static group210_F4132(h: int, k: int, l: int) bool#

Space group 210: F4₁32. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h + l, k + l = 2n - 0kl (h = 0): k, l even - hhl (h = k): h + l even - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/210az2.htm

validated

static group211_I432(h: int, k: int, l: int) bool#

Space group 211: I432. Body-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/211az2.htm

validated

static group212_P4_332(h: int, k: int, l: int) bool#

Space group 212: P4₃32. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - h00 (k = 0, l = 0): h = 4n - 0k0 (h = 0, l = 0): k = 4n - 00l (h = 0, k = 0): l = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group213_P4_132(h: int, k: int, l: int) bool#

Space group 213: P4₁32. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - h00 (k = 0, l = 0): h = 4n - 0k0 (h = 0, l = 0): k = 4n - 00l (h = 0, k = 0): l = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group214_I4_132(h: int, k: int, l: int) bool#

Space group 214: I4₁32. Body-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/214az2.htm

validated

static group215_P4bar_3m(h: int, k: int, l: int) bool#

Space group 215: P4̅3m. Primitive cubic. All reflections are allowed; no systematic absences. validated

static group216_F4bar_3m(h: int, k: int, l: int) bool#

Space group 216: F4̅3m. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k, h + l, k + l even - 0kl (h = 0): k, l even - hhl (h = k): h + l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group217_I4bar_3m(h: int, k: int, l: int) bool#

Space group 217: I4̅3m. Body-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k + l even - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group218_P4_3n(h: int, k: int, l: int) bool#

Space group 218: P4̅3n. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group219_F4bar_3c(h: int, k: int, l: int) bool#

Space group 219: F4̅3c. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h + l, k + l = 2n - 0kl (h = 0): k, l even - hhl (h = k): h, l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l). JKC: http://img.chem.ucl.ac.uk/sgp/large/219az2.htm

validated

static group21_C222(h: int, k: int, l: int) bool#

Space group 21: C 2 2 2. Orthorhombic Valid reflections must satisfy: - General (hkl): h + k even - 0kl (h=0): k even - h0l (k=0): h even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even

Note: Unlike space group 20 (C 2 2 21), there is no rule for 00l in this group. validated

static group220_I4bar_3d(h: int, k: int, l: int) bool#

Space group 220: I4̅3d. Body-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - hhl (h = k): 2h + l = 4n - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group221_Pm3bar_m(h: int, k: int, l: int) bool#

Space group 221: Pm3̅m. Primitive cubic. All reflections are allowed; no systematic absences. validated

static group222_Pn3bar_n(h: int, k: int, l: int) bool#

Space group 222: Pn3̅n. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group223_Pm3_n(h: int, k: int, l: int) bool#

Space group 223: Pm3̅n. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated (without cyclic permutations)

static group224_Pn3bar_m(h: int, k: int, l: int) bool#

Space group 224: Pn3̅m. Primitive cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - 0kl (h = 0): k + l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group225_Fm3bar_m(h: int, k: int, l: int) bool#

Space group 225: Fm3̅m. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k, h + l, k + l even - 0kl (h = 0): k, l even - hhl (h = k): h + l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group226_Fm3bar_c(h: int, k: int, l: int) bool#

Space group 226: Fm3̅c. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h + l, k + l = 2n - 0kl (h = 0): k, l even - hhl (h = k): h, l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group227_Fd3bar_m(h: int, k: int, l: int) bool#

Space group 227: Fd3̅m. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h + l, k + l = 2n - 0kl (h = 0): k + l = 4n and k, l even - hhl (h = k): h + l even - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group228_Fd3bar_c(h: int, k: int, l: int) bool#

Space group 228: Fd3̅c. Face-centred cubic. Reflection conditions are permutable.

Valid reflections must satisfy: - General hkl: h + k = 2n and h + l, k + l = 2n - 0kl (h = 0): k + l = 4n and k, l even - hhl (h = k): h, l even - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group229_Im3bar_m(h: int, k: int, l: int) bool#

Space group 229: Im3̅m. Body-centred cubic. Reflection conditions, without permutations.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - hhl (h = k): l even - h00 (k = 0, l = 0): h even

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group22_F222(h: int, k: int, l: int) bool#

Space group 22: F222. Orthorhombic.

Valid reflections must satisfy: - General hkl: h + k, h + l, k + l even - 0kl (h = 0): k, l even - h0l (k = 0): h, l even - hk0 (l = 0): h, k even - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group230_Ia3bar_d(h: int, k: int, l: int) bool#

Space group 230: Ia3̅d. Body-centred cubic. Reflection conditions, without permutations.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k, l even - hhl (h = k): 2h + l = 4n - h00 (k = 0, l = 0): h = 4n

Source:

Reflection conditions from ITC, adapted to (h, k, l).

validated

static group23_I222(h: int, k: int, l: int) bool#

Space group 23: I222. Orthorhombic.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - h0l (k = 0): h + l even - hk0 (l = 0): h + k even - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group24_I212121(h: int, k: int, l: int) bool#

Space group 24: I2₁2₁2₁. Orthorhombic.

Valid reflections must satisfy: - General hkl: h + k + l = 2n - 0kl (h = 0): k + l even - h0l (k = 0): h + l even - hk0 (l = 0): h + k even - h00 (k = 0, l = 0): h even - 0k0 (h = 0, l = 0): k even - 00l (h = 0, k = 0): l even

Source: ITC validated

static group25_Pmm2(h: int, k: int, l: int) bool#

Space group 25: Pmm2. Primitive lattice. All reflections are allowed; no systematic absences. validated

static group26_Pmc21(h: int, k: int, l: int) bool#

Space group 26: Pmc21. Valid reflections must satisfy: - h0l: l = 2n - 00l: l = 2n validated

static group27_Pcc2(h: int, k: int, l: int) bool#

Space group 27: Pcc2. Valid reflections must satisfy: - General (hkl): No condition (unrestricted) - 0kl (h=0): l even - h0l (k=0): l even - 00l (h=0, k=0): l even No other systematic absences. validated

static group28_pma2(h: int, k: int, l: int) bool#

Space group 28: Pma2 Valid reflections must satisfy: - h0l (k=0): h even - h00 (k=0, l=0): h even No other systematic absences. validated

static group29_Pca21(h: int, k: int, l: int) bool#

Space group 29: Pca2₁ Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): h even - h00 (k=0, l=0): h even - 00l (h=0, k=0): l even No other systematic absences. validated

static group2_P1bar(h: int, k: int, l: int) bool#

Space group 2: P1̄. Triclinic.

All reflections are allowed; no systematic absences. validated

static group30_pnc2(h: int, k: int, l: int) bool#

Space group 30: Pnc2 Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): l even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group31_pmn21(h: int, k: int, l: int) bool#

Space group 31: Pmn2₁ Valid reflections must satisfy: - h0l (k=0): h + l even - h00 (k=0, l=0): h even - 00l (h=0, k=0): l even validated

static group32_pba2(h: int, k: int, l: int) bool#

” Space group 32: Pba2. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even No other systematic absences. validated

static group33_Pna21(h: int, k: int, l: int) bool#

Space group 33: Pna21. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group34_Pnn2(h: int, k: int, l: int) bool#

Space group 34: Pnn2. P-centering. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h + l even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group35_Cmm2(h: int, k: int, l: int) bool#

Space group 35: Cmm2. C-centering. Valid reflections must satisfy: - General (hkl): h + k even - 0kl (h=0): k even - h0l (k=0): h even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even validated

static group36_Cmc21(h: int, k: int, l: int) bool#

Space group 36: Cmc2₁. C-centering. Valid reflections must satisfy: - General (hkl): h + k even - 0kl (h=0): k even - h0l (k=0): h and l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group37_Cmm2(h: int, k: int, l: int) bool#

Space group 37: Cmm2. C-centering. Valid reflections satisfy: - General (hkl): h + k even - 0kl (h=0): k and l even - h0l (k=0): h and l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group38_Amm2(h: int, k: int, l: int) bool#

Space group 38: Amm2. A-centering. Valid reflections satisfy: - General (hkl): k + l even - 0kl (h=0): k + l even - h0l (k=0): l even - hk0 (l=0): k even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group39_Aem2(h: int, k: int, l: int) bool#

Space group 39: Aem2. A-centering. Valid reflections must satisfy: - General (hkl): k + l even - 0kl (h=0): k and l even - h0l (k=0): l even - hk0 (l=0): k even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group3_P2(h: int, k: int, l: int) bool#

Space group 3: P2. Monoclinic, unique axis b.

All reflections are allowed; no systematic absences. validated

static group40_Ama2(h: int, k: int, l: int) bool#

Space group 40: Ama2. A-centering. Valid reflections must satisfy: - General (hkl): k + l even - 0kl (h=0): k + l even - h0l (k=0): h and l even - hk0 (l=0): k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group41_Aea2(h: int, k: int, l: int) bool#

Space group 41: Aea2. A-centering. Valid reflections must satisfy: - General (hkl): k + l even - 0kl (h=0): k and l even - h0l (k=0): h and l even - hk0 (l=0): k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group42_Fmm2(h: int, k: int, l: int) bool#

Space group 42: Fmm2. F-centering. Valid reflections must satisfy: - General (hkl): h + k, h + l, and k + l even - 0kl (h=0): k and l even - h0l (k=0): h and l even - hk0 (l=0): h and k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group43_Fdd2(h: int, k: int, l: int) bool#

Space group 43: Fdd2. F-centering. Valid reflections must satisfy: - General (hkl): h + k, h + l, and k + l even - 0kl (h=0): k and l even, k + l = 4n - h0l (k=0): h and l even, h + l = 4n - hk0 (l=0): h and k even - h00 (k=0, l=0): h % 4 == 0 - 0k0 (h=0, l=0): k % 4 == 0 - 00l (h=0, k=0): l % 4 == 0 validated

static group44_Imm2(h: int, k: int, l: int) bool#

Space group 44: Imm2. I-centering. Valid reflections must satisfy: - General (hkl): h + k + l even - 0kl (h=0): k + l even - h0l (k=0): h + l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group45_Iba2(h: int, k: int, l: int) bool#

Space group 45: Iba2. I-centering. Valid reflections must satisfy: - General (hkl): h + k + l even - 0kl (h=0): k and l even - h0l (k=0): h and l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group46_Ima2(h: int, k: int, l: int) bool#

Space group 46: Ima2. I-centering. Valid reflections must satisfy: - General (hkl): h + k + l even - 0kl (h=0): k + l even - h0l (k=0): h and l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group47_Pmmm(h: int, k: int, l: int) bool#

Space group 47: Pmmm. Primitive lattice. No reflection conditions — all (h, k, l) are allowed. validated

static group48_Pnnn(h: int, k: int, l: int) bool#

Space group 48: Pnnn. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h + l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group49_Pccm(h: int, k: int, l: int) bool#

Space group 49: Pccm. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): l even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group4_P21(h: int, k: int, l: int) bool#

Space group 4: P21. Monoclinic, unique axis b.

Valid reflections must satisfy: - 0k0 (h = 0, l = 0): k even

Source: ITC validated

static group50_Pban(h: int, k: int, l: int) bool#

Space group 50: Pban. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): h even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even No general condition on hkl. validated

static group51_Pmma(h: int, k: int, l: int) bool#

Space group 51: Pmma. Primitive lattice. Valid reflections must satisfy: - hk0 (l=0): h even - h00 (k=0, l=0): h even No general condition on hkl. validated

static group52_Pnna(h: int, k: int, l: int) bool#

Space group 52: Pnna. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h + l even - hk0 (l=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group53_Pmna(h: int, k: int, l: int) bool#

Space group 53: Pmna. Primitive lattice. Valid reflections must satisfy: - h0l (k=0): h + l even - hk0 (l=0): h even - h00 (k=0, l=0): h even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group54_Pcca(h: int, k: int, l: int) bool#

Space group 54: Pcca. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): l even - hk0 (l=0): h even - h00 (k=0, l=0): h even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group55_Pbam(h: int, k: int, l: int) bool#

Space group 55: Pbam. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even No general condition on hkl. validated

static group56_Pccn(h: int, k: int, l: int) bool#

Space group 56: Pccn. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): l even - h0l (k=0): l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group57_Pbcm(h: int, k: int, l: int) bool#

Space group 57: Pbcm. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): l even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group58_Pnnm(h: int, k: int, l: int) bool#

Space group 58: Pnnm. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l even - h0l (k=0): h + l even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on full hkl. validated

static group59_Pmmn(h: int, k: int, l: int) bool#

Space group 59: Pmmn. Primitive lattice. Valid reflections must satisfy: - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even No general condition on other hkl. validated

static group5_C2(h: int, k: int, l: int) bool#

Space group 5: C2. Monoclinic, unique axis b.

Valid reflections must satisfy: - General hkl: h + k = 2n - h0l (k = 0): h even - 0kl (h = 0): k even - hk0 (l = 0): h + k even - 0k0 (h = 0, l = 0): k even - h00 (k = 0, l = 0): h even

Source: ITC validated

static group60_Pbcn(h: int, k: int, l: int) bool#

Space group 60: Pbcn. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on full hkl. validated

static group61_Pbca(h: int, k: int, l: int) bool#

Space group 61: Pbca. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k even - h0l (k=0): l even - hk0 (l=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on hkl. validated

static group62_Pnma(h: int, k: int, l: int) bool#

Space group 62: Pnma. Primitive lattice. Valid reflections must satisfy: - 0kl (h=0): k + l even - hk0 (l=0): h even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even No general condition on general hkl. validated

static group63_Cmcm(h: int, k: int, l: int) bool#

Space group 63: Cmcm. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k even - h0l (k=0): h and l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group64_Cmce(h: int, k: int, l: int) bool#

Space group 64: Cmce. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k even - h0l (k=0): h and l even - hk0 (l=0): h and k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group65_Cmmm(h: int, k: int, l: int) bool#

Space group 65: Cmmm. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k even - h0l (k=0): h even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even validated

static group66_Cccm(h: int, k: int, l: int) bool#

Space group 66: Cccm. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k, l even - h0l (k=0): h, l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group67_Cmme(h: int, k: int, l: int) bool#

Space group 67: Cmme. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k even - h0l (k=0): h even - hk0 (l=0): h, k even validated

static group68_Ccce(h: int, k: int, l: int) bool#

Space group 68: Ccce. C-centering. Valid reflections must satisfy: - general hkl: h + k even - 0kl (h=0): k, l even - h0l (k=0): h, l even - hk0 (l=0): h, k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group69_Fmmm(h: int, k: int, l: int) bool#

Space group 69: Fmmm. F-centering. Valid reflections must satisfy: - general hkl: h + k, h + l, k + l even - 0kl (h=0): k, l even - h0l (k=0): h, l even - hk0 (l=0): h, k even - h00 (k=0,l=0): h even - 0k0 (h=0,l=0): k even - 00l (h=0,k=0): l even validated

static group6_Pm(h: int, k: int, l: int) bool#

Space group 6: Pm. Monoclinic, unique axis b.

All reflections are allowed; no systematic absences. validated

static group70_Fddd(h: int, k: int, l: int) bool#

Space group 70: Fddd. F-centering. Valid reflections must satisfy: - general hkl: h + k, h + l, k + l even - 0kl (h=0): k + l = 4n, k, l even - h0l (k=0): h + l = 4n, h, l even - hk0 (l=0): h + k = 4n, h, k even - h00 (k=0, l=0): h = 4n - 0k0 (h=0, l=0): k = 4n - 00l (h=0, k=0): l = 4n validated

static group71_Immm(h: int, k: int, l: int) bool#

Space group 71: Immm. Body-centered lattice (I-centering). Valid reflections must satisfy: - general hkl: h + k, h + l, k + l even - 0kl (h=0): k + l = 4n, k, l even - h0l (k=0): h + l = 4n, h, l even - hk0 (l=0): h + k = 4n, h, k even - h00 (k=0, l=0): h = 4n - 0k0 (h=0, l=0): k = 4n - 00l (h=0, k=0): l = 4n validated

static group72_Ibam(h: int, k: int, l: int) bool#

Space group 72: Ibam. Body-centered lattice (I-centering). Valid reflections must satisfy: - general hkl: h + k + l even - 0kl (h=0): k, l even - h0l (k=0): h, l even - hk0 (l=0): h + k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group73_Ibca(h: int, k: int, l: int) bool#

Space group 73: Ibca. Body-centered lattice (I-centering). Valid reflections must satisfy: - general hkl: h + k + l even - 0kl (h=0): k, l even - h0l (k=0): h, l even - hk0 (l=0): h, k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group74_Imma(h: int, k: int, l: int) bool#

Space group 74: Imma. Body-centered lattice (I-centering). Valid reflections must satisfy: - general hkl: h + k + l even - 0kl (h=0): k + l even - h0l (k=0): h + l even - hk0 (l=0): h, k even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l even validated

static group75_P4(h: int, k: int, l: int) bool#

Space group 75: P4. Primitive tetragonal. All reflections are allowed; no systematic absences. validated

static group76_P41(h: int, k: int, l: int) bool#

Space group 76: P41. Primitive tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l = 4n validated

static group77_P42(h: int, k: int, l: int) bool#

Space group 77: P42. Primitive tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l = 2n validated

static group78_P43(h: int, k: int, l: int) bool#

Space group 78: P43. Primitive tetragonal. Valid reflections must satisfy: - 00l: l = 4n validated

static group79_I4(h: int, k: int, l: int) bool#

Space group 79: I4. Body-centered lattice (I-centering). Valid reflections must satisfy: - general hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even validated

static group7_Pc(h: int, k: int, l: int) bool#

Space group 7: Pc. Monoclinic, unique axis b.

Valid reflections: - h0l (k=0): l even - 00l (h=0, k=0): l even

Source: ITC validated

static group80_I41(h: int, k: int, l: int) bool#

Space group 80: I41. Body-centered tetragonal (I-centering). Valid reflections must satisfy: - general hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=0, k=0): l = 4n - h00 (k=0, l=0): h even validated

static group81_P4bar(h: int, k: int, l: int) bool#

Space group 81: P4̅. No systematic absences. validated

static group82_I4bar(h: int, k: int, l: int) bool#

Space group 82: I4̅. Body-centered tetragonal (I-centering). Valid reflections must satisfy: - hkl: h + k + l even - hk0: h + k even - 0kl: k + l even - hhl: l even - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even validated

static group83_P4m(h: int, k: int, l: int) bool#

Space group 83: P4/m. Tetragonal. All reflections are allowed; no systematic absences. validated

static group84_P42m(h: int, k: int, l: int) bool#

Space group 84: P42/m. Tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l even validated

static group85_P4n(h: int, k: int, l: int) bool#

Space group 85: P4/n. Tetragonal. Valid reflections must satisfy: - hk0 (l=0): h + k even - h00 (k=0, l=0): h even validated

static group86_P42n(h: int, k: int, l: int) bool#

Space group 86: P42/n. Tetragonal. Valid reflections must satisfy: - hk0 (l=0): h + k even - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even validated

static group87_I4m(h: int, k: int, l: int) bool#

Space group 87: I4/m. Body-centered tetragonal (I-centering). Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl: l even - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even validated

static group88_I41a(h: int, k: int, l: int) bool#

Space group 88: I41/a. Body-centered tetragonal (I-centering). Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h, k even - 0kl (h=0): k + l even - hhl: l even - 00l (h=0, k=0): l = 4n - h00 (k=0, l=0): h even - hh0 (k=h, l=0): h even validated

static group89_P422(h: int, k: int, l: int) bool#

Space group 89: P 4 2 2. Tetragonal. All reflections are allowed; no systematic absences. validated

static group8_Cm(h: int, k: int, l: int) bool#

Space group 8: Cm. Monoclinic, unique axis b.

Valid reflections must satisfy: - General hkl: h + k = 2n - h0l (k = 0): h even - 0kl (h = 0): k even - hk0 (l = 0): h + k even - 0k0 (h = 0, l = 0): k even - h00 (k = 0, l = 0): h even

Source: ITC validated

static group90_P4212(h: int, k: int, l: int) bool#

Space group 90: P 4 21 2. Tetragonal. Valid reflections must satisfy: - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even (a & b are permutable in tetragonal) validated

static group91_P4122(h: int, k: int, l: int) bool#

Space group 91: P 41 2 2. Tetragonal Valid reflections must satisfy: - 00l (h=0, k=0): l = 4n validated

static group92_P41_21_2(h: int, k: int, l: int) bool#

Space group 92: P41 21 2. Tetragonal. Valid reflections must satisfy: - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even - 00l (h=0, k=0): l = 4n validated

static group93_P42_2_2(h: int, k: int, l: int) bool#

Space group 93: P42 2 2. Tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l even validated

static group94_P42_21_2(h: int, k: int, l: int) bool#

Space group 94: P42 21 2. Tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even (a & b are permutable in tetragonal) validated

static group95_P43_2_2(h: int, k: int, l: int) bool#

Space group 95: P43 2 2. Tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l = 4n validated

static group96_P_43_21_2(h: int, k: int, l: int) bool#

Space group 96: P 43 21 2. Tetragonal. Valid reflections must satisfy: - 00l (h=0, k=0): l = 4n - h00 (k=0, l=0): h even - 0k0 (h=0, l=0): k even (a & b are permutable in tetragonal) Used in lysozyme. validated

static group97_I422(h: int, k: int, l: int) bool#

Space group 97: I422. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=0, k=0): l even - h00 (k=0, l=0): h even validated

static group98_I4122(h: int, k: int, l: int) bool#

Space group 98: I4122. Tetragonal. I-centering. Valid reflections must satisfy: - hkl: h + k + l even - hk0 (l=0): h + k even - 0kl (h=0): k + l even - hhl (h=k): l even - 00l (h=0, k=0): l = 4n - h00 (k=0, l=0): h even validated

static group99_P4mm(h: int, k: int, l: int) bool#

Space group 99: P4mm. Tetragonal. Primitive lattice. No reflection conditions — all (h, k, l) are allowed. No systematic absences. validated

static group9_Cc(h: int, k: int, l: int) bool#

Space group 9: Cc. Monoclinic, unique axis b.

Valid reflections must satisfy: - General hkl: h + k = 2n - h0l (k = 0): h, l even - 0kl (h = 0): k even - hk0 (l = 0): h + k even - 0k0 (h = 0, l = 0): k even - h00 (k = 0, l = 0): h even - 00l (h = 0, k = 0): l even

Source: ITC validated

static type_A(h: int, k: int, l: int) bool#

End-centered A type: k+l even

static type_B(h: int, k: int, l: int) bool#

End-centered B type: h+l even

static type_C(h: int, k: int, l: int) bool#

End-centered C type: h+k even

static type_F(h: int, k: int, l: int) bool#

Face-centered type: h,k,l all even or all odd

static type_I(h: int, k: int, l: int) bool#

Body-centered type: h+k+l even

static type_P(h: int, k: int, l: int) bool#

Default selection rule: h=k=l=0 is forbidden

static type_R(h: int, k: int, l: int) bool#

Rhombohedral type: -h+k+l multiple of 3 http://img.chem.ucl.ac.uk/sgp/large/146bz2.htm

pyFAI.calibrant.get_calibrant(calibrant_name: str, wavelength: float = None) Calibrant#

Returns a new instance of the calibrant by it’s name.

Parameters:
  • calibrant_name – Name of the calibrant

  • wavelength – initialize the calibrant with the given wavelength (in m)

pyFAI.calibrant.names() list[str]#

Returns the list of registered calibrant names.

distortion Module#

class pyFAI.distortion.Distortion(detector='detector', shape=None, resize=False, empty=0, mask=None, method='csr', device=None, workgroup=None)#

Bases: object

This class applies a distortion correction on an image.

New version compatible both with CSR and LUT…

__init__(detector='detector', shape=None, resize=False, empty=0, mask=None, method='csr', device=None, workgroup=None)#
Parameters:
  • detector – detector instance or detector name

  • shape – shape of the output image

  • resize – allow the output shape to be different from the input shape

  • empty – value to be given for empty bins

  • method – “lut” or “csr”, the former is faster

  • device – Name of the device: None for OpenMP, “cpu” or “gpu” or the id of the OpenCL device a 2-tuple of integer

  • workgroup – workgroup size for CSR on OpenCL

calc_LUT(use_common=True)#

Calculate the Look-up table

Returns:

look up table either in CSR or LUT format depending on self.method

calc_LUT_regular()#

Calculate the Look-up table for a regular detector ….

calc_init()#

Initialize all arrays

calc_pos(use_cython=True)#

Calculate the pixel boundary position on the regular grid

Returns:

pixel corner positions (in pixel units) on the regular grid

Return type:

ndarray of shape (nrow, ncol, 4, 2)

calc_size(use_cython=True)#

Calculate the number of pixels falling into every single bin and

Returns:

max of pixel falling into a single bin

Considering the “half-CCD” spline from ID11 which describes a (1025,2048) detector, the physical location of pixels should go from: [-17.48634 : 1027.0543, -22.768829 : 2028.3689] We chose to discard pixels falling outside the [0:1025,0:2048] range with a lose of intensity

correct(image, dummy=None, delta_dummy=None)#

Correct an image based on the look-up table calculated …

Parameters:
  • image – 2D-array with the image

  • dummy – value suggested for bad pixels

  • delta_dummy – precision of the dummy value

Returns:

corrected 2D image

correct_ng(image, variance=None, dark=None, flat=None, solidangle=None, polarization=None, dummy=None, delta_dummy=None, normalization_factor=1.0)#

Correct an image based on the look-up table calculated … Like the integrate_ng it provides * Dark current correction * Normalisation with flatfield (or solid angle, polarization, absorption, …) * Error propagation

Parameters:
  • image – 2D-array with the image

  • variance – 2D-array with the associated image

  • dark – array with dark-current values

  • flat – array with values for a flat image

  • solidangle – solid-angle array

  • polarization – numpy array with 2D polarization corrections

  • dummy – value suggested for bad pixels

  • delta_dummy – precision of the dummy value

  • normalization_factor – multiply all normalization with this value

Returns:

corrected 2D image

reset(method=None, device=None, workgroup=None, prepare=True)#

reset the distortion correction and re-calculate the look-up table

Parameters:
  • method – can be “lut” or “csr”, “lut” looks faster

  • device – can be None, “cpu” or “gpu” or the id as a 2-tuple of integer

  • worgroup – enforce the workgroup size for CSR.

  • prepare – set to false to only reset and not re-initialize

property shape_out#

Calculate/cache the output shape

Returns:

output shape

uncorrect(image, use_cython=False)#

Take an image which has been corrected and transform it into it’s raw (with loss of information)

Parameters:

image – 2D-array with the image

Returns:

uncorrected 2D image

Nota: to retrieve the input mask on can do:

>>> msk =  dis.uncorrect(numpy.ones(dis._shape_out)) <= 0
class pyFAI.distortion.Quad(buffer)#

Bases: object

Quad modelisation.

Modelization of the quad
__init__(buffer)#
calc_area()#
calc_area_AB(I1, I2)#
calc_area_BC(J1, J2)#
calc_area_CD(K1, K2)#
calc_area_DA(L1, L2)#
calc_area_old()#
calc_area_vectorial()#
get_box(i, j)#
get_box_size0()#
get_box_size1()#
get_idx(i, j)#
get_offset0()#
get_offset1()#
init_slope()#
integrateAB(start, stop, calc_area)#
populate_box()#
reinit(A0, A1, B0, B1, C0, C1, D0, D1)#
pyFAI.distortion.resize_image_2D_numpy(image, shape_in)#

numpy implementation of resize_image_2D

units Module#

Manages the different units

Nota for developers: this module is used a singleton to store all units in a unique manner. This explains the number of top-level variables on the one hand and their CAPITALIZATION on the other.

pyFAI.units.CONST_hc = 12.398419843320026#

Product of h the Planck constant, and c the speed of light in vacuum in Angstrom.KeV. It is approximately equal to:

  • pyFAI reference: 12.398419292004204

  • scipy v1.3.1: 12.398419739640717

  • scipy v1.4.0: 12.398419843320026

pyFAI.units.CONST_q = 1.602176634e-19#

One electron-volt is equal to 1.602176634⋅10-19 joules

class pyFAI.units.Unit(name: str, scale: float = 1, label: str | None = None, equation: Callable | None = None, formula: str | None = None, center: Callable | None = None, corner: Callable | None = None, delta: Callable | None = None, short_name: str | None = None, unit_symbol: str | None = None, positive: bool = True, period: float | None = None, extra_parameters: dict | ImmutableDict | None = None)#

Bases: object

Represents a unit.

It has at least a name and a scale (in SI-unit)

__init__(name: str, scale: float = 1, label: str | None = None, equation: Callable | None = None, formula: str | None = None, center: Callable | None = None, corner: Callable | None = None, delta: Callable | None = None, short_name: str | None = None, unit_symbol: str | None = None, positive: bool = True, period: float | None = None, extra_parameters: dict | ImmutableDict | None = None)#

Constructor of a unit.

Parameters:
  • name (str) – name of the unit

  • scale (float) – scale of the unit to go to SI

  • label (str) – label for nice representation in matplotlib, can use latex representation

  • equation (func) – equation to calculate the value from coordinates (x,y,z) in detector space. Parameters of the function are x, y, z, wavelength

  • formula (str) – string with the mathematical formula. Valid variable names are x, y, z, λ and the constant π

  • center (str) – name of the fast-path function

  • unit_symbol (str) – symbol used to display values of this unit

  • positive (bool) – this value can only be positive

  • period – None or the periodicity of the unit (angles are periodic)

  • extra_parameters – extra parameters used in the formula

as_str()#

Return repr(self).

get(key)#

Mimics the dictionary interface

Parameters:

key (str) – key wanted

Returns:

self.key

static parse(obj, type_=None)#

Factory for a Unit object

Parameters:
  • obj – can be a unit or a string like “2th_deg”

  • type – family of units like AZIMUTHAL_UNITS or RADIAL_UNITS

Returns:

Unit instance

class pyFAI.units.UnitFiber(name, scale=1, label=None, equation=None, formula=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1, center=None, corner=None, delta=None, short_name=None, unit_symbol=None, positive=True, period=None)#

Bases: Unit

Represents a unit + two rotation axis. To be used in a Grazing-Incidence or Fiber Diffraction/Scattering experiment.

Fiber parameters: :param float incident_angle: pitch angle; projection angle of the beam in the sample. Its rotation axis is the horizontal axis of the lab system. :param float tilt angle: roll angle; its rotation axis is the beam axis. Tilting of the horizon for grazing incidence in thin films. :param int sample_orientation: 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)

It has at least a name and a scale (in SI-unit)

__init__(name, scale=1, label=None, equation=None, formula=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1, center=None, corner=None, delta=None, short_name=None, unit_symbol=None, positive=True, period=None)#

Constructor of a unit.

Parameters:
  • name (str) – name of the unit

  • scale (float) – scale of the unit to go to SI

  • label (str) – label for nice representation in matplotlib, can use latex representation

  • equation (func) – equation to calculate the value from coordinates (x,y,z) in detector space. Parameters of the function are x, y, z, wavelength

  • formula (str) – string with the mathematical formula. Valid variable names are x, y, z, λ and the constant π

  • center (str) – name of the fast-path function

  • unit_symbol (str) – symbol used to display values of this unit

  • positive (bool) – this value can only be positive

  • period – None or the periodicity of the unit (angles are periodic)

  • extra_parameters – extra parameters used in the formula

as_dict() dict#

Serialize the FiberUnit instance into a dictionary :return: dictionary with all needed parameters to recreate the FiberUnit instance

get_config() dict#

Serialize the FiberUnit instance into a dictionary :return: dictionary with all needed parameters to recreate the FiberUnit instance

get_config_shared() dict#

Get a config without name, whose parameters can be shared between FiberUnits :return: dictionary with fiber parameters

property incident_angle: float#
property sample_orientation: int#
set_config(config: dict = None, **kwargs) None#

Updates the FiberUnit instance with new parameter values

Parameters:
  • config (dict) – dictionary with new parameters values

  • kwargs – single new parameters, out of the dictionary, kwargs have priority over config

set_incident_angle(incident_angle: float) None#
set_sample_orientation(sample_orientation: int) None#
set_tilt_angle(tilt_angle: float) None#
property tilt_angle: float#
pyFAI.units.change_sample_orientation(fn)#

Decorator to change the sample orientation of numpy equation for grazing-incidence units Maps x,y arrays to new sample orientation

pyFAI.units.eq_2th(x, y, z, wavelength=None)#

Calculates the 2theta aperture of the cone

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

opening angle 2θ in radian

pyFAI.units.eq_chi(x, y, z, wavelength)#

Calculates the polar angle in transmission mode,

chi = arctan2(y, x)

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam, unused

  • wavelength – in meter, unused

Returns:

polar angle, in rad

pyFAI.units.eq_chi_gi(x, y, z, wavelength, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#

Calculates the polar angle from the vertical axis (fiber or thin-film main axis)

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)

Returns:

component of the scattering vector in the plane YZ, in inverse nm

pyFAI.units.eq_exit_angle_horz(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#

Calculates the horizontal exit angle in radians relative to the horizon (for thin films), used for GI/Fiber diffraction

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • wavelength – in meter

Returns:

horizontal exit angle in radians

pyFAI.units.eq_exit_angle_vert(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#

Calculates the vertical exit angle in radians relative to the horizon (for thin films), used for GI/Fiber diffraction

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • wavelength – in meter

Returns:

vertical exit angle in radians

pyFAI.units.eq_exitangle(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#

Calculates the vertical exit angle in radians relative to the horizon (for thin films), used for GI/Fiber diffraction

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • wavelength – in meter

Returns:

vertical exit angle in radians

pyFAI.units.eq_q(x, y, z, wavelength)#

Calculates the modulus of the scattering vector

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

modulus of the scattering vector q in inverse nm

pyFAI.units.eq_q_total(x, y, z, wavelength, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the total component of the scattering vector joining qip and qoop (for GI/Fiber diffraction)
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)

Returns:

component of the scattering vector in the plane YZ, in inverse nm

pyFAI.units.eq_qbeam(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the beam propagation direction in the sample frame (for GI/Fiber diffraction)
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the beam propagation direction in inverse nm

pyFAI.units.eq_qbeam_gi(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the beam propagation direction in the sample frame (for GI/Fiber diffraction)
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the beam propagation direction in inverse nm

pyFAI.units.eq_qhorz(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the horizontal direction in the sample frame (for GI/Fiber diffraction), towards the center of the ring
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the horizontal direction in inverse nm

pyFAI.units.eq_qhorz_gi(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the horizontal direction in the sample frame (for GI/Fiber diffraction), towards the center of the ring
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the horizontal direction in inverse nm

pyFAI.units.eq_qip(x, y, z, wavelength, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector in the plane YZ in the sample frame (for GI/Fiber diffraction)
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)

Returns:

component of the scattering vector in the plane YZ, in inverse nm

pyFAI.units.eq_qoop(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the vertical direction in the sample frame (for GI/Fiber diffraction), to the roof
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the vertical direction in inverse nm

pyFAI.units.eq_qvert(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the vertical direction in the sample frame (for GI/Fiber diffraction), to the roof
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the vertical direction in inverse nm

pyFAI.units.eq_qvert_gi(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#
Calculates the component of the scattering vector along the vertical direction in the sample frame (for GI/Fiber diffraction), to the roof
First, rotates the lab sample reference around the beam axis a tilt_angle value in radians,

then rotates again around the horizontal axis using an incident angle value in radians

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

component of the scattering vector along the vertical direction in inverse nm

pyFAI.units.eq_r(x, y, z=None, wavelength=None)#

Calculates the radius in meter

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

radius in meter

pyFAI.units.eq_scattering_angle_horz(x, y, z, wavelength=None, incident_angle=None, tilt_angle=None, sample_orientation=1)#

Calculates the horizontal scattering angle (relative to direct beam axis), used for GI/Fiber diffraction

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

horizontal exit angle in radians

pyFAI.units.eq_scattering_angle_vertical(x, y, z, wavelength=None, incident_angle=None, tilt_angle=None, sample_orientation=1)#

Calculates the vertical scattering angle (relative to direct beam axis), used for GI/Fiber diffraction

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

vertical exit angle in radians

pyFAI.units.get_unit_fiber(name, incident_angle: float = 0.0, tilt_angle: float = 0.0, sample_orientation: int = 1, angle_unit: str = 'rad')#

Retrieves a unit instance for Grazing-Incidence/Fiber Scattering with updated incident and tilt angles The unit angles are in radians

Parameters:
  • incident_angle (float) – projection angle of the beam in the sample. Its rotation axis is the fiber axis or the normal vector of the thin film

  • angle (float tilt) – roll angle. Its rotation axis is orthogonal to the beam, the horizontal axis of the lab frame

  • sample_orientation (int) – 1-8, orientation of the fiber axis according to EXIF orientation values (see def rotate_sample_orientation)

  • angle_unit (str) – rad/deg, defines the units if incident and tilt angles

pyFAI.units.parse_fiber_unit(unit, incident_angle=None, tilt_angle=None, sample_orientation=None)#
pyFAI.units.q_lab(x, y, z, wavelength=None, sample_orientation=1) tuple#

Calculates the scattering vector in the laboratory frame (for GI/Fiber diffraction): no sample rotations are applied

Parameters:
  • z – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

scattering vector in the laboratory frame reference in inverse nm

pyFAI.units.q_lab_beam(x, y, z, wavelength=None, incident_angle=None, tilt_angle=None, sample_orientation=1)#

Calculates the beam component (x) of the scattering vector in the laboratory frame, no sample rotations are applied yet

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

beam scattering vector in inverse nm

pyFAI.units.q_lab_horz(x, y, z, wavelength=None, incident_angle=None, tilt_angle=None, sample_orientation=1)#

Calculates the horizontal component (y) of the scattering vector in the laboratory frame, no sample rotations are applied yet

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

horizontal scattering vector in inverse nm

pyFAI.units.q_lab_vert(x, y, z, wavelength=None, incident_angle=None, tilt_angle=None, sample_orientation=1)#

Calculates the vertical component (z) of the scattering vector in the laboratory frame, no sample rotations are applied yet

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

Returns:

vertical scattering vector in inverse nm

pyFAI.units.q_sample(x, y, z, wavelength=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1)#

Calculates the scattering vector in the sample frame (for GI/Fiber diffraction) after incident angle and tilt angle rotations

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • z – distance from sample along the beam

  • wavelength – in meter

  • incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

  • tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

scattering vector in the laboratory frame reference in inverse nm

pyFAI.units.register_azimuthal_fiber_unit(name, scale=1, label=None, equation=None, formula=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1, center=None, corner=None, delta=None, short_name=None, unit_symbol=None, positive=False, period=None) UnitFiber#
pyFAI.units.register_azimuthal_unit(name: str, scale: float = 1, label: str | None = None, equation: Callable | None = None, formula: str | None = None, center: Callable | None = None, corner: Callable | None = None, delta: Callable | None = None, short_name: str | None = None, unit_symbol: str | None = None, positive: bool = False, period: float | None = None, extra_parameters: dict | ImmutableDict | None = None)#

Register a new azimuthal unit.

pyFAI.units.register_radial_fiber_unit(name, scale=1, label=None, equation=None, formula=None, incident_angle=0.0, tilt_angle=0.0, sample_orientation=1, center=None, corner=None, delta=None, short_name=None, unit_symbol=None, positive=True, period=None) UnitFiber#
pyFAI.units.register_radial_unit(name: str, scale: float = 1, label: str | None = None, equation: Callable | None = None, formula: str | None = None, center: Callable | None = None, corner: Callable | None = None, delta: Callable | None = None, short_name: str | None = None, unit_symbol: str | None = None, positive: bool = True, period: float | None = None, extra_parameters: dict | ImmutableDict | None = None)#

Register a new radial unit, if needed.

pyFAI.units.rotate_cartesian(x, y, z, incident_angle: float = 0.0, tilt_angle: float = 0.0)#
Rotate three position arrays in this order:

1st) Around the horizontal axis (x) an incident angle, left-handed 2nd) Around the beam axis (z) a tilt angle, right-handed (x_rot, y_rot, z_rot) = Rz(tilt, RH) @ Rx(inc, LH) @ (x,y,z)

pyFAI.units.rotate_q_lab(q_beam, q_horz, q_vert, incident_angle: float = 0.0, tilt_angle: float = 0.0)#
Rotate three position arrays in this order:

1st) Around the horizontal axis (y) an incident angle, right-handed 2nd) Around the beam axis (x) a tilt angle, left-handed (x_rot, y_rot, z_rot) = Rx(tilt, RH) @ Ry(inc, LH) @ (x,y,z)

pyFAI.units.rotate_sample_orientation(x, y, sample_orientation=1)#

Rotates/Flips the axis x and y following the EXIF orientation values: https://sirv.com/help/articles/rotate-photos-to-be-upright/

Parameters:
  • x – horizontal position, towards the center of the ring, from sample position

  • y – vertical position, to the roof, from sample position

  • sample_orientation (int) – 1-8, orientation of the fiber axis regarding the detector main axis

Sample orientations 1 - No changes are applied to the image 2 - Image is mirrored (flipped horizontally) 3 - Image is rotated 180 degrees 4 - Image is rotated 180 degrees and mirrored 5 - Image is mirrored and rotated 90 degrees counter clockwise 6 - Image is rotated 90 degrees counter clockwise 7 - Image is mirrored and rotated 90 degrees clockwise 8 - Image is rotated 90 degrees clockwise

pyFAI.units.rotation_incident_angle(incident_angle=0.0)#

Calculates the rotation matrix along the y axis, (horizontal axis); represents the incident angle rotation

Parameters:

incident_angle – tilting of the sample towards the beam (analog to rot2): in radians

Returns:

3x3 rotation matrix along the horizontal axis

pyFAI.units.rotation_tilt_angle(tilt_angle=0.0)#

Calculates the rotation matrix along the x axis, (beam axis); represents the tilt angle rotation

Parameters:

tilt_angle – tilting of the sample orthogonal to the beam direction (analog to rot3): in radians

Returns:

3x3 rotation matrix along the beam axis

pyFAI.units.to_unit(obj, type_=None)#

Factory for a Unit object

Parameters:
  • obj – can be a unit or a string like “2th_deg”

  • type – family of units like AZIMUTHAL_UNITS or RADIAL_UNITS

Returns:

Unit instance

worker Module#

This module contains the Worker class:

A tool able to perform azimuthal integration with: additional saving capabilities like

  • save as 2/3D structure in a HDF5 File

  • read from HDF5 files

Aims at being integrated into a plugin like LImA or as model for the GUI

The configuration of this class is mainly done via a WorkerConfig object serialized as a JSON string. For the valid keys, please refer to the doc of the dataclass pyFAI.io.integration_config.WorkerConfig

class pyFAI.worker.DistortionWorker(detector=None, dark=None, flat=None, solidangle=None, polarization=None, mask=None, dummy=None, delta_dummy=None, method='LUT', device=None)#

Bases: object

Simple worker doing dark, flat, solid angle and polarization correction

__init__(detector=None, dark=None, flat=None, solidangle=None, polarization=None, mask=None, dummy=None, delta_dummy=None, method='LUT', device=None)#

Constructor of the worker :param dark: array :param flat: array :param solidangle: solid-angle array :param polarization: numpy array with 2D polarization corrections :param dummy: value for bad pixels :param delta_dummy: precision for dummies :param method: LUT or CSR for the correction :param device: Used to influence OpenCL behavior: can be “cpu”, “GPU”, “Acc” or even an OpenCL context

process(data, variance=None, normalization_factor=1.0)#

Process the data and apply a normalization factor :param data: input data :param variance: the variance associated to the data :param normalization: normalization factor :return: processed data as either an array (data) or two (data, error)

class pyFAI.worker.PixelwiseWorker(dark=None, flat=None, solidangle=None, polarization=None, mask=None, dummy=None, delta_dummy=None, device=None, empty=None, dtype='float32')#

Bases: object

Simple worker doing dark, flat, solid angle and polarization correction

__init__(dark=None, flat=None, solidangle=None, polarization=None, mask=None, dummy=None, delta_dummy=None, device=None, empty=None, dtype='float32')#

Constructor of the worker

Parameters:
  • dark – array

  • flat – array

  • solidangle – solid-angle array

  • polarization – numpy array with 2D polarization corrections

  • device – Used to influence OpenCL behavior: can be “cpu”, “GPU”, “Acc” or even an OpenCL context

  • empty – value given for empty pixels by default

  • dtype – unit (and precision) in which to perform calculation: float32 or float64

process(data, variance=None, normalization_factor=None, use_cython=True)#

Process the data and apply a normalization factor :param data: input data :param variance: the variance associated to the data :param normalization: normalization factor :return: processed data, optionally with the associated error if variance is provided

class pyFAI.worker.Worker(azimuthalIntegrator=None, shapeIn=None, shapeOut=(360, 500), unit='r_mm', dummy=None, delta_dummy=None, method=('bbox', 'csr', 'cython'), integrator_name=None, extra_options=None)#

Bases: object

__init__(azimuthalIntegrator=None, shapeIn=None, shapeOut=(360, 500), unit='r_mm', dummy=None, delta_dummy=None, method=('bbox', 'csr', 'cython'), integrator_name=None, extra_options=None)#
Parameters:
  • azimuthalIntegrator (AzimuthalIntegrator) – An AzimuthalIntegrator instance

  • shapeIn (tuple) – image size in input ->auto guessed from detector shape now

  • shapeOut (tuple) – Integrated size: can be (1,2000) for 1D integration

  • unit (str) – can be “2th_deg, r_mm or q_nm^-1 …

  • dummy (float) – the value making invalid pixels

  • delta_dummy (float) – the precision for dummy values

  • method – integration method: str like “csr” or tuple (“bbox”, “csr”, “cython”) or IntegrationMethod instance.

  • integrator_name (str) – Offers an alternative to “integrate1d” like “sigma_clip_ng”

  • extra_options (dict) – extra kwargs for the integrator (like {“max_iter”:3, “thres”:0, “error_model”: “azimuthal”} for sigma-clipping)

do_2D()#
get_config()#

Returns the configuration as a JSON-serializable dictionary. :return: JSON-serializable dictionary

get_json_config()#

return configuration as a JSON string

get_normalization_factor()#
get_unit()#
get_worker_config()#

Returns the configuration as a WorkerConfig dataclass instance.

Returns:

WorkerConfig dataclass instance

property nbpt_azim#
property normalization_factor#
process(data, variance=None, dark=None, flat=None, normalization_factor=1.0, writer=None, metadata=None)#

Process one frame

Parameters:
  • data – numpy array containing the input image

  • writer – An open writer in which ‘write’ will be called with the result of the integration

reconfig(shape=None, sync=False)#

This is just to force the integrator to initialize with a given input image shape

Parameters:
  • shape – shape of the input image

  • sync – return only when synchronized

reset()#

this is just to force the integrator to initialize

save_config(filename=None)#

Save the configuration as a JSON file

setDarkcurrentFile(imagefile)#
setExtension(ext)#

enforce the extension of the processed data file written

setFlatfieldFile(imagefile)#
setJsonConfig(json_file)#
setMaskFile(imagefile)#
setSubdir(path)#

Set the relative or absolute path for processed data

set_config(config: dict | WorkerConfig, consume_keys: bool = False)#

Configure the working from the dictionary|WorkerConfig.

Parameters:
  • config (dict) – Key-value configuration or WorkerConfig dataclass instance

  • consume_keys (bool) – If true the keys from the dictionary will be consumed when used.

set_dark_current_file(imagefile)#
set_flat_field_file(imagefile)#
set_json_config(json_file)#
set_mask_file(imagefile)#
set_method(method='csr')#

Set the integration method

set_normalization_factor(value)#
set_unit(value)#
property shape#
sync_init()#
property unit#
update_processor(integrator_name=None)#
static validate_config(config, raise_exception=<class 'RuntimeError'>)#

Validates a configuration for any inconsistencies

Parameters:
  • config – dict containing the configuration

  • raise_exception – Exception class to raise when configuration is not consistent

Returns:

None or reason as a string when raise_exception is None, else raise the given exception

warmup(sync=False)#

Process a dummy image to ensure everything is initialized

Parameters:

sync – wait for processing to be finished

class pyFAI.worker.WorkerFiber(fiberIntegrator=None, shapeIn=None, npt_oop: int = 1000, npt_ip: int = 1000, unit_oop='qoop_nm^-1', unit_ip='qip_nm^-1', ip_range: tuple = None, oop_range: tuple = None, incident_angle: float = 0.0, tilt_angle: float = 0.0, sample_orientation: int = 1, integration_1d: bool = False, vertical_integration: bool = True, dummy=None, delta_dummy=None, method=('no', 'csr', 'cython'), use_missing_wedge: bool = False, integrator_name=None, extra_options=None)#

Bases: Worker

__init__(fiberIntegrator=None, shapeIn=None, npt_oop: int = 1000, npt_ip: int = 1000, unit_oop='qoop_nm^-1', unit_ip='qip_nm^-1', ip_range: tuple = None, oop_range: tuple = None, incident_angle: float = 0.0, tilt_angle: float = 0.0, sample_orientation: int = 1, integration_1d: bool = False, vertical_integration: bool = True, dummy=None, delta_dummy=None, method=('no', 'csr', 'cython'), use_missing_wedge: bool = False, integrator_name=None, extra_options=None)#
Parameters:
  • FiberIntegrator (FiberIntegrator) – A FiberIntegrator instance

  • shapeIn (tuple) – image size in input ->auto guessed from detector shape now

  • shapeOut (tuple) – Integrated size: can be (1,2000) for 1D integration

  • unit_oop (str) – fiber unit to be used along the out-of-plane direction

  • unit_ip (str) – fiber unit to be used along the in-plane direction

  • dummy (float) – the value making invalid pixels

  • delta_dummy (float) – the precision for dummy values

  • method – integration method: str like “csr” or tuple (“bbox”, “csr”, “cython”) or IntegrationMethod instance.

  • integrator_name (str) – Offers an alternative to “integrate1d” like “sigma_clip_ng”

do_2D()#
get_worker_config()#

Returns the configuration as a WorkerFiberConfig dataclass instance.

Returns:

WorkerConfig dataclass instance

property incident_angle#
property npt_ip#
property npt_oop#
process(data, variance=None, dark=None, flat=None, normalization_factor=1.0, incident_angle=None, tilt_angle=None, sample_orientation=None, writer=None, metadata=None)#

Process one frame

Parameters:
  • data – numpy array containing the input image

  • writer – An open writer in which ‘write’ will be called with the result of the integration

property sample_orientation#
set_config(config: dict | WorkerFiberConfig, consume_keys: bool = False)#

Configure the working from the dictionary|WorkerFiberConfig.

Parameters:
  • config (dict) – Key-value configuration or WorkerFiberConfig dataclass instance

  • consume_keys (bool) – If true the keys from the dictionary will be consumed when used.

property tilt_angle#
update_processor()#
static validate_config(config, raise_exception=<class 'RuntimeError'>)#

Validates a configuration for any inconsistencies

Parameters:
  • config – dict containing the configuration

  • raise_exception – Exception class to raise when configuration is not consistent

Returns:

None or reason as a string when raise_exception is None, else raise the given exception

pyFAI.worker.make_ai(config, consume_keys=False)#

Create an Azimuthal integrator from the configuration.

Parameters:
  • config – Key-value dictionary with all parameters

  • consume_keys (bool) – If true the keys from the dictionary will be consumed when used.

Returns:

A configured (but uninitialized) AzimuthalIntegrator.

containers Module#

Module containing holder classes, like returned objects.

class pyFAI.containers.ErrorModel(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: IntEnum

AZIMUTHAL = 3#
HYBRID = 4#
NO = 0#
POISSON = 2#
VARIANCE = 1#
as_str()#
property do_variance#
classmethod parse(value)#
property poissonian#
class pyFAI.containers.FixedParameters(iterable=(), /)#

Bases: set

Like a set, made for FixedParameters in geometry refinement

add_or_discard(key, value=True)#

Add a value to a set if value, else discard it.

Parameters:

key – element to add or discard from set

Returns:

None

class pyFAI.containers.ImmutableDict(dico: dict | None)#

Bases: Mapping

Implements a dict that cannot be modified

__init__(dico: dict | None)#
class pyFAI.containers.Integrate1dFiberResult(integrated, intensity, sigma=None)#

Bases: IntegrateResult

__init__(integrated, intensity, sigma=None)#
property integrated#

Integrated positions (q/2theta/r)

Return type:

numpy.ndarray

property intensity#

Regrouped intensity

Return type:

numpy.ndarray

property radial#
property sigma#

Error array if it was requested

Return type:

numpy.ndarray, None

property vertical_integration#

Vertical integration

Return type:

bool

class pyFAI.containers.Integrate1dResult(radial, intensity, sigma=None)#

Bases: IntegrateResult

Result of an 1D integration. Provide a tuple access as a simple way to reach main attributes. Default result, extra results, and some integration parameters are available from attributes.

For compatibility with older API, the object can be read as a tuple in different ways:

result = ai.integrate1d(...)
if result.sigma is None:
    radial, intensity = result
else:
    radial, intensity, sigma = result
COPYABLE_ATTR: ClassVar[set] = {'_compute_engine', '_count', '_dummy', '_error_model', '_has_dark_correction', '_has_flat_correction', '_has_mask_applied', '_has_solidangle_correction', '_metadata', '_method', '_method_called', '_normalization_factor', '_npt_azim', '_percentile', '_polarization_factor', '_poni', '_sem', '_std', '_sum_normalization', '_sum_normalization2', '_sum_signal', '_sum_variance', '_unit', '_weighted_average'}#
__init__(radial, intensity, sigma=None)#
calc_spottiness(weighted: bool = False) float#

Calculate the spottiness of a powder diffraction pattern: Inspired by doi:10.1107/S1600576713029713 Requires the azimuthal error propagation.

As a rule of thumb: - S < 0.05: Smooth powder pattern - 0.05 < S < 0.15: Mild spottiness / texture - S > 0.15 : Strongly spotty, likely with large grain size

Parameters:

weighted – Weight the spottiness by the intensity of each ring, probably more correct but also larger values

Returns:

a value that increases with the spottiness

property intensity#

Regrouped intensity

Return type:

numpy.ndarray

property radial#

Radial positions (q/2theta/r)

Return type:

numpy.ndarray

property sigma#

Error array if it was requested

Return type:

numpy.ndarray, None

class pyFAI.containers.Integrate1dtpl(position: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], intensity: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], sigma: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], signal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], variance: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], normalization: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], count: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], std: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None, sem: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None, norm_sq: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None)#

Bases: NamedTuple

Result of any engines after 1d integration

count: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 6

intensity: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 1

norm_sq: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 9

normalization: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 5

position: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 0

sem: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 8

sigma: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 2

signal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 3

std: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 7

variance: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 4

class pyFAI.containers.Integrate2dFiberResult(intensity, inplane, outofplane, sigma=None)#

Bases: IntegrateResult

Result of an 2D integration for fiber/grazing-incidence scattering. Provide a tuple access as a simple way to reach main attributes. Default result, extra results, and some integration parameters are available from attributes. Analog to azimuthal integrate containers but: Radial -> in-plane, Azimuthal -> out-of-plane

__init__(intensity, inplane, outofplane, sigma=None)#
property azimuthal#
property inplane#

In-plane positions (q/2theta/r)

Return type:

numpy.ndarray

property intensity#

Regrouped intensity

Return type:

numpy.ndarray

property ip_unit#

In-plane scattering unit

Return type:

string

property oop_unit#

Out-of-plane scattering unit

Return type:

string

property outofplane#

Out-of-plane positions (q/2theta/r)

Return type:

numpy.ndarray

property radial#
property sigma#

Error array if it was requested

Return type:

numpy.ndarray, None

property unit#
Return type:

2-tuple of Unit

class pyFAI.containers.Integrate2dResult(intensity, radial, azimuthal, sigma=None)#

Bases: IntegrateResult

Result of an 2D integration. Provide a tuple access as a simple way to reach main attributes. Default result, extra results, and some integration parameters are available from attributes.

For compatibility with older API, the object can be read as a tuple in different ways:

result = ai.integrate2d(...)
if result.sigma is None:
    intensity, radial, azimuthal = result
else:
    intensity, radial, azimuthal, sigma = result
COPYABLE_ATTR: ClassVar[set] = {'_azimuthal_unit', '_compute_engine', '_count', '_dummy', '_error_model', '_has_dark_correction', '_has_flat_correction', '_has_mask_applied', '_has_solidangle_correction', '_metadata', '_method', '_method_called', '_normalization_factor', '_npt_azim', '_percentile', '_polarization_factor', '_poni', '_radial_unit', '_sem', '_std', '_sum_normalization', '_sum_normalization2', '_sum_signal', '_sum_variance', '_unit', '_weighted_average'}#
__init__(intensity, radial, azimuthal, sigma=None)#
property azimuthal#

Azimuthal positions (chi)

Return type:

numpy.ndarray

property azimuthal_unit#

Radial unit

Return type:

string

property intensity#

Azimuthaly regrouped intensity

Return type:

numpy.ndarray

property radial#

Radial positions (q/2theta/r)

Return type:

numpy.ndarray

property radial_unit#

Radial unit

Return type:

string

rebin1d() Integrate1dResult#

Function that rebins an Integrate2dResult into a Integrate1dResult It keeps the number of radial bins unchanged but rebin the azimuthal bins into a single one.

Returns:

Integrate1dResult

property sigma#

Error array if it was requested

Return type:

numpy.ndarray, None

property unit#

Radial unit

Return type:

Unit or 2-tuple of Unit

class pyFAI.containers.Integrate2dtpl(radial: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], azimuthal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], intensity: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], sigma: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], signal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], variance: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], normalization: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], count: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], std: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None, sem: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None, norm_sq: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = None)#

Bases: NamedTuple

Result of any engines after 2d integration

azimuthal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 1

count: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 7

intensity: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 2

norm_sq: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 10

normalization: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 6

radial: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 0

sem: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 9

sigma: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 3

signal: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 4

std: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 8

variance: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 5

class pyFAI.containers.IntegrateResult#

Bases: _CopyableTuple

Class defining shared information between Integrate1dResult and Integrate2dResult.

COPYABLE_ATTR: ClassVar[set] = {'_compute_engine', '_count', '_dummy', '_error_model', '_has_dark_correction', '_has_flat_correction', '_has_mask_applied', '_has_solidangle_correction', '_metadata', '_method', '_method_called', '_normalization_factor', '_npt_azim', '_percentile', '_polarization_factor', '_poni', '_sem', '_std', '_sum_normalization', '_sum_normalization2', '_sum_signal', '_sum_variance', '_unit', '_weighted_average'}#
EXPR_AVG = <numexpr.NumExpr object>#
EXPR_SEM = <numexpr.NumExpr object>#
EXPR_STD = <numexpr.NumExpr object>#
__init__()#
property compute_engine#

return the name of the compute engine, like CSR

property count#

Count information

Return type:

numpy.ndarray

property dummy#
property error_model#
property has_dark_correction#

True if a dark correction was applied

Return type:

bool

property has_flat_correction#

True if a flat correction was applied

Return type:

bool

property has_mask_applied#

True if a mask was applied

Return type:

bool

property has_solidangle_correction#

True if a flat correction was applied

Return type:

bool

property metadata#

Metadata associated with the input frame

Return type:

JSON serializable dict object

property method#

return the name of the integration method _actually_ used, represented as a 4-tuple (dimension, splitting, algorithm, implementation)

property method_called#

return the name of the method called

property normalization_factor#

The normalisation factor used

Return type:

float

property npt_azim#

for median filter along the azimuth, number of azimuthal bin initially used

property percentile#

for median filter along the azimuth, position of the centile retrieved

property polarization_factor#

The polarization factor used

Return type:

float

property poni#

content of the PONI-file

renormalize(value: float, copy=True)#

Recalculate the diffraction pattern with a different normalization factor

Parameters:
  • value – new normalization factor

  • copy – leave the current object untouched if True, else mangle-it in place

Returns:

IntegrateResult instance

property sem#
property std#
property sum#

Sum of all signal

Return type:

numpy.ndarray

property sum_normalization#

Sum of all normalization information

Return type:

numpy.ndarray

property sum_normalization2#

Sum of all normalization squared information

Return type:

numpy.ndarray

property sum_signal#

Sum_signal information

Return type:

numpy.ndarray

property sum_variance#

Sum of all variances information

Return type:

numpy.ndarray

union(other, recalculate_means: bool = True)#

Calculate the weighted average of two results in a new IntegrateResult

Parameters:
  • other – the same datatype as self

  • recalculate_means – if False, does not call __recalculate_means__, just accumulates signals, variances, …

Returns:

another instance of same datatype with the weighted average

property unit#

Radial unit

Return type:

string

property weighted_average#

Average have been done: * if True with the weighted mean (-ng) * if False with the unweighted mean (-legacy)

class pyFAI.containers.Miller(h: int, k: int, l: int)#

Bases: NamedTuple

This represents the Miller index of a family of lattice plans

h: int#

Alias for field number 0

k: int#

Alias for field number 1

l: int#

Alias for field number 2

classmethod parse(text: str)#
class pyFAI.containers.PolarizationArray(array, checksum)#

Bases: NamedTuple

array: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]#

Alias for field number 0

checksum: int#

Alias for field number 1

class pyFAI.containers.PolarizationDescription(polarization_factor, axis_offset)#

Bases: NamedTuple

axis_offset: float#

Alias for field number 1

polarization_factor: float#

Alias for field number 0

class pyFAI.containers.Reflection(dspacing: float = None, intensity: float = None, hkl: tuple = (), multiplicity: int = None)#

Bases: object

Represent a family of Miller plans

__init__(dspacing: float = None, intensity: float = None, hkl: tuple = (), multiplicity: int = None) None#
dspacing: float#
hkl: tuple#
intensity: float#
property is_weak#

Return True if the intensity is weak

multiplicity: int#
class pyFAI.containers.SeparateResult(bragg, amorphous)#

Bases: _CopyableTuple

Class containing the result of AzimuthalIntegrator.separate which separates the

  • Amorphous isotropic signal (from a median filter or a sigma-clip)

  • Bragg peaks (signal > amorphous)

  • Shadow areas (signal < amorphous)

COPYABLE_ATTR: ClassVar[set] = {'_compute_engine', '_count', '_has_dark_correction', '_has_flat_correction', '_has_mask_applied', '_intensity', '_metadata', '_method', '_method_called', '_normalization_factor', '_npt_azim', '_npt_rad', '_percentile', '_polarization_factor', '_radial', '_shadow', '_sigma', '_sum_normalization', '_sum_signal', '_sum_variance', '_unit'}#
__init__(bragg, amorphous)#
property amorphous#

Contains the amorphous (isotropic) signal

Return type:

numpy.ndarray

property bragg#

Contains the bragg peaks

Return type:

numpy.ndarray

property compute_engine#

return the name of the compute engine, like CSR

property count#

Count information

Return type:

numpy.ndarray

property has_dark_correction#

True if a dark correction was applied

Return type:

bool

property has_flat_correction#

True if a flat correction was applied

Return type:

bool

property has_mask_applied#

True if a mask was applied

Return type:

bool

property intensity#

Regrouped intensity

Return type:

numpy.ndarray

property metadata#

Metadata associated with the input frame

Return type:

JSON serializable dict object

property method#

return the name of the integration method _actually_ used, represented as a 4-tuple (dimension, splitting, algorithm, implementation)

property method_called#

return the name of the method called

property normalization_factor#

The normalisation factor used

Return type:

float

property npt_azim#

for median filter along the azimuth, number of azimuthal bin initially used

property percentile#

for median filter along the azimuth, position of the centile retrieved

property polarization_factor#

The polarization factor used

Return type:

float

property radial#

Radial positions (q/2theta/r)

Return type:

numpy.ndarray

property shadow#

Contains the shadowed (weak) signal part

Return type:

numpy.ndarray

property sigma#

Error array if it was requested

Return type:

numpy.ndarray, None

property sum#

Sum of all signal

Return type:

numpy.ndarray

property sum_normalization#

Sum of all normalization information

Return type:

numpy.ndarray

property sum_signal#

Sum_signal information

Return type:

numpy.ndarray

property sum_variance#

Sum of all variances information

Return type:

numpy.ndarray

property unit#

Radial unit

Return type:

string

class pyFAI.containers.SparseFrame(index, intensity)#

Bases: _CopyableTuple

Result of the sparsification of a diffraction frame

COPYABLE_ATTR: ClassVar[set] = {'_background_avg', '_background_cycle', '_background_std', '_compute_engine', '_cutoff_clip', '_cutoff_peak', '_cutoff_pick', '_dtype', '_dummy', '_error_model', '_has_dark_correction', '_has_flat_correction', '_mask', '_metadata', '_method', '_method_called', '_noise', '_normalization_factor', '_peak_connected', '_peak_patch_size', '_peaks', '_percentile', '_polarization_factor', '_radial_range', '_radius', '_shape', '_unit'}#
__init__(index, intensity)#
property background_avg#
property background_std#
property cutoff#
property cutoff_clip#
property cutoff_peak#
property cutoff_pick#
property dtype#
property dummy#
property error_model#
property index#

Contains the index position of bragg peaks

Return type:

numpy.ndarray

property intensity#

Contains the intensity of bragg peaks

Return type:

numpy.ndarray

property mask#

Contains the mask used (encodes for the shape of the image as well)

Return type:

numpy.ndarray

property noise#
property peak_connected#
property peak_patch_size#
property peaks#
property radius#
property shape#
property unit#
property x#
property y#
pyFAI.containers.rebin1d(res2d: Integrate2dResult) Integrate1dResult#

Function that rebins an Integrate2dResult into a Integrate1dResult

Parameters:

res2d – Integrate2dResult instance obtained from ai.integrate2d

Returns:

Integrate1dResult

pyFAI.containers.symmetrize(res2d: Integrate2dResult) Integrate2dResult#

Function that symmetrize an Integrate2dResult, i.e. merge data with those 180° apart in azimuthal space

Parameters:

res2d – Integrate2dResult instance obtained from ai.integrate2d

Returns:

Integrate1dResult

Other sub-packages:#