Source code for islatu.corrections
"""
Reflectometry data must be corrected as a part of reduction.
These functions facilitate this, including the footprint and
DCD q-variance corrections.
"""
import numpy as np
from scipy.stats import norm
from scipy.interpolate import splrep
[docs]def get_interpolator(
file_path, parser, q_axis_name="qdcd_", intensity_axis_name="adc2"):
"""
Get an interpolator object from scipy, this is useful for the DCD
q-normalisation step.
Args:
file_path (:py:attr:`str`): File path to the normalisation file.
parser (:py:attr:`callable`): Parser function for the normalisation
file.
q_axis_name (:py:attr:`str`, optional): Label for the q-value in the
normalisation file. Defaults to ``'qdcd_'``.
intensity_axis_name (:py:attr:`str`, optional): Label for the
intensity in the normalisation file. Defaults to ``'adc2'``.
Returns:
:py:attr:`tuple`: Containing:
- :py:attr:`array_like`: Interpolation knots.
- :py:attr:`array_like`: B-spline coefficients.
- :py:attr:`int`: Degree of spline.
"""
normalisation_data = parser(file_path)[1]
return splrep(
normalisation_data[q_axis_name],
normalisation_data[intensity_axis_name])