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

Query grid object? #239

Closed
kthyng opened this issue Sep 18, 2020 · 5 comments
Closed

Query grid object? #239

kthyng opened this issue Sep 18, 2020 · 5 comments
Labels

Comments

@kthyng
Copy link

kthyng commented Sep 18, 2020

Sorry if I have missed this, but is it possible to query an existing xgcm grid object for information? Something like grid.get_coords(array, axes) such that grid.get_coords(ds.temp, 'X') would return 'center' (name of position). It would then also be useful to be able to generally query the position and return the name of the coord: grid.get_coord_from_position('center') would return 'xi_rho' (name of coordinate associated with that position and axis).

@jbusecke
Copy link
Contributor

This functionality is available but currently not part of the public API.
I believe grid.axes[axis]._get_axis_coord does what you are looking for.

@kthyng
Copy link
Author

kthyng commented Sep 18, 2020

Excellent! Thank you. 🙏 I would also like to be able to ask generally for information from the grid, like asking grid for the name of the coordinate given the position name and axis, but not associated with a particular array (what the second question above is after). Does that happen to be accessible?

@jbusecke
Copy link
Contributor

grid[axis].coords[position] should do that.

@kthyng
Copy link
Author

kthyng commented Sep 18, 2020

Thank you so much, I was able to get it to work with grid.axes[axis].coords[position]. I really appreciate you helping me figure this out! I'll close this now.

@kthyng kthyng closed this as completed Sep 18, 2020
@jbusecke
Copy link
Contributor

Any time! Very excited that you are using xgcm for your projects.

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

No branches or pull requests

2 participants