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

axis attribute missing for lat/lon when using guess_coord_axis #368

Open
MuellerSeb opened this issue Oct 12, 2022 · 6 comments
Open

axis attribute missing for lat/lon when using guess_coord_axis #368

MuellerSeb opened this issue Oct 12, 2022 · 6 comments

Comments

@MuellerSeb
Copy link
Contributor

Hey there,

when using guess_coord_axis with lat/lon coords, the axis attribute is not added. The CF-Conventions states:

Optionally, the latitude type may be indicated additionally by providing the standard_name attribute with the value latitude, and/or the axis attribute with the value Y.

See: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#latitude-coordinate

So, the current behavior is not wrong, but I think it would be nice to have the axis attributes generated for lat/lon as well for consistency.

@MuellerSeb MuellerSeb changed the title axis attribute for lat/lon when using guess_coord_axis axis attribute missing for lat/lon when using guess_coord_axis Oct 12, 2022
@dcherian
Copy link
Contributor

dcherian commented Oct 17, 2022

The issue here is that for analysis, it is useful to distinguish between 1D dimensions or axes of the array, and the actual lat, lon coordinate variables which may be 2D.

In that case, you want to be able to do .mean(dim="X") while .mean(dim="lon") would break. So it's nice to not add axis="X" to a 2D longitude variable (for example)

@MuellerSeb
Copy link
Contributor Author

Of course, I wouldn't add the axis attribute, when lat/lon are auxiliary coordinate variables. But when there is a dim lat and a coordinate lat(lat), the axis attribute makes sense to me as it is mentioned in the cf-convention.

@dcherian
Copy link
Contributor

I think the reason I didn't do this was that it makes it hard to write code that generalizes for dimension vs auxiliary lat, lon variables.

Potentially we could have guess_coord_axis(x_is_lon=True, y_is_lat=True) to do what you want. I think I prefer the default to be False because of the above reason

the axis attribute makes sense to me as it is mentioned in the cf-convention.

Oooh can you post a link or the text from the conventions please?

@MuellerSeb
Copy link
Contributor Author

@dcherian it is in the first post:
https://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#latitude-coordinate

If lat (or lon) is a auxiliary coordinate it of course shouldn't hold an axis attribute. But if it is a coordinate lat(lat) (or lon(lon)) it makes perfectly sense to add the axis attribute.

@dcherian
Copy link
Contributor

To be clear, it is optional:

Optionally, the latitude type may be indicated additionally by providing the standard_name attribute with the value latitude, and/or the axis attribute with the value Y.

so I still like this approach:

guess_coord_axis(x_is_lon=True, y_is_lat=True)

@MuellerSeb
Copy link
Contributor Author

Yes it is optional. But I would like to get the axis (if present) without first checking if they may be lat/lon. I got a file with lat/lon/z coords but only z gets the axis attributes and lat, lon not. That seems strange to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants