Skip to content

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

Merged
dopplershift merged 8 commits into
Unidata:masterfrom
jthielen:xarray-dim-order
Jan 13, 2020
Merged

Refactor xarray grid deltas calculation to handle axis order flexibly#1260
dopplershift merged 8 commits into
Unidata:masterfrom
jthielen:xarray-dim-order

Conversation

@jthielen

@jthielenjthielen commented Dec 28, 2019

Copy link
Copy Markdown
Collaborator

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

@dopplershiftdopplershift left a comment

Copy link
Copy Markdown
Member

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.

Comment threadsrc/metpy/calc/tools.py Outdated
latitude = np.asarray(latitude)

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

Copy link
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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.

Comment threadsrc/metpy/calc/tools.py

@dopplershiftdopplershift left a comment

Copy link
Copy Markdown
Member

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:masterJan 13, 2020
@jthielenjthielen mentioned this pull request Jul 1, 2020
3 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: XarrayPertains to xarray integrationType: EnhancementEnhancement 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

@jthielen@dopplershift