Skip to content

Develop new APE 14-compliant WCS class for FITS WCS with units preserved #8664

Closed

Description

@astrofrog

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.

EDIT: Fix #8819

Activity

  1. astrofrog commented on Mar 3, 2026

    @astrofrog
    MemberAuthor

    Fixed in #18338 - in fact it's just the existing WCS class but with a preserve_units=True/False option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions