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

Refactor xarray grid deltas calculation to handle axis order flexibly #1260

Merged
merged 8 commits into from
Jan 13, 2020
Merged

Refactor xarray grid deltas calculation to handle axis order flexibly #1260

merged 8 commits into from
Jan 13, 2020

Conversation

jthielen
Copy link
Collaborator

@jthielen jthielen commented Dec 28, 2019

Description Of Changes

As noted in #1249 (comment), the grid deltas calculation does not handle dimension/axis order that are not (..., y, x), whereas a goal of MetPy's xarray integration is to be able to flexibly handle dimension order. This PR refactors lat_lon_grid_deltas and grid_deltas_from_dataarray to now flexibly handle dimension order. There were also some accompanying changes:

Checklist

dopplershift
dopplershift previously approved these changes Jan 13, 2020
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor question.

@@ -787,35 +800,48 @@ def lat_lon_grid_deltas(longitude, latitude, **kwargs):
longitude = np.asarray(longitude)
latitude = np.asarray(latitude)

# Determine dimension order for offset slicing
take_y = make_take(latitude.ndim, kwargs.pop('y_dim', -2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this and x_dim could become a kwarg-only argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Looking back at this, I'm not sure why I did it the way it is now.

Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on CI

@dopplershift dopplershift merged commit b97458e into Unidata:master Jan 13, 2020
@jthielen jthielen mentioned this pull request Jul 1, 2020
3 tasks
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

Successfully merging this pull request may close these issues.

Documentation for axes in gradient calc Investigate improvements to clean up complex indexing
2 participants