xopto.materials.ri.util.model.base module¶
- class Model(formatstr: str, params: Optional[numpy.ndarray] = None, pp: Optional[xopto.materials.ri.util.model.base.Scale] = None)[source]¶
Bases:
object
Creates a refractive index model with the give wavelength preprocessor.
- Parameters
- property formatstr: str¶
Format string for rendering the model equation.
- guess(wavelengths: numpy.ndarray, n: numpy.ndarray) → list[source]¶
Returns an initial guess for optimization/fit.
- Parameters
wavelengths (np.ndarray) – The wavelengths of light at which the values of refractive index are defined.
n (np.ndarray) – The values of refractive index at the given wavelengths of light.
- Returns
params0 – Initial guess for the values of the model parameters
- Return type
np.ndarray
- property name¶
Model name.
- property params: xopto.materials.ri.util.model.base.Scale¶
Default parameter values of the model.
- property pp: xopto.materials.ri.util.model.base.Scale¶
Preprocessor that scales/normalizes the wavelengths
- render(params: Optional[numpy.ndarray] = None) → str[source]¶
Render the model equation with the given set of parameters (use default parameter values passed to the constructor if None).
- Parameters
params (np.ndarray or None) – Model parameters. If None, use the default parameter values as passed to the constructor.
- Returns
eq (str) – Model equation rendered as a string.
pp (str) – Preprocessor equation rendered as a string.
- class Normalize(src_range: Tuple[float, float], dest_range: Tuple[float, float] = (- 1.0, 1.0))[source]¶
Bases:
object
Linearly transforms the input data range so that they tightly fit the specified output range.
- Parameters
src_range (numpy.ndarray, list or tuple of 2 values) – The range of input values as [min, max]. Can also be a full array of values in which case the minimum and maximum values are taken as the range.
dest_range (numpy.ndarray, list or tuple of 2 values) – The range of normalized values as [min, max].
- render(input='wavelength', output='wn')[source]¶
Render the preprocessor equation to a string.
- Parameters
input (str) – Input symbol as a string.
output (str) – Output symbol as a string.
- undo(data: numpy.ndarray) → numpy.ndarray[source]¶
Apply inverse of the normalization/transformation to the data.
- Parameters
data (numpy.ndarray, list or tuple) – Data to transfor.
- Returns
denormalized – The input data inversely transformed to the input range specified in the constructor call.
- Return type
numpy.ndarray, list or tuple
- class Scale(factor: float, offset: float = 0.0)[source]¶
Bases:
object
Constructs an object that transforms the input data as (data - offset)*factor.
- Parameters
factor (float) – The multiplicative term.
offset (float) – The additive term.