LinearInterpolatedResampler¶
- class specutils.manipulation.LinearInterpolatedResampler(extrapolation_treatment='nan_fill')[source]¶
Bases:
ResamplerBase
Resample a spectrum onto a new
spectral_axis
using linear interpolation.- 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.
Examples
To resample an input spectrum to a user specified dispersion grid using linear interpolation:
>>> import numpy as np >>> import astropy.units as u >>> from specutils import Spectrum1D >>> from specutils.manipulation import LinearInterpolatedResampler >>> 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 = LinearInterpolatedResampler() >>> fluxc_resample(input_spectra, resample_grid) <Spectrum1D(flux=<Quantity [ nan, 3.5 , 5.5 , 6.75, 6.5 , 9.5 , nan, nan, nan] mJy> (shape=(9,), mean=6.35000 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_spectrum
Spectrum1D
The original 1D spectrum.
- fin_spec_axisndarray
The desired spectral axis array.
- orig_spectrum
- Returns:
- resample_spectrum
Spectrum1D
An output spectrum containing the resampled
Spectrum1D
- resample_spectrum