Preserving units in FITS-WCS
I just wanted to raise awareness of a new feature I've added to astropy.wcs which is to ensure that units in WCSes get preserved rather than converted to meters or Hz:
https://docs.astropy.org/en/latest/whatsnew/7.2.html#preserving-units-in-fits-wcs
This seems like it would be useful in specutils. It would be good to check:
- That specutils works as expected if one passes it a FITS WCS object with
preserve_units=Trueto make sure specutils isn't assuming Hz or meters anywhere (if you always only use APE-14 API I doubt there will be any issues) - Whether there are any places (e.g. loaders) where it would make sense for specutils to switch to using this by default once it's available in stable versions of astropy
@astrofrog I just started testing with this (sorry for the delay!), and ran into the fact that even when using this, using wcs.spectral always results in meters. We could work around that (see https://github.com/astropy/specutils/pull/1273), but perhaps in the case that preserve_units was set to True the conversion in wcs.spectral shouldn't happen.
Good catch, I agree that wcs.spectral, wcs.celestial, and more generally wcs.sub should pass the preserve_units option to any new instance.
@rosteen - would you be able to try out https://github.com/astropy/astropy/pull/18655 to see if this fixes the issues you were seeing?
@rosteen - would you be able to try out astropy/astropy#18655 to see if this fixes the issues you were seeing?
Will do, thanks!