Repository navigation
Description
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
astropy/astropy/visualization/wcsaxes/wcsapi.py
Lines 54 to 71 in cf99b9e
| 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
samaloney commentedon Apr 25, 2024
In a slack discussion the concept of extending the context manager approach as used here
astropy/astropy/wcs/wcsapi/fitswcs.py
Line 165 in cf99b9e
and here
astropy/astropy/wcs/utils.py
Line 273 in cf99b9e
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
astropy/astropy/wcs/wcsapi/fitswcs.py
Lines 117 to 126 in cf99b9e
and sunpy already directly adds custom frames mappings to the lists
astropy/astropy/wcs/utils.py
Lines 269 to 270 in cf99b9e
here
https://github.com/sunpy/sunpy/blob/5b27fef34b9f36256da4037ba27b0bece61e755a/sunpy/coordinates/wcs_utils.py#L206-L207
[-]Support custom mapping from UCD to WSCAxes properties[/-][+]Support custom mapping from UCD to WSCAxes properties for custom coordinate frames[/+]