SplineInterpolatedResampler

class specutils.manipulation.SplineInterpolatedResampler(extrapolation_treatment='nan_fill')[source]

Bases: ResamplerBase

This resample algorithim uses a cubic spline interpolator. Any uncertainty is also interpolated using an identical spline.

Parameters:
extrapolation_treatmentstr

What to do when resampling off the edge of the spectrum. Can be 'nan_fill' to have points beyond the edges by set to NaN, 'zero_fill' to set those points to zero, or 'truncate' to truncate any non-overlapping bins of the spectrum. Any other value will have the spline interpolate beyond the edges of the original data.

Examples

To resample an input spectrum to a user specified spectral axis grid using a cubic spline interpolator:

>>> import numpy as np
>>> import astropy.units as u
>>> from specutils import Spectrum1D
>>> from specutils.manipulation import SplineInterpolatedResampler
>>> input_spectra = Spectrum1D(
...     flux=np.array([1, 3, 7, 6, 20]) * u.mJy,
...     spectral_axis=np.array([2, 4, 12, 16, 20]) * u.nm)
>>> resample_grid = [1, 5, 9, 13, 14, 17, 21, 22, 23] * u.nm
>>> fluxc_resample = SplineInterpolatedResampler()
>>> fluxc_resample(input_spectra, resample_grid)  
<Spectrum1D(flux=<Quantity [       nan, 3.98808594, 6.94042969, 6.45869141, 5.89921875,
           7.29736328,        nan,        nan,        nan] mJy> (shape=(9,), mean=6.11676 mJy); spectral_axis=<SpectralAxis [ 1.  5.  9. ... 21. 22. 23.] nm> (length=9))>

Methods Summary

resample1d(orig_spectrum, fin_spec_axis)

Call interpolation, repackage new spectra

Methods Documentation

resample1d(orig_spectrum, fin_spec_axis)[source]

Call interpolation, repackage new spectra

Parameters:
orig_spectrumSpectrum1D

The original 1D spectrum.

fin_spec_axisQuantity

The desired spectral axis array.

Returns:
resample_spectrumSpectrum1D

An output spectrum containing the resampled Spectrum1D