radis.misc.signal moduleÂ¶
SummaryÂ¶
Signal processing functions
- resample(xspace, vector, xspace_new, k=1, ext='error', energy_threshold=0.005, print_conservation=True)[source]Â¶
Resample (xspace, vector) on a new space (xspace_new) of evenly distributed data and whose bounds are taken as the same as
xspace
.Uses spline interpolation to create the intermediary points. Number of points is the same as the initial xspace, times a resolution factor. Verifies energy conservation on the intersecting range at the end.
- Parameters
xspace (array) â€“ space on which vector was generated
vector (array) â€“ quantity to resample
xspace_new (array) â€“ space on which to resample
- Other Parameters
resfactor (array) â€“ xspace vector to resample on
k (int) â€“ order of spline interpolation. 3: cubic, 1: linear. Default 1.
ext (â€˜errorâ€™, â€˜extrapolateâ€™, 0, 1) â€“ Controls the value returned for elements of xspace_new not in the interval defined by xspace. If â€˜errorâ€™, raise a ValueError. If â€˜extrapolateâ€™, well, extrapolate. If â€˜0â€™ or 0, then fill with 0. If 1, fills with 1. Default â€˜errorâ€™.
energy_threshold (float or
None
) â€“ if energy conservation (integrals on the intersecting range) is above this threshold, raise an error. IfNone
, dont check for energy conservation Default 5e-3 (0.5%)print_conservation (boolean) â€“ if True, prints energy conservation
- Returns
array
- Return type
resampled vector on evenly spaced array. Number of element is conserved.
Notes
Note that depending upon the from_space > to_space operation, sorting may be reversed.
Examples
Resample a
Spectrum
radiance on an evenly spaced wavenumber space:w_nm, I_nm = s.get('radiance') w_cm, I_cm = resample_even(nm2cm(w_nm), I_nm)
See also
- resample_even(xspace, vector, resfactor=2, k=1, ext='error', energy_threshold=0.001, print_conservation=True)[source]Â¶
Resample (xspace, vector) on a new space (xspace_new) of evenly distributed data and whose bounds are taken as the same as
xspace
.Uses spline interpolation to create the intermediary points. Number of points is the same as the initial xspace, times a resolution factor. Verifies energy conservation at the end.
- Parameters
xspace (array) â€“ space on which vector was generated
vector (array) â€“ quantity to resample
resfactor (float) â€“ increase of resolution. If 1, output vector has the same number of points as the input vector. Default 2.
k (int) â€“ order of spline interpolation. 3: cubic, 1: linear. Default 1.
ext (â€˜errorâ€™, â€˜extrapolateâ€™, 0) â€“ Controls the value returned for elements of xspace_new not in the interval defined by xspace. If â€˜errorâ€™, raise a ValueError. If â€˜extrapolateâ€™, well, extrapolate. If â€˜0â€™ or 0, then fill with 0. Default â€˜errorâ€™.
energy_threshold (float) â€“ if energy conservation (integrals) is above this threshold, raise an error
print_conservation (boolean) â€“ if True, prints energy conservation
- Returns
xspace_new (array) â€“ evenly spaced mapping of xspace (same min, same max)
vector_new (array) â€“ resampled vector on evenly spaced array. Number of element is conserved.
Note that depending upon the from_space > to_space operation, sorting may
be reversed.
Examples
Resample a
Spectrum
radiance on an evenly spaced wavenumber space:w_nm, I_nm = s.get('radiance') w_cm, I_cm = resample_even(nm2cm(w_nm), I_nm)