SciTools / iris

A powerful, format-agnostic, and community-driven Python package for analysing and visualising Earth science data
https://scitools-iris.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
624 stars 280 forks source link

conservative regrid : unexpectedly masked data #700

Closed bblay closed 10 years ago

bblay commented 10 years ago

Using regrid_conservative_via_esmpy, we are getting two masked points. These target points are inside the source cube, so it seems they should not be getting masked (an IDL routine does not mask them).

The masked points can be seen here, and the problem can be recreated using the files here

bblay commented 10 years ago

Grateful for any thoughts, @pp-mo.

pp-mo commented 10 years ago

May be related to some problems already identified in the Iris tests.

I think that rounding errors can often produce masking when you'd expect it not to. There's already a kludge for that in one of the tests... see : https://github.com/SciTools/iris/blob/master/lib/iris/tests/experimental/regrid/test_regrid_conservative_via_esmpy.py ...

General advice: could try reducing the bounds by a small fraction -- but, as the comment says, 5% is not a small fraction !! If there is an actual bug here, it is probably in ESMF.

rokuingh commented 10 years ago

Hi,

I am an ESMF developer. I heard through a 3rd party who is mostly out of touch because he is on vacation that you were having a problem with ESMF conservative regridding. Looking at the snippet of the message he sent (below) I'm not able to tell what's going on. We use integers within ESMF to mark cells as masked so there shouldn't be a problem with rounding. I'd be happy to look into this further on the ESMF side if I can get more information about the symptoms.

Thanks!

May be related to some problems already identified in the Iris tests.

I think that rounding errors can often produce masking when you'd expect it not to. There's already a kludge for that in one of the tests... see : https://github.com/SciTools/iris/blob/master/lib/iris/tests/experimental/regrid/test_regrid_conservative_via_esmpy.py ...

General advice: could try reducing the bounds by a small fraction -- but, as the comment says, 5% is not a small fraction !! If there was a bug, it is liable to be in ESMF.

pp-mo commented 10 years ago

I now think there is not a real problem here after all. I modified the example code to plot out (part of) the cell boundaries (as constructed by Coord.guess_bounds), and it now appears that the 2 points previously plotted are in the corner of the target grid (which was not totally obvious), and these 2 cells (only) do in fact go outside the source grid.

New picture looks like this: ( Green = source grid cell corners+edges, Red = target(regridded) ones Big crosses = masked result cells (centres, as in previous plot) ) figure_1

Changes shown here : https://github.com/pp-mo/iris-issue-files/commit/fba94248e04af1b2079d5c4dda4c7837da5de93a

pp-mo commented 10 years ago

Just to clarify, related to original terms...

Using regrid_conservative_via_esmpy, we are getting two masked points. These target points are inside the source cube, so it seems they should not be getting masked (an IDL routine does not mask them).

Though "target points are inside the source cube", the cells containing them are not.

bblay commented 10 years ago

Lovely job, @pp-mo. I'll pass that back to the original user.

Closing this issue because it is correct behaviour. Iris uses cells to regrid and these two target cells do extend beyond the source grid.