OttoStruve / muler

A Python package for working with pipeline-produced spectra from IGRINS, HPF, and Keck NIRSPEC
https://muler.readthedocs.io
MIT License
15 stars 9 forks source link

Bug with Specutils radial velocity comparison #22

Closed gully closed 3 years ago

gully commented 3 years ago

Specutils offers a neat concept of the spectral_axis which makes it amenable to frequency or wavelength axes, and supports redshifting, etc. We currently use the radial_velocity= feature to let specutils do all the Doppler shifting for us. The problem is that specutils does handle the comparison of two spectra with radial velocities defined:

spec1.radial_velocity = 5*u.km/u.s
spec2.radial_velocity = 7*u.km/u.s
net_spec = spec1-spec2 # How will it handle the velocity?
net_spec.radial_velocity # shows 0.0 km/s

There's a kwarg that can nominally support a callable for what to do with these different spectral axes:

net_spec = spec1.subtract(spec2, compare_wcs='first_found')

...but I haven't figure out how to make a callable that simply subtracts the Doppler shifted spectra? Other bugs have arisen from the use of radial_velocity and I am simply inclined to immediately make a zero-RV copy of each spectrum with a pristine spectral_axis set to the Doppler shifted wavelength as a permanent workaround. This hacky looking workaround appears to achieve this goal:

spec1.radial_velocity = 5*u.km/u.s
spec1._copy(spectral_axis=spec1.wavelength.value*spec1.wavelength.unit)

So I will inject this code directly after the methods that rouch the radial_velocity