mpylab.tools.interpol module¶
This is mpylab.tools.interpol.
Provides interpolation routines
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- exception mpylab.tools.interpol.DeprecatedDBFactorWarning
Bases:
FutureWarningAn obsolete interpolation factor was explicitly supplied.
- mpylab.tools.interpol.InterpolateMResults(y, x, interpolation=None)
Create interpolation function with optional log-axis transforms.
- mpylab.tools.interpol.MResult_Interpol(dct, interpolation)
Create interpolation function from mapping of x->y values.
- class mpylab.tools.interpol.UQ_interpol(dct, typ=None, frequency_scale='LINEAR', value_scale='LINEAR', complex_mode='POLAR', db_factor=None)
Bases:
objectInterpolate uncertain quantities in their canonical linear unit.
- Parameters:
dct (mapping) – Frequency-to-SCUQ-Quantity mapping.
typ (object, optional) – Unused historical argument retained for compatibility.
frequency_scale (str, optional) – LINEAR or LOG frequency coordinates.
value_scale (str, optional) – LINEAR or DB (geometric) value/magnitude interpolation. Real-valued DB interpolation also interpolates positive lower and upper bounds geometrically. This is not a unit conversion.
complex_mode (str, optional) – POLAR or CARTESIAN. DB requires POLAR. Complex covariance matrices retain their existing linear interpolation on the frequency axis.
db_factor (float or None, optional) – Deprecated, numerically ignored compatibility argument. Explicit 10 or 20 emits DeprecatedDBFactorWarning; other values are rejected. Omit this argument in new code, including for linear input units.
- Raises:
ValueError – If a mode, legacy factor or logarithmic interpolation domain is invalid.
TypeError – If scalar and complex covariance uncertainty models are mixed.
Notes
The legacy
db_factorattribute remains available as the supplied validated value, or None when omitted. It does not control the result. No removal release is scheduled; removing this compatibility argument requires a separately announced breaking change.
- class mpylab.tools.interpol.cartesian_interpol(dct, frequency_scale='LINEAR')
Bases:
objectInterpolate complex values through real and imaginary components.
- class mpylab.tools.interpol.cplx_interpol(dct, typ=None, frequency_scale='LINEAR', magnitude_scale='LINEAR', db_factor=None)
Bases:
objectInterpolate complex magnitudes and unwrapped phases independently.
- Parameters:
dct (mapping) – Frequency-to-complex-value mapping.
typ (object, optional) – Unused historical argument retained for compatibility.
frequency_scale (str, optional) – LINEAR or LOG frequency coordinates.
magnitude_scale (str, optional) – LINEAR or DB (geometric) magnitude interpolation. DB requires nonzero magnitudes and needs no power/amplitude conversion factor.
db_factor (float or None, optional) – Deprecated, numerically ignored compatibility argument. Explicit 10 or 20 emits DeprecatedDBFactorWarning; other values are rejected. None is the default and produces no warning.
- Raises:
ValueError – If a mode, legacy factor or logarithmic interpolation domain is invalid.
- mpylab.tools.interpol.extrap1d(interpolator)
Return a vectorized interpolation function with linear extrapolation.
- mpylab.tools.interpol.unwrap(dct, arg=None)
Phase unwrapping of values in dictionary dct.
dct is a dict with keys that can be sorted (frequencies). The values are typically complex values representing e.g. S-parameters.
If arg is given, it is expected to be a callable with a signature like
math.atan2()that returns the argument (phase) of the objects in dct.The function returns a 3-tuple of lists with the sorted keys, the magnitude, and the phase of the values.