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: Tweak area weighting regrid move xdim and ydim axes #3594

Conversation

abooton
Copy link
Contributor

@abooton abooton commented Dec 12, 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.

See original PR #3587 (targeting master) for initial comments

@abooton abooton added this to the v3.0.0 milestone Dec 12, 2019
@abooton abooton mentioned this pull request Dec 12, 2019
12 tasks
@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
@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
@abooton abooton changed the title Tweak area weighting regrid move xdim and ydim axes PI-2472: Tweak area weighting regrid move xdim and ydim axes Dec 12, 2019
else:
new_data = np.moveaxis(new_data, -2, y_dim_orig)
new_data = np.moveaxis(new_data, -1, x_dim_orig)

Copy link
Contributor

Choose a reason for hiding this comment

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

These last two loops can be consolidated, since new_data will end in [..., y, x] in either case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. We'll revisit in PR #3596 after everything has been rejigged anyway

dest = _resampled_grid(self.realistic_cube[0, 0, :3, :2], 3, 3)
res = regrid_area_weighted(src, dest)
self.assertArrayShapeStats(src, (3, 2, 4), 288.08868, 0.008262919)
self.assertArrayShapeStats(res, (9, 6, 4), 288.08865, 0.00826281)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these different tests be in separate test functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usually yes, but in this case they align with the transpose function that this supersedes and also share the same results info.

@abooton abooton merged commit e3e61b3 into SciTools:area_weighted_regridding Dec 12, 2019
@@ -491,6 +491,31 @@ def _regrid_area_weighted_array(
cached_x_bounds.append(x_bounds)
cached_x_indices.append(x_indices)

# Move y_dim and x_dim to last dimensions
x_dim_orig = copy.copy(x_dim)
y_dim_orig = copy.copy(y_dim)
Copy link
Contributor

Choose a reason for hiding this comment

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

Stephen queried the use of copy.copy and I agree it isn't required here. I'll add this comment to #3596.

stephenworsley pushed a commit that referenced this pull request Dec 13, 2019
* PI-2472: Tweak area weighting regrid move xdim and ydim axes (#3594)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* PI-2472: Tweak area weighting regrid enforce xdim ydim (#3595)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* _regrid_area_weighted_array: Ensure x_dim and y_dim

* PI-2472: Tweak area weighting regrid move averaging out of loop (#3596)

* _regrid_area_weighted_array: Refactor weights and move averaging outside loop
@abooton abooton deleted the tweak_area_weighting_regrid_move_xdim_and_ydim_axes branch December 20, 2019 20:42
trexfeathers pushed a commit to trexfeathers/iris that referenced this pull request Jan 14, 2020
* PI-2472: Tweak area weighting regrid move xdim and ydim axes (SciTools#3594)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* PI-2472: Tweak area weighting regrid enforce xdim ydim (SciTools#3595)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* _regrid_area_weighted_array: Ensure x_dim and y_dim

* PI-2472: Tweak area weighting regrid move averaging out of loop (SciTools#3596)

* _regrid_area_weighted_array: Refactor weights and move averaging outside loop
pp-mo pushed a commit to pp-mo/iris that referenced this pull request Jan 14, 2020
* PI-2472: Tweak area weighting regrid move xdim and ydim axes (SciTools#3594)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* PI-2472: Tweak area weighting regrid enforce xdim ydim (SciTools#3595)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* _regrid_area_weighted_array: Ensure x_dim and y_dim

* PI-2472: Tweak area weighting regrid move averaging out of loop (SciTools#3596)

* _regrid_area_weighted_array: Refactor weights and move averaging outside loop
pp-mo pushed a commit to pp-mo/iris that referenced this pull request Jan 14, 2020
* PI-2472: Tweak area weighting regrid move xdim and ydim axes (SciTools#3594)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* PI-2472: Tweak area weighting regrid enforce xdim ydim (SciTools#3595)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* _regrid_area_weighted_array: Ensure x_dim and y_dim

* PI-2472: Tweak area weighting regrid move averaging out of loop (SciTools#3596)

* _regrid_area_weighted_array: Refactor weights and move averaging outside loop
trexfeathers added a commit that referenced this pull request Jan 16, 2020
* Bump version to 2.4.0rc0.

* unpin mpl (#3468)

* Merge pull request #3301 from bayliffe/fastpercentilemethod_mask_test

Analysis percentile method - update applicability test for fast_percentile_method

* Have Travis test with iris-grib, remove problem tests (#3469)

* Have Travis test with iris-grib, remove problem tests

* mock GribInternalError correctly

* Update license headers

* account for changes in handling of grib message defaults

* Test against the latest version of python-eccodes

* Moved irir-grib skip to iris.tests

* Merge pull request #2608 from cpelley/PICKLEABLE_FORMATS

TEST: Extends #2569 to unpickle

* _regrid_area_weighted_array: Move axes creation over which weights are calculated to before loop (#3519)

* Purge iris.experimental.regrid np<1.7 support (#3539)

* Add NameConstraint with relaxed name loading (#3463)

* _regrid_area_weighted_array:  move indices variable nearer to use (#3564)

* _regrid_area_weighted_array: Tweak variable order to near other use in code (#3571)

* Fix problems with export and echo command. (#3577)

* Pushdocs fix2 (#3580)

* Revert to single-line command for doctr invocation.

* Added script comment, partly to force Github respin.

* Bracketed six.moves and __future__ imports.

* Fixes required due to the release of iris-grib v0.15.0 (#3582)

* Fix python-eccodes pin in travis (#3593)

* PI-2472: Optimise the area weighted regridding routine (#3598)

* PI-2472: Tweak area weighting regrid move xdim and ydim axes (#3594)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* PI-2472: Tweak area weighting regrid enforce xdim ydim (#3595)

* _regrid_area_weighted_array: Set axis order to y_dim, x_dim last dimensions

* _regrid_area_weighted_array: Extra tests for axes ordering

* _regrid_area_weighted_array: Ensure x_dim and y_dim

* PI-2472: Tweak area weighting regrid move averaging out of loop (#3596)

* _regrid_area_weighted_array: Refactor weights and move averaging outside loop

* Pin pillow to make graphics tests work again. (#3630)

* PI-2472: Area weighted regridding (#3623)

* The Area-weights routine is refactored into the "__prepare" and "__perform" structure, in-line with our other regridding methods.
* The area-weights are now computed in the "__prepare", so are calculated once.
* The information required for checking the regridding weights and target grid info are now cached on the "regridder" object.
* This is inline with the general use already described in the documentation.

* pep8 conformance.

* pep8 compliance.

* Allow some 'key=None' args in Geostationary creation. (#3628)

LGTM

* Allow some 'key=None' args in Geostationary creation.

* Integration test loading netcdf geostationary without offset properties.

* pep8 conformance.

* pep8 conformance.

* pep8 conformance.

* test_NameConstraint get mock from iris.tests.

* Remove use of super() in _constraints.py for Py2 compatibility.

* Updated license headers.

* Updated iris-grib reference in extensions.txt.

* Py2 support for iris-grib in Travis.

* Updates for auto docs for Iris 2.4 release.

* What's new entry to unpinning mpl.

* Edited Py2 support for iris-grib in Travis.

* Renamed whatsnew contributions folder for v2.4.

* Hacked tests.integration.test_grib2 to avoid import error from iris-grib version < 0.15.

* Only test grib with python 3.

* Compiled v2.4 whatsnew.

Co-authored-by: Martin Yeo <[email protected]>
Co-authored-by: Bill Little <[email protected]>
Co-authored-by: stephenworsley <[email protected]>
Co-authored-by: abooton <[email protected]>
Co-authored-by: lbdreyer <[email protected]>
Co-authored-by: Emma Hogan <[email protected]>
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.

3 participants