From f275690ca87e6b23de10f4339feafdc5673396a1 Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 5 Nov 2024 11:24:05 -0500 Subject: [PATCH] Add test --- specutils/tests/test_resample.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/specutils/tests/test_resample.py b/specutils/tests/test_resample.py index 45d9f2d6a..d2d39c0ba 100644 --- a/specutils/tests/test_resample.py +++ b/specutils/tests/test_resample.py @@ -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 @@ -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)