Skip to content

Support custom mapping from UCD to WSCAxes properties for custom coordinate frames #16339

Closed

Description

@samaloney

What is the problem this feature will solve?

The overall aim is to have nice plot with proper ax.coords setting e.g. coord_wrap, format_unit, coord_type for custom Coordinate frames.

Currently half of the is supported, fitswcs.py supports custom ctype to UCD mappings via CTYPE_TO_UCD1_CUSTOM but then on the other side wscapi.py has a hard coded list in transform_coord_meta_from_wcs therefore WCSAxes doesn't recognise the custom UCD.

So currently this can be done

MYFRAME_CTYPE_TO_UCD1 = {
    "SXLT": "custom:pos.myframe.lat",
    "SXLN": "custom:pos.myframe.lon",
    "SXRZ": "custom:pos.myframe.z"
}
astropy.wcs.wcsapi.fitswcs.CTYPE_TO_UCD1_CUSTOM.update(MYFRAME_CTYPE_TO_UCD1)

but there is no way to include settings for custom:pos.myframe.X in this section of code

for idx in range(wcs.world_n_dim):
axis_type = wcs.world_axis_physical_types[idx]
axis_unit = u.Unit(wcs.world_axis_units[idx])
coord_wrap = None
format_unit = axis_unit
coord_type = "scalar"
if axis_type is not None:
axis_type_split = axis_type.split(".")
if len(axis_type_split):
axis_type_split[0] = axis_type_split[0].replace("custom:", "")
if "pos.helioprojective.lon" in axis_type:
coord_wrap = 180.0 * u.deg
format_unit = u.arcsec
coord_type = "longitude"
elif "pos.helioprojective.lat" in axis_type:

where Id like to add something like

            if "custom:pos.MYFRAME.lon" in axis_type:
                coord_wrap = 180.0 * u.deg
                format_unit = u.arcsec
                coord_type = "longitude"
            elif "custom:pos.MYFARME.lat" in axis_type:
                format_unit = u.arcsec
                coord_type = "latitude"

Describe the desired outcome

Be able to register or other wise include custom plot setting for custom UCDs in a similar manner to how custom CTYPE to UCD mapping can be included.

Additional context

No response

Activity

  1. samaloney commented on Apr 25, 2024

    @samaloney
    ContributorAuthor

    In a slack discussion the concept of extending the context manager approach as used here

    class custom_ctype_to_ucd_mapping:

    and here

    class custom_wcs_to_frame_mappings:

    was mentioned. I wonder if in addition to this approach underlying lists and dictionaries could be exposed and documented that way other packages could add / remove mappings without relying on astropy. For example some sunpy specific mapping can be found here

    "HPLT": "custom:pos.helioprojective.lat",
    "HPLN": "custom:pos.helioprojective.lon",
    "HPRZ": "custom:pos.helioprojective.z",
    "HGLN": "custom:pos.heliographic.stonyhurst.lon",
    "HGLT": "custom:pos.heliographic.stonyhurst.lat",
    "CRLN": "custom:pos.heliographic.carrington.lon",
    "CRLT": "custom:pos.heliographic.carrington.lat",
    "SOLX": "custom:pos.heliocentric.x",
    "SOLY": "custom:pos.heliocentric.y",
    "SOLZ": "custom:pos.heliocentric.z",

    and sunpy already directly adds custom frames mappings to the lists

    WCS_FRAME_MAPPINGS = [[_wcs_to_celestial_frame_builtin]]
    FRAME_WCS_MAPPINGS = [[_celestial_frame_to_wcs_builtin]]

    here

    https://github.com/sunpy/sunpy/blob/5b27fef34b9f36256da4037ba27b0bece61e755a/sunpy/coordinates/wcs_utils.py#L206-L207

  2. changed the title [-]Support custom mapping from UCD to WSCAxes properties[/-] [+]Support custom mapping from UCD to WSCAxes properties for custom coordinate frames[/+] on Apr 26, 2024
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