Skip to content

Conversation

@ehogan
Copy link
Contributor

@ehogan ehogan commented Dec 17, 2019

This pull request refactors AreaWeightedRegridder to call the relevant __prepare and __perform functions.

I've not come across mock.sentinel before, so I've had to comment out one assert that I can't get to work.

@ehogan
Copy link
Contributor Author

ehogan commented Dec 18, 2019

I managed to reproduce the doctest failure by updating my local conda install to match the environment that Travis uses. I'll continue debugging tomorrow (unless someone else gets to it first!) ;)

@stephenworsley stephenworsley added this to the v3.0.0 milestone Dec 19, 2019
@ehogan
Copy link
Contributor Author

ehogan commented Dec 19, 2019

The doctest was failing due to the fact that the source cube is now being cached (a new cube is created) in AreaWeightedRegridder. This means that when RectilinearRegridder._create_cube is called, copy_coords, didn't correctly copy the latitude and longitude coordinates (using is checks whether both variables refer to the same object, which is no longer true), which resulted in VOLCANIC_ASH_AIR_CONCENTRATION / (g/m3) (-- : 73; -- : 96) rather than VOLCANIC_ASH_AIR_CONCENTRATION / (g/m3) (latitude: 73; longitude: 96) (thanks to @stephenworsley for finding the root cause!).

@abooton abooton changed the title Refactor AreaWeightedRegridder PI-2472: Refactor AreaWeightedRegridder Dec 19, 2019
@ehogan
Copy link
Contributor Author

ehogan commented Dec 19, 2019

__prepare is now called when the AreaWeightedRegridder is instantiated. This allows the use of src_grid_cube directly, without caching it, which enables the change I made that was detailed here to be removed. It's possible that target_grid_cube also doesn't need to be cached, since it is only now used in __prepare (which is only called once, when AreaWeightedRegridder is instantiated). However, I'm not sure if there would be any significant performance issues related to the fact that the cached target_grid_cube has no data associated with it.

… be regridded are equal to the data dims of the x and y coordinates of the source cube used to set up the regridder
@abooton
Copy link
Contributor

abooton commented Dec 20, 2019

Looks good. :)
Now, most of the checks on the src and target cube are done at the instantiation of the regridder. We then check that the src cube x&y dims match those that the checks were done on. At a later date we might be able to revisit the restrictions and reduce them a little. However this is not easy to determine until the weights refactor is in.

@abooton abooton merged commit f4c7ff4 into SciTools:area_weighted_regridding Dec 20, 2019
@ehogan ehogan deleted the refactor_area_weighted_regridder branch December 20, 2019 10:05
abooton added a commit to abooton/iris that referenced this pull request Jan 9, 2020
* pr/3623:
  PI-2472:  Update area weighted regridder to accept different dim data (SciTools#3625)
  PI-2472: Fix issue related to comparison / equality in regridding code (SciTools#3624)
  Remove unused variables in regridding code (SciTools#3620)
  Add docstring and what's new (SciTools#3619)
  Move calculation of area weights from perform to prepare (SciTools#3617)
  PI-2472: Refactor AreaWeightedRegridder (SciTools#3606)
  Test for AreaWeightedRegridder (SciTools#3604)
  Split regrid_area_weighted_rectilinear_src_and_grid into prepare and perform (SciTools#3601)
abooton pushed a commit to abooton/iris that referenced this pull request Jan 9, 2020
* Add prepare and perform to the AreaWeightedRegridder
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