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
WIP: CF convention parser #568
base: master
Are you sure you want to change the base?
Conversation
This actually works quite neatly out of the box thanks to cf-xarray. Using this I can take a CMIP6 dataset: And get a fully functional xgcm grid with a few lines: kwargs = cf_parser(ds)
grid = Grid(**kwargs)
grid
The parser function modifies the dataset and then passes it + additional kwargs (at the moment only the This design follows the ideas layed out in #566 and might also be a good example for #559 (cc @jatkinson1000). I think once we have #557 done, we can use this PR to refactor the way metadata conventions are parsed, and then add support for SGRID via #559. |
@dcherian I am curious if you have some ideas on testing here. This works well with a single dataset, but I figured you have a lot more experience with edge cases re CF stuff. |
Another general question here would be if we want to make cf-xarray a full or optional dependency. cc @rabernat @dcherian @TomNicholas. |
Hah I think the edge cases are in the CMIP archive :) |
LOL |
import cf_xarray | ||
|
||
|
||
def cf_parser(ds): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should type hint this, probably with TypedDict
pre-commit run --all-files
whats-new.rst
api.rst
cf-xarray