radis.misc.curve module¶
Created on Mon Jan 8 16:29:18 2018.
@author: erwan
Operations on Curves, where a curve is a (w, I) array tuple
Similar to OriginPro’s Simple Curve Math operators
Routine Listing¶
- curve_add(w1, I1, w2, I2, is_sorted=False, kind='linear')[source]¶
Add curve (w2, I2) from (w1, I1) Linearly interpolates if the two ranges dont match. Fills out of bound parameters with nan.
Similar to OriginPro’s “Simple Curve Math Subtract”
Note
for higher accuracy, choose (w2, I2) has the curve with the highest resolution
- Parameters:
w1, I1 (array) – range and values for first curve
w2, I2 (array) – range and values for 2nd curve
is_sorted (boolean) – (optional) if True, doesnt sort input arrays
kind (str) – interpolation kind. Default ‘linear’. See scipy.interpolate.interp1d
- Returns:
w1, Iadd – sum
I1 + I2
interpolated on the first rangew1
- Return type:
array
- curve_distance(w1, I1, w2, I2, discard_out_of_bounds=True)[source]¶
Get a regularized euclidian distance from curve (w1, I1) to curve (w2, I2)
\[D(w_1)[i] = \sqrt{ \sum_j (\hat{I_1}[i] - \hat{I_2}[j] )^2 + (\hat{w_1}[i] - \hat{w_2}[j])^2}\]Where values are normalized as:
\[\begin{split}\hat{A} = \\frac{A}{max(A) - min(A)}\end{split}\]This regularized Euclidian distance minimizes the effect of a small shift in between the two curves in case of stiff curves (like a spectrum bandhead can be)
No interpolation needed neither.
Distances for out of bounds values is set to nan
Warning
This is a distance on both the waverange and the intensity axis. It may be used to compensate for a small offset in your experimental spectrum (due to wavelength calibration, for instance) but can lead to wrong fits easily. Plus, it is very cost-intensive!
- Parameters:
w1, I1 (array) – range and values for first curve
w2, I2 (array) – range and values for 2nd curve
discard_out_of_bounds (boolean) – if True, distance for out of bound values is set to nan. Else, it will be the distance from the last point.
- Returns:
w1, Idist – minimal distance from I1 to I2, for each point in (w1, I1)
- Return type:
array
- curve_divide(w1, I1, w2, I2, is_sorted=False, kind='linear', interpolation=1)[source]¶
Divides curve (w1, I1) by (w2, I2) Linearly interpolates if the two ranges dont match. Fills out of bound parameters with nan.
Similar to OriginPro’s “Simple Curve Math Subtract”
Note
for higher accuracy, choose (w2, I2) has the curve with the highest resolution
- Parameters:
w1, I1 (array) – range and values for first curve
w2, I2 (array) – range and values for 2nd curve
- Other Parameters:
is_sorted (boolean) – (optional) if
True
, assumes that both input arrays are sorted already. DefaultFalse
.kind (str) – interpolation kind. Default ‘linear’. See scipy.interpolate.interp1d
interpolation (int, optional) – If 1, interpolate on w1, I1. Else, on w2, I2. Default 1
- Returns:
w1, Idiv – Division
I1 / I2
interpolated on the first or second range according to reverseInterpolation- Return type:
array
- curve_multiply(w1, I1, w2, I2, is_sorted=False, kind='linear')[source]¶
Multiply curve (w2, I2) with (w1, I1) Linearly interpolates if the two ranges dont match. Fills out of bound parameters with nan.
Similar to OriginPro’s “Simple Curve Math Subtract”
Note
for higher accuracy, choose (w2, I2) has the curve with the highest resolution
- Parameters:
w1, I1 (array) – range and values for first curve
w2, I2 (array) – range and values for 2nd curve
is_sorted (boolean) – (optional) if True, doesnt sort input arrays
kind (str) – interpolation kind. Default ‘linear’. See scipy.interpolate.interp1d
- Returns:
w1, Iproduct – product
I1 * I2
interpolated on the first rangew1
- Return type:
array
- curve_substract(w1, I1, w2, I2, is_sorted=False, kind='linear')[source]¶
Subtracts curve (w2, I2) from (w1, I1) Linearly interpolates if the two ranges dont match. Fills out of bound parameters with nan.
Similar to OriginPro’s “Simple Curve Math Subtract”
Note
for higher accuracy, choose (w2, I2) has the curve with the highest resolution
- Parameters:
w1, I1 (array) – range and values for first curve
w2, I2 (array) – range and values for 2nd curve
is_sorted (boolean) – (optional) if True, doesnt sort input arrays
kind (str) – interpolation kind. Default ‘linear’. See scipy.interpolate.interp1d
- Returns:
w1, Idiff – difference
I1 - I2
interpolated on the first rangew1
- Return type:
array