radis.misc.signal module

Summary

Signal processing functions


resample(xspace, vector, xspace_new, 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 on the intersecting range at the end.

Parameters
  • xspace (array) – space on which vector was generated

  • vector (array) – quantity to resample

  • 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) – if energy conservation (integrals on the intersecting range) is above this threshold, raise an error. If None, dont check for energy conservation Default 1e-3 (0.1%)

  • print_conservation (boolean) – if True, prints energy conservation

Returns

  • 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)
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)