Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Nov 5, 2024
1 parent 1ed0089 commit f275690
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion specutils/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from astropy.nddata import VarianceUncertainty, InverseVariance, StdDevUncertainty
from astropy.tests.helper import assert_quantity_allclose

from ..spectra.spectrum1d import Spectrum1D
from ..spectra.spectrum1d import Spectrum1D, SpectralAxis
from ..manipulation.resample import FluxConservingResampler, LinearInterpolatedResampler, SplineInterpolatedResampler


Expand Down Expand Up @@ -214,6 +214,22 @@ def test_resample_different_units(all_resamplers):
resampled = resampler(input_spectrum, resamp_grid)
assert not np.any(np.isnan(resampled.flux))

resamp_grid = [550, 650]*u.nm
resampled = resampler(input_spectrum, resamp_grid)

# Test conversion to velocity grid
rest_wavelength = 656.2 * u.nm
wavelengths = np.linspace(640, 672, 10) * u.nm
flux = np.ones(10) * u.mJy
spec1d = Spectrum1D(spectral_axis=wavelengths, velocity_convention="optical", flux=flux)
spec1d.spectral_axis.doppler_rest = rest_wavelength

velocities = np.linspace(-1000, 1000, 5) * u.km/u.s
velocity_grid = SpectralAxis(velocities, doppler_rest=rest_wavelength,
doppler_convention="optical")
velocity_binned = resampler(spec1d, velocity_grid)
assert not np.any(np.isnan(velocity_binned.flux))


def test_resample_uncs(all_resamplers):
sdunc = StdDevUncertainty([0.1, 0.2, 0.3]*u.mJy)
Expand Down

0 comments on commit f275690

Please sign in to comment.