Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_cf should not overwrite existing axis attributes #981

Closed
jthielen opened this issue Dec 14, 2018 · 0 comments
Closed

parse_cf should not overwrite existing axis attributes #981

jthielen opened this issue Dec 14, 2018 · 0 comments
Labels
Area: Xarray Pertains to xarray integration Type: Enhancement Enhancement to existing functionality
Milestone

Comments

@jthielen
Copy link
Collaborator

This was brought up in #960: while the current re-assignment of the axis attribute in parse_cf() keeps parse_cf() idempotent, it may still overwrite information that was previously in that attribute. Since the issue of #960 itself was resolved by #967, repeated below are the parts relevant for this issue so they don't get lost. Any thoughts about the best way to fix this?


Current implementation:

MetPy/metpy/xarray.py

Lines 336 to 343 in 1a052be

def _assign_axes(coord_map, var):
"""Assign axis attribute to coordinates in var according to coord_map."""
for coord_var in var.coords.values():
if 'axis' in coord_var.attrs:
del coord_var.attrs['axis']
for axis in coord_map:
if coord_map[axis] is not None:
coord_map[axis].attrs['axis'] = axis

Some ideas for possible fixes:

  • Use a metpy_axis attribute instead of axis (or some other "namespaced" attribute)
  • Store the axis type -> coordinate information in the attributes of the crs coordinate
  • Store the axis type -> coordinate information in the CFProjection object itself
@dopplershift dopplershift added Area: Xarray Pertains to xarray integration Type: Enhancement Enhancement to existing functionality labels Jun 6, 2019
@dopplershift dopplershift added this to the 0.10 milestone Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Xarray Pertains to xarray integration Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants