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

PI-2472: _regrid_area_weighted_array: Set order y_dim, x_dim axis to be last dimensions #3587

Conversation

abooton
Copy link
Contributor

@abooton abooton commented Dec 9, 2019

Re-order the axis to be [..., y_dim, x_dim]. The weights.T then becomes redundant.
Changes are in preparation for optimising the averaging.

@abooton abooton mentioned this pull request Dec 9, 2019
12 tasks
src_data = np.moveaxis(src_data, y_dim, -2)
x_dim = src_data.ndim - 1
y_dim = src_data.ndim - 2

# Create empty data array to match the new grid.
Copy link
Contributor

Choose a reason for hiding this comment

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

  • test_regrid_transposed is the only test that has an input that is affected by np.moveaxis (the fourth loop). Would it be possible to add a test with an input that is affected by np.moveaxis for each of the other loops?
  • Since all the other tests don't require any axes to be moved, is it worth performing a check to determine whether an axis needs to be moved before moving it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. If we add a test for data ordered: [x, z, y], and like [y, x, z] I think this captures most of it. In the next PR we ensure we have x and y dims to might want to re-evaluate this next.

@abooton abooton force-pushed the tweak_area_weighting_regrid_move_xdim_and_ydim_axes branch from 2124de1 to 3a14cb1 Compare December 12, 2019 08:19
z = src.coord("model_level_number")
lat = src.coord("grid_latitude")
lon = src.coord("grid_longitude")
z_shape = 4

Choose a reason for hiding this comment

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

F841 local variable 'z_shape' is assigned to but never used

lat = src.coord("grid_latitude")
lon = src.coord("grid_longitude")
z_shape = 4
lat_shape = 3

Choose a reason for hiding this comment

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

F841 local variable 'lat_shape' is assigned to but never used

lon = src.coord("grid_longitude")
z_shape = 4
lat_shape = 3
lon_shape = 2

Choose a reason for hiding this comment

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

F841 local variable 'lon_shape' is assigned to but never used

@abooton abooton force-pushed the tweak_area_weighting_regrid_move_xdim_and_ydim_axes branch from 3a14cb1 to 0792ad1 Compare December 12, 2019 08:24
@trexfeathers
Copy link
Contributor

Closing as superseded by #3594

@abooton abooton deleted the tweak_area_weighting_regrid_move_xdim_and_ydim_axes branch December 20, 2019 20:42
@abooton abooton changed the title _regrid_area_weighted_array: Set order y_dim, x_dim axis to be last dimensions PI-2472: _regrid_area_weighted_array: Set order y_dim, x_dim axis to be last dimensions Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants