Skip to content

Allow frames to set a default wrap angle for longitudes #11767

Open

Description

@mhvk

In #11676, a new HADec frame is introduced, for which the natural range for the longitude (hour angle) is -12 to 12 hours. We had to add a hack to ensure the default wrap angle for [Unit]SphericalRepresentation is overwritten, similar to the hack used in SkyOffsetFrame (and perhaps similar to what is done in sunpy?). It would be good if the frame_specific_representation_info could also give a default wrap_angle.

Activity

  1. mkbrewer commented on May 21, 2021

    @mkbrewer
    Contributor

    I should think that the required range should be inherent in the definition of units.hourangle.
    Never mind.

  2. ayshih commented on May 21, 2021

    @ayshih
    Contributor

    Since you mentioned SunPy, here's a reminder for how we've implemented it in our base frame (sunpy/sunpy#3223, inspired by #7462 (comment)):

    https://github.com/sunpy/sunpy/blob/e0289b1aae66c667c43e36a306ba274b666fbfd4/sunpy/coordinates/frames.py#L141-L148

        def represent_as(self, base, s='base', in_frame_units=False):
            data = super().represent_as(base, s, in_frame_units=in_frame_units)
    
            # If a frame wrap angle is set, use that wrap angle for any spherical representations.
            if self._wrap_angle is not None and \
               isinstance(data, (UnitSphericalRepresentation, SphericalRepresentation)):
                data.lon.wrap_angle = self._wrap_angle
            return data

    Any of our frame classes can change the inherited class variable _wrap_angle from its default value of 180 degrees.

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