resins.models.polynomial module
Collection of models based off polynomials.
All classes within are exposed for reference only and should not be instantiated directly. For
obtaining the resolution function of an instrument, please use the
resins.instrument.Instrument.get_resolution_function method.
- class resins.models.polynomial.DiscontinuousPolynomialModel1D(model_data: DiscontinuousPolynomialModelData, **_)
Bases:
GaussianKernel1DMixin,SimpleBroaden1DMixin,InstrumentModelModel using a 1D polynomial to model an instrument, but with values above and below certain energy transfer set to constant values.
Models the resolution as a function of energy transfer (frequencies) only, with the output model being a Gaussian. This is done by fitting a single power-series polynomial (see
numpy.polynomial.polynomial.Polynomial) to the resolution curve, where the result of the polynomial is the width (sigma) of the Gaussian. The polynomial can be of any degree and is given via thePolynomialModelData. However, allsigmavalues belowDiscontinuousPolynomialModelData.low_energy_cutoffare set to the value ofDiscontinuousPolynomialModelData.low_energy_resolutionand similarly allsigmavalues aboveDiscontinuousPolynomialModelData.high_energy_cutoffare set to the value ofDiscontinuousPolynomialModelData.high_energy_resolution.- Parameters:
- model_data
The data associated with the model for a given version of a given instrument.
- Attributes:
- input
The names of the columns in the
omega_qarray expected by all computation methods, i.e. the names of the independent variables ([Q, w]) that the model models.data_classData for the
DiscontinuousPolynomialModel1Dmodel.- polynomial
numpy.polynomial.polynomial.Polynomial The polynomial representing the resolution function.
- low_energy_cutoff
The lower bound (in meV) for the energy transfer (frequencies), below which the
sigmavalues are set to the value oflow_energy_resolution.- low_energy_resolution
The value (in meV) to which
sigmais set when the energy transfer is lower thanlow_energy_cutoff.- high_energy_cutoff
The upper bound (in meV) for the energy transfer (frequencies), above which the
sigmavalues are set to the value ofhigh_energy_resolution.- high_energy_resolution
The value (in meV) to which
sigmais set when the energy transfer is higher thanhigh_energy_cutoff.citationThe citation for this model.
Methods
__call__(points, data, *meshes)Broadens the
dataon themeshes.broaden(points, data, mesh)Broadens the
dataon the fullmeshusing the straightforward scheme.get_characteristics(points)Computes the broadening width at each value of energy transfer given by
points.get_kernel(points, mesh)Computes the Gaussian kernel centered on zero on the provided
meshat each (energy transfer or momentum scalar) point inpoints.get_peak(points, mesh)Computes the Gaussian broadening peak on the provided
meshat each (energy transfer or momentum scalar) point inpoints.- data_class
alias of
DiscontinuousPolynomialModelData
- get_characteristics(points: Float[np.ndarray, 'energy_transfer dimension=1']) dict[str, Float[np.ndarray, 'sigma']]
Computes the broadening width at each value of energy transfer given by
points.The model approximates the broadening using the Gaussian distribution, so the returned widths are in the form of the standard deviation (sigma).
- Parameters:
- points
The energy transfer in meV at which to compute the width in sigma of the kernel. This must be a
samplex 1 2D array wheresampleis the number of energy transfers.
- Returns:
characteristicsThe characteristics of the broadening function, i.e. the Gaussian width as sigma in meV.
- class resins.models.polynomial.DiscontinuousPolynomialModelData(*, function: str, citation: list[str], defaults: dict[str, int | float], restrictions: dict[str, list[int | float], set[int | float]], fit: list[float], low_energy_cutoff: float = -inf, low_energy_resolution: float = 0.0, high_energy_cutoff: float = inf, high_energy_resolution: float = 0.0)
Bases:
ModelDataData for the
DiscontinuousPolynomialModel1Dmodel.- Attributes:
- function
The name of the function, i.e. the alias for
DiscontinuousPolynomialModel1D.- citation
The citation for the model. Please use this to look up more details and cite the model.
- restrictions
All constraints that the model places on the settings. If the value is a
list, this signifies therangestyle (start, stop, step) tuple, and if it is aset, it is a set of explicitly allowed values.- defaults
The default values for the settings, used when a value is not provided when creating the model.
- fit
Polynomial coefficients.
- low_energy_cutoff
The lower bound (in meV) for the energy transfer (frequencies), below which the
sigmavalues are set to the value oflow_energy_resolution.- low_energy_resolution
The value (in meV) to which
sigmais set when the energy transfer is lower thanlow_energy_cutoff.- high_energy_cutoff
The upper bound (in meV) for the energy transfer (frequencies), above which the
sigmavalues are set to the value ofhigh_energy_resolution.- high_energy_resolution
The value (in meV) to which
sigmais set when the energy transfer is higher thanhigh_energy_cutoff.
- class resins.models.polynomial.PolynomialModel1D(model_data: PolynomialModelData, **_)
Bases:
GaussianKernel1DMixin,SimpleBroaden1DMixin,InstrumentModelModel using a 1D polynomial to model an instrument.
Models the resolution as a function of energy transfer (frequencies) only, with the output model being a Gaussian. This is done by fitting a single power-series polynomial (see
numpy.polynomial.polynomial.Polynomial) to the resolution curve, where the result of the polynomial is the width (sigma) of the Gaussian. The polynomial can be of any degree and is given via thePolynomialModelData.- Parameters:
- model_data
The data associated with the model for a given version of a given instrument.
- Attributes:
- input
The names of the columns in the
omega_qarray expected by all computation methods, i.e. the names of the independent variables ([Q, w]) that the model models.data_classData for the
PolynomialModel1Dmodel.- polynomial
numpy.polynomial.polynomial.Polynomial The polynomial representing the resolution function.
citationThe citation for this model.
Methods
__call__(points, data, *meshes)Broadens the
dataon themeshes.broaden(points, data, mesh)Broadens the
dataon the fullmeshusing the straightforward scheme.get_characteristics(points)Computes the broadening width at each value of energy transfer (
points).get_kernel(points, mesh)Computes the Gaussian kernel centered on zero on the provided
meshat each (energy transfer or momentum scalar) point inpoints.get_peak(points, mesh)Computes the Gaussian broadening peak on the provided
meshat each (energy transfer or momentum scalar) point inpoints.- data_class
alias of
PolynomialModelData
- get_characteristics(points: Float[np.ndarray, 'energy_transfer dimension=1']) dict[str, Float[np.ndarray, 'sigma']]
Computes the broadening width at each value of energy transfer (
points).The model approximates the broadening using the Gaussian distribution, so the returned widths are in the form of the standard deviation (sigma).
- Parameters:
- points
The energy transfer in meV at which to compute the width in sigma of the kernel. This must be a
samplex 1 2D array wheresampleis the number of energy transfers.
- Returns:
characteristicsThe characteristics of the broadening function, i.e. the Gaussian width as sigma.
- class resins.models.polynomial.PolynomialModelData(*, function: str, citation: list[str], defaults: dict[str, int | float], restrictions: dict[str, list[int | float], set[int | float]], fit: list[float])
Bases:
ModelDataData for the
PolynomialModel1Dmodel.- Attributes:
- function
The name of the function, i.e. the alias for
PolynomialModel1D.- citation
The citation for the model. Please use this to look up more details and cite the model.
- restrictions
All constraints that the model places on the settings. If the value is a
list, this signifies therangestyle (start, stop, step) tuple, and if it is aset, it is a set of explicitly allowed values.- defaults
The default values for the settings, used when a value is not provided when creating the model.
- fit
Polynomial coefficients.