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
Add unit- and axis-aware selection to the metpy accessors #971
Conversation
Instead of copying in xarray code, can we just delegate to the |
While I couldn't think of a way to not reuse the |
I still need to give this a more detailed review, but I definitely prefer this to the copy-and-modify version. Thanks! |
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.
Nice work. The xarray handling code is getting a bit big, but not too unwieldy...yet. We may yet be broken by xarray because we're using things they consider outside their public API, but that's ok. Small price to pay for this nice bit of functionality.
If you can rebase this to merge cleanly, I think we're good to go here. |
This commit adds the .loc indexer and .sel method to both the DataArray and Dataset metpy accessors to allow for unit-aware indexing/selection. For DataArrays (for which axis types are uniquely determined), this also allows selection via the axis name ('time', 'vertical', etc.) instead of the coordinate name. Also, adds this new unit-aware selection to the xarray tutorial.
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.
Rebased and clean!
This PR adds
.loc[]
and.sel()
to both the DataArray and Dataset accessors to allow for unit-aware indexing/selection. Also, for DataArrays (for which axis types are uniquely determined), I also added in selection via the axis name ('time', 'vertical', etc.).As an example, now something like this can be done:
Closes #970.
Also, I reused some code from xarray with modification for this (theloc
indexers). What is the proper way to cite this in the code given their license?