You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Develop new APE 14-compliant WCS class for FITS WCS with units preserved #8664
One common issue/annoyance with the standard WCS class in astropy is that it does not preserve units, instead converting angular units to degrees, and e.g. km/s to m/s. This is due to the way that WCSLIB works. However, there's actually no reason that we couldn't develop a new WCS class, say WCSWithOriginalUnits, which internally stores a WCS instance as well as the original units from the header, and converts values on-the-fly. From a user's perspective we could add a preserve_units=True/False flag to the WCS initializer, and if True, we could return a WCSWithOriginalUnits instead of a WCS instance? (this wouldn't break any compatibility since it's a new mode).
Another possibility (though closely related) which I think I prefer would be to start writing a new class, FITSWCS, which would become the new de-facto class that we recommend to users. This class would present APE 14 plus some settable properties for the main WCS properties (but not in a wcs.wcs sub-object, just at the top level. This class would aim to have a cleaner API than the current WCS class. Given how widely used the WCS class is, we would not deprecate it but just not mention it anymore in the docs. This new class could then also implement more sensible behavior in terms of units. Internally of course, this could still store a WCS class to do a lot of the heavy lifting, as a private attribute.
Activity
astrofrog commentedon Mar 3, 2026
Fixed in #18338 - in fact it's just the existing
WCSclass but with apreserve_units=True/Falseoption