pyFAI.engines package¶
pyFAI.engines.CSR_engine module¶
CSR rebinning engine implemented in pure python (with bits of scipy !)
-
class
pyFAI.engines.CSR_engine.
CSRIntegrator
(size, data=None, indices=None, indptr=None, empty=0.0)¶ Bases:
object
-
__init__
(size, data=None, indices=None, indptr=None, empty=0.0)¶ Constructor of the abstract class
- Parameters
size – input image size
data – data of the CSR matrix
indices – indices of the CSR matrix
indptr – indices of the start of line in the CSR matrix
empty – value for empty pixels
-
integrate
(signal, variance=None, dummy=None, delta_dummy=None, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, normalization_factor=1.0)¶ Actually perform the CSR matrix multiplication after preprocessing.
- Parameters
signal – array of the right size with the signal in it.
variance – Variance associated with the signal
dummy – values which have to be discarded (dynamic mask)
delta_dummy – precision for dummy values
dark – noise to be subtracted from signal
flat – flat-field normalization array
flat – solidangle normalization array
polarization – :solidangle normalization array
absorption – :absorption normalization array
normalization_factor – scale all normalization with this scalar
- Returns
the preprocessed data integrated as array nbins x 4 which contains: regrouped signal, variance, normalization and pixel count
Nota: all normalizations are grouped in the preprocessing step.
-
set_matrix
(data, indices, indptr)¶ Actually set the CSR sparse matrix content
- Parameters
data – the non zero values NZV
indices – the column number of the NZV
indptr – the index of the start of line
-
-
class
pyFAI.engines.CSR_engine.
CsrIntegrator1d
(size, data=None, indices=None, indptr=None, empty=0.0, bin_centers=None)¶ Bases:
pyFAI.engines.CSR_engine.CSRIntegrator
-
__init__
(size, data=None, indices=None, indptr=None, empty=0.0, bin_centers=None)¶ Constructor of the abstract class for 1D integration
- Parameters
data – data of the CSR matrix
indices – indices of the CSR matrix
indptr – indices of the start of line in the CSR matrix
empty – value for empty pixels
bin_center – position of the bin center
Nota: bins are deduced from bin_centers
-
integrate
(signal, variance=None, dummy=None, delta_dummy=None, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, normalization_factor=1.0)¶ Actually perform the 1D integration
- Parameters
signal – array of the right size with the signal in it.
variance – Variance associated with the signal
dummy – values which have to be discarded (dynamic mask)
delta_dummy – precision for dummy values
dark – noise to be subtracted from signal
flat – flat-field normalization array
flat – solidangle normalization array
polarization – :solidangle normalization array
absorption – :absorption normalization array
normalization_factor – scale all normalization with this scalar
- Returns
Integrate1dResult or Integrate1dWithErrorResult object depending on variance
-
set_matrix
(data, indices, indptr)¶ Actually set the CSR sparse matrix content
- Parameters
data – the non zero values NZV
indices – the column number of the NZV
indptr – the index of the start of line
-
-
class
pyFAI.engines.CSR_engine.
CsrIntegrator2d
(size, data=None, indices=None, indptr=None, empty=0.0, bin_centers0=None, bin_centers1=None)¶ Bases:
pyFAI.engines.CSR_engine.CSRIntegrator
-
__init__
(size, data=None, indices=None, indptr=None, empty=0.0, bin_centers0=None, bin_centers1=None)¶ Constructor of the abstract class for 2D integration
- Parameters
size – input image size
data – data of the CSR matrix
indices – indices of the CSR matrix
indptr – indices of the start of line in the CSR matrix
empty – value for empty pixels
bin_center – position of the bin center
Nota: bins are deduced from bin_centers0, bin_centers1
-
integrate
(signal, variance=None, dummy=None, delta_dummy=None, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, normalization_factor=1.0)¶ Actually perform the 2D integration
- Parameters
signal – array of the right size with the signal in it.
variance – Variance associated with the signal
dummy – values which have to be discarded (dynamic mask)
delta_dummy – precision for dummy values
dark – noise to be subtracted from signal
flat – flat-field normalization array
flat – solidangle normalization array
polarization – :solidangle normalization array
absorption – :absorption normalization array
normalization_factor – scale all normalization with this scalar
- Returns
Integrate2dResult or Integrate2dWithErrorResult object depending is variance is provided
-
set_matrix
(data, indices, indptr)¶ Actually set the CSR sparse matrix content
- Parameters
data – the non zero values NZV
indices – the column number of the NZV
indptr – the index of the start of line
-
pyFAI.engines.histogram_engine module¶
simple histogram rebinning engine implemented in pure python (with the help of numpy !)
-
pyFAI.engines.histogram_engine.
histogram1d_engine
(radial, npt, raw, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, mask=None, dummy=None, delta_dummy=None, normalization_factor=1.0, empty=None, split_result=False, variance=None, dark_variance=None, poissonian=False, radial_range=None)¶ Implementation of rebinning engine using pure numpy histograms
- Parameters
radial – radial position 2D array (same shape as raw)
npt – number of points to integrate over
raw – 2D array with the raw signal
dark – array containing the value of the dark noise, to be subtracted
flat – Array containing the flatfield image. It is also checked for dummies if relevant.
solidangle – the value of the solid_angle. This processing may be performed during the rebinning instead. left for compatibility
polarization – Correction for polarization of the incident beam
absorption – Correction for absorption in the sensor volume
mask – 2d array of int/bool: non-null where data should be ignored
dummy – value of invalid data
delta_dummy – precision for invalid data
normalization_factor – final value is divided by this
empty – value to be given for empty bins
variance – provide an estimation of the variance
dark_variance – provide an estimation of the variance of the dark_current,
poissonian – set to “True” for assuming the detector is poissonian and variance = raw + dark
NaN are always considered as invalid values
if neither empty nor dummy is provided, empty pixels are left at 0.
- Nota: “azimuthal_range” has to be integrated into the
mask prior to the call of this function
- Returns
Integrate1dtpl named tuple containing: position, average intensity, std on intensity, plus the various histograms on signal, variance, normalization and count.
-
pyFAI.engines.histogram_engine.
histogram2d_engine
(radial, azimuthal, npt, raw, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, mask=None, dummy=None, delta_dummy=None, normalization_factor=1.0, empty=None, split_result=False, variance=None, dark_variance=None, poissonian=False, radial_range=None, azimuth_range=None)¶ Implementation of 2D rebinning engine using pure numpy histograms
- Parameters
radial – radial position 2D array (same shape as raw)
azimuthal – azimuthal position 2D array (same shape as raw)
npt – number of points to integrate over in (azimuthal, radial) dimension
raw – 2D array with the raw signal
dark – array containing the value of the dark noise, to be subtracted
flat – Array containing the flatfield image. It is also checked for dummies if relevant.
solidangle – the value of the solid_angle. This processing may be performed during the rebinning instead. left for compatibility
polarization – Correction for polarization of the incident beam
absorption – Correction for absorption in the sensor volume
mask – 2d array of int/bool: non-null where data should be ignored
dummy – value of invalid data
delta_dummy – precision for invalid data
normalization_factor – final value is divided by this
empty – value to be given for empty bins
variance – provide an estimation of the variance
dark_variance – provide an estimation of the variance of the dark_current,
poissonian – set to “True” for assuming the detector is poissonian and variance = raw + dark
NaN are always considered as invalid values
if neither empty nor dummy is provided, empty pixels are left at 0.
- Nota: “azimuthal_range” has to be integrated into the
mask prior to the call of this function
- Returns
Integrate1dtpl named tuple containing: position, average intensity, std on intensity, plus the various histograms on signal, variance, normalization and count.
pyFAI.engines.preproc module¶
Module providing common pixel-wise pre-processing of data.
-
pyFAI.engines.preproc.
preproc
(raw, dark=None, flat=None, solidangle=None, polarization=None, absorption=None, mask=None, dummy=None, delta_dummy=None, normalization_factor=1.0, empty=None, split_result=False, variance=None, dark_variance=None, poissonian=False, dtype=<class 'numpy.float32'>)¶ Common preprocessing step for all integration engines
- Parameters
data – raw value, as a numpy array, 1D or 2D
mask – array non null where data should be ignored
dummy – value of invalid data
delta_dummy – precision for invalid data
dark – array containing the value of the dark noise, to be subtracted
flat – Array containing the flatfield image. It is also checked for dummies if relevant.
solidangle – the value of the solid_angle. This processing may be performed during the rebinning instead. left for compatibility
polarization – Correction for polarization of the incident beam
absorption – Correction for absorption in the sensor volume
normalization_factor – final value is divided by this
empty – value to be given for empty bins
split_result – set to true to separate signal from normalization and return an array of float2, float3 (with variance) ot float4 (including counts)
variance – provide an estimation of the variance, enforce split_result=True and return an float3 array with variance in second position.
dark_variance – provide an estimation of the variance of the dark_current, enforce split_result=True and return an float3 array with variance in second position.
poissonian – set to “True” for assuming the detector is poissonian and variance = raw + dark
dtype – dtype for all processing
All calculation are performed in single precision floating point (32 bits).
NaN are always considered as invalid values
if neither empty nor dummy is provided, empty pixels are 0. Empty pixels are always zero in “split_result” mode.
When set to False, i.e the default, the pixel-wise operation is: I = (raw - dark)/(flat * solidangle * polarization * absorption) Invalid pixels are set to the dummy or empty value.
When split_ressult is set to True, each result is a float2 or a float3 (with an additional value for the variance) as such: I = [(raw - dark), (variance), (flat * solidangle * polarization * absorption)] Empty pixels will have all their 2 or 3 values to 0 (and not to dummy or empty value)
If poissonian is set to True, the variance is evaluated as (raw + dark).
Module contents¶
This sub-module contains various rebinning and pre-processing engines defined at the Python level.