GreenBankObservatory / dysh

https://dysh.readthedocs.io
Other
9 stars 3 forks source link

Changing the frame of a Spectrum to itself changes its spectral axis #401

Open astrofle opened 4 hours ago

astrofle commented 4 hours ago

Describe the bug When changing the frame of a Spectrum to its _velocity_frame, the resulting Spectrum has a different SpectralAxis, even though they should be the same.

How to Reproduce

from dysh.spectra import Spectrum
spec = Spectrum.fake_spectrum()
(spec.with_frame(spec._velocity_frame).spectral_axis.value - spec.spectral_axis.value).sum() == 0
    False

Environment

astrofle commented 4 hours ago

Using with_frame multiple times keeps increasing the difference in spectral axis values.

(spec.with_frame(spec._velocity_frame).spectral_axis.value - spec.spectral_axis.value)[0]
    1218.3474452495575
(spec.with_frame(spec._velocity_frame).with_frame(spec._velocity_frame).spectral_axis.value - spec.spectral_axis.value)[0]
    2436.695948600769
astrofle commented 4 hours ago

This is not an astropy issue:

spec.spectral_axis.with_observer_stationary_relative_to("lsrk").with_observer_stationary_relative_to("lsrk").value[0] - \
spec.spectral_axis.with_observer_stationary_relative_to("lsrk").value[0]
    0