API
adcorr
adcorr.utils
adcorr.utils.geometry
- adcorr.utils.geometry.scattering_angles(frame_shape: Tuple[int, int], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float], distance: float) ndarray[Tuple[int, int], dtype[floating]] [source]
Computes the angles of pixels from the sample for a given geometry.
- Parameters
frame_shape – The shape of a frame.
beam_center – The center position of the beam in pixels.
pixel_sizes – The real space size of a detector pixel.
distance – The distance between the detector and the sample.
- Returns
An array of pixel angles from the sample.
- adcorr.utils.geometry.azimuthal_angles(frame_shape: Tuple[int, int], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float]) ndarray[Tuple[int, int], dtype[floating]] [source]
Computes the azimuthal angles of pixels from the beam center.
- Parameters
frame_shape – The shape of the frame.
beam_center – The center position of the beam in pixels.
- Returns
An array of pixel azimuthal angles from the beam center.
adcorr.utils.typing
- adcorr.utils.typing.FrameDType
The underlying data type of a frame.
alias of TypeVar(‘FrameDType’, bound=
dtype
)
- adcorr.utils.typing.NumFrames
The number of frames in a stack of frames.
alias of TypeVar(‘NumFrames’, bound=
int
)
- adcorr.utils.typing.FrameWidth
The number of pixels spanning the width of a frame.
alias of TypeVar(‘FrameWidth’, bound=
int
)
- adcorr.utils.typing.FrameHeight
The number of pixels spanning the height of a frame.
alias of TypeVar(‘FrameHeight’, bound=
int
)
- adcorr.utils.typing.FrameShape
The shape of a frame; Comprising of a width and height.
alias of
Tuple
[FrameWidth
,FrameHeight
]
- adcorr.utils.typing.StackShape
The shape of a stack of frames; Comprising a count, width and height.
alias of
Tuple
[NumFrames
,FrameWidth
,FrameHeight
]
- adcorr.utils.typing.Frame
A frame; Comprising a shape and a data type
- adcorr.utils.typing.Frames
A stack of frames; Comprising a shape and a data type
adcorr.angular_efficiency
- adcorr.angular_efficiency.correct_angular_efficiency(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float], distance: float, absorption_coefficient: float, thickness: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Corrects for loss due to the angular efficiency of the detector head.
Corrects for loss due to the angular efficiency of the detector head, as described in section 3.xiii and appendix C of ‘The modular small-angle X-ray scattering data correction sequence’ [https://doi.org/10.1107/S1600576717015096].
- Parameters
frames – A stack of frames to be corrected.
beam_center – The center position of the beam in pixels.
pixel_sizes – The real space size of a detector pixel.
distance – The distance between the detector and the sample head.
absorption_coefficient – The coefficient of absorption for a given material at a given photon energy.
thickness – The thickness of the detector head material.
- Returns
The corrected stack of frames.
adcorr.background_subtraction
- adcorr.background_subtraction.subtract_background(foreground_frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], background_frame: ndarray[Tuple[FrameWidth, FrameHeight], FrameDType]) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Subtract a background frame from a sequence of foreground frames.
Subtract a background frame from a sequence of foreground frames, as detailed in section 3.4.6 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
foreground_frames – A sequence of foreground frames to be corrected.
background_frame – The background which is to be corrected for.
- Returns
A sequence of corrected frames.
adcorr.dark_current
- adcorr.dark_current.correct_dark_current(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], count_times: ndarray[Tuple[Union[NumFrames, Literal[1]]], dtype[floating]], base_dark_current: float, temporal_dark_current: float, flux_dependant_dark_current: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Correct by subtracting base, temporal and flux-dependant dark currents.
Correct for incident dark current by subtracting a baselike, time dependant and a flux dependant count rate from frames, as detailed in section 3.3.6 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
count_times – The period over which photons are counted for each frame.
base_dark_current – The dark current flux, irrespective of time.
temporal_dark_current – The dark current flux, as a factor of time.
flux_dependant_dark_current – The dark current flux, as a factor of incident flux.
- Returns
The corrected stack of frames.
adcorr.deadtime
- adcorr.deadtime.correct_deadtime(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], count_times: ndarray[Tuple[Union[NumFrames, Literal[1]]], dtype[floating]], minimum_pulse_separation: float, minimum_arrival_separation: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Correct for detector deadtime by scaling counts to account for overlapping events.
Correct for detector deadtime by iteratively solving for the number of incident photons required to produce the observed value in a given time period subject to detector characteristics, as detailed in section 3.3.4 of ‘Everything SAXS: small- angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
count_times – The period over which photons are counted for each frame.
minimum_pulse_separation – The minimum time difference required between a prior pulse and the current pulse for the current pulse to be recorded correctly.
minimum_arrival_separation – The minimum time difference required between the current pulse and a subsequent pulse for the current pulse to be recorded correctly.
- Returns
The corrected stack of frames.
adcorr.displaced_volume
- adcorr.displaced_volume.correct_displaced_volume(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], displaced_fraction: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Correct for displaced volume of solvent by multiplying signal by retained fraction.
Correct for displaced volume of solvent by multiplying signal by the retained fraction, as detailed in section 3.xviii and appendix B of ‘The modular small-angle X-ray scattering data correction sequence’ [https://doi.org/10.1107/S1600576717015096].
- Parameters
frames – A stack of frames to be corrected.
displaced_fraction – The fraction of solvent displaced by the analyte.
- Returns
The corrected stack of frames.
adcorr.flatfield
- adcorr.flatfield.correct_flatfield(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], flatfield: ndarray[Tuple[FrameWidth, FrameHeight], dtype[floating]]) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Apply multiplicative flatfield correction, to correct for inter-pixel sensitivity.
Apply multiplicative flatfield correction, to correct for inter-pixel sensitivity, as described in section 3.xii of ‘The modular small-angle X-ray scattering data correction sequence’ [https://doi.org/10.1107/S1600576717015096].
- Parameters
frames – A stack of frames to be corrected.
flatfield – The multiplicative flatfield correction to be applied.
- Returns
The corrected stack of frames.
adcorr.flux_and_transmission
- adcorr.flux_and_transmission.normalize_transmitted_flux(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType]) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Normalize for incident flux and transmissibility by scaling photon counts.
Normalize for incident flux and transmissibility by scaling photon counts with respect to the total observed flux, as detailed in section 4 of ‘The modular small- angle X-ray scattering data correction sequence’ [https://doi.org/10.1107/S1600576717015096].
- Parameters
frames – A stack of frames to be normalized.
- Returns
The normalized stack of frames.
adcorr.frame_average
- adcorr.frame_average.average_all_frames(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType]) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Average all frames over the leading axis.
- Parameters
frames – A stack of frames to be averaged.
- Returns
A frame containing the average pixel values of all frames in the stack.
adcorr.frame_time
- adcorr.frame_time.normalize_frame_time(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], count_times: ndarray[Tuple[Union[NumFrames, Literal[1]]], dtype[floating]]) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Normalize for detector frame rate by scaling photon counts according to count time.
Normalize for detector frame rate by scaling photon counts according to count time, as detailed in section 3.4.3 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be normalized.
count_times – The period over which photons are counted for each frame.
- Returns
The normalized stack of frames.
adcorr.masking
- adcorr.masking.mask_frames(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], mask: ndarray[Any, dtype[bool_]]) MaskedArray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Replaces masked elemenets of frames in a stack with zero.
- Parameters
frames – A stack of frames to be masked.
mask – The boolean mask to apply to each frame.
- Returns
A stack of frames where pixels.
adcorr.polarization
- adcorr.polarization.correct_polarization(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float], distance: float, horizontal_poarization: float = 0.5) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Corrects for the effect of polarization of the incident beam.
Corrects for the effect of polarization of the incident beam, as detailed in section 3.4.1 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
beam_center – The center position of the beam in pixels.
pixel_sizes – The real space size of a detector pixel.
distance – The distance between the detector and the sample.
horizontal_poarization – The fraction of incident radiation polarized in the horizontal plane, where 0.5 signifies an unpolarized source. Defaults to 0.5.
- Returns
The corrected stack of frames.
adcorr.self_absorption
- adcorr.self_absorption.correct_self_absorption(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float], distance: float, absorption_coefficient: float, thickness: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Correct for transmission loss due to differences in observation angle.
Correct for transmission loss due to differences in observation angle, as detailed in section 3.4.7 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
beam_center – The center position of the beam in pixels.
pixel_sizes – The real space size of a detector pixel.
distance – The distance between the detector and the sample.
absorption_coefficient – The coefficient of absorption for a given material at a given photon energy.
thickness – The thickness of the detector head material.
- Returns
The corrected stack of frames.
adcorr.solid_angle
- adcorr.solid_angle.correct_solid_angle(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], beam_center: Tuple[float, float], pixel_sizes: Tuple[float, float], distance: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Corrects for the solid angle by scaling by the inverse of area subtended by a pixel.
Corrects for the solid angle by scaling by the inverse of area subtended by each pixel, as detailed in section 3.4.6 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
beam_center – The center position of the beam in pixels.
pixel_sizes – The real space size of a detector pixel.
distance – The distance between the detector and the sample head.
- Returns
The corrected stack of frames.
adcorr.thickness
- adcorr.thickness.normalize_thickness(frames: ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType], sample_thickness: float) ndarray[Tuple[NumFrames, FrameWidth, FrameHeight], FrameDType] [source]
Normailizes pixel intensities by dividing by the sample thickness.
Normailizes pixel intensities by dividing by the sample thickness, as detailed in section 3.4.3 of ‘Everything SAXS: small-angle scattering pattern collection and correction’ [https://doi.org/10.1088/0953-8984/25/38/383201].
- Parameters
frames – A stack of frames to be corrected.
sample_thickness – The thickness of the exposed sample.
- Returns
The normalized stack of frames.
- adcorr.__version__: str
Version number as calculated by https://github.com/dls-controls/versiongit