FluxConservingResampler¶
- class specutils.manipulation.FluxConservingResampler(extrapolation_treatment='nan_fill')[source]¶
Bases:
ResamplerBase
This resampling algorithm conserves overall integrated flux (as opposed to flux density). Algorithm based on the equations documented in the following paper: https://ui.adsabs.harvard.edu/abs/2017arXiv170505165C/abstract
- 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 spectral grid using a flux conserving algorithm:
>>> import numpy as np >>> import astropy.units as u >>> from specutils import Spectrum1D >>> from specutils.manipulation import FluxConservingResampler >>> 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 = FluxConservingResampler() >>> fluxc_resample(input_spectra, resample_grid) <Spectrum1D(flux=<Quantity [ 1. , 3. , 6. , 7. , 6.25, 10. , 20. , nan, nan] mJy> (shape=(9,), mean=7.60714 mJy); spectral_axis=<SpectralAxis [ 1. 5. 9. ... 21. 22. 23.] nm> (length=9))>
Methods Summary
resample1d
(orig_spectrum, fin_spec_axis)Create a re-sampling matrix to be used in re-sampling spectra in a way that conserves flux.
Methods Documentation
- resample1d(orig_spectrum, fin_spec_axis)[source]¶
Create a re-sampling matrix to be used in re-sampling spectra in a way that conserves flux. If an uncertainty is present in the input spectra it will be propagated through to the final resampled output spectra as an InverseVariance uncertainty.
- Parameters:
- orig_spectrum
Spectrum1D
The original 1D spectrum.
- fin_spec_axisQuantity
The desired spectral axis array.
- orig_spectrum
- Returns:
- resampled_spectrum
Spectrum1D
An output spectrum containing the resampled
Spectrum1D
- resampled_spectrum