Unstructured Scheme - Basic GridInfo Handling#32
Unstructured Scheme - Basic GridInfo Handling#32abooton merged 11 commits intoSciTools:unstructured_schemefrom
Conversation
Codecov Report
@@ Coverage Diff @@
## unstructured_scheme #32 +/- ##
=======================================================
+ Coverage 88.43% 91.08% +2.64%
=======================================================
Files 10 11 +1
Lines 346 415 +69
=======================================================
+ Hits 306 378 +72
+ Misses 40 37 -3
Continue to review full report at Codecov.
|
esmf_regrid/tests/unit/experimental/unstructured_scheme/test_cube_to_GridInfo.py
Outdated
Show resolved
Hide resolved
esmf_regrid/tests/unit/experimental/unstructured_scheme/test_cube_to_GridInfo.py
Outdated
Show resolved
Hide resolved
esmf_regrid/tests/unit/experimental/unstructured_scheme/test_cube_to_GridInfo.py
Outdated
Show resolved
Hide resolved
| rg = Regridder(gridinfo, gridinfo) | ||
| expected_weights = scipy.sparse.identity(n_lats * n_lons) | ||
| assert np.array_equal(expected_weights.todense(), rg.weight_matrix.todense()) | ||
|
|
There was a problem hiding this comment.
Separate these into two tests, consider the naming convention (keep consistent with iris).
| # Returns a GridInfo object describing the horizontal grid of the cube. | ||
| # This may be inherited from code written for the rectilinear regridding scheme. | ||
| pass | ||
| lat = cube.coord("latitude") |
There was a problem hiding this comment.
Do we need to confirm that the incoming cube is a gridded cube?
esmf_regrid/tests/unit/experimental/unstructured_scheme/test_cube_to_GridInfo.py
Outdated
Show resolved
Hide resolved
|
|
||
| def test_cube_to_GridInfo(): | ||
| """Basic test for :func:`~esmf_regrid.experimental.unstructured_scheme._cube_to_GridInfo`.""" | ||
| n_lats = 5 |
There was a problem hiding this comment.
Maybe we should have a test for n_lats=1. I believe this could be passed in. Not sure what the final behaviour is!
esmf_regrid/tests/unit/experimental/unstructured_scheme/test__cube_to_GridInfo.py
Outdated
Show resolved
Hide resolved
|
|
||
|
|
||
| def _grid_cube(n_lons, n_lats, lon_bounds, lat_bounds, circular=False): | ||
| lon_lower, lon_upper = lon_bounds |
There was a problem hiding this comment.
Lines 13-17 are identical to 22-27. And only the ll_bound_span needs to be returned in both cases.
Lets refactor and tidy this up - then its looking good.
| lat = cube.coord("latitude") | ||
| # Ensure coords come from a proper grid. | ||
| assert isinstance(lon, iris.coords.DimCoord) | ||
| assert isinstance(lat, iris.coords.DimCoord) |
There was a problem hiding this comment.
I like this - but I've just had a thought as to whether the scalar passes. Let's just confirm, and remove these lines if they are more problematic than helpful!
There was a problem hiding this comment.
The scalar test is passing fine with this.
Having discussed this with @stephenworsley , we think this is because the information is added to the Cube as a DimCoord, then it becomes a scalar as it has length 1. Hence the test and the data process correctly.
* Unstructured scheme skeleton (#31) * create skeleton of unstructured regridding code This code is primarily based on Iris's current Area weighted regridding scheme, with the required adaptions for accepting unstructred UGRID data. * Unstructured Scheme - Basic GridInfo Handling (#32) Add basic `GridInfo` function and associated tests. It returns an ESMF regridding object for gridded data. * Unstructured scheme iris source (#33) * refresh cirrus-ci and nox * add iris artifact support * deal with special-case cirrus-ci quoting * review actions * Unstructured Scheme - Basic MeshInfo Handling (#36) * provide iris Mesh to MeshInfo conversion * test against iris feature branch * lint fixes and documentation * fix typo * address review comments. * change tests to better reflect UGRID orientation * address review comments. * address review comments * ASCII art fix * Unstructured Scheme - Cube Creation 2D (#39) * support creation of 2D cubes * lint fixes * rewrite test * remove mesh from _create_cube arguments * add TODO * add TODO * Unstructured Scheme - Mesh Fetching (#46) * support mesh fetching * fix docstring * lint fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add docstrings * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add and restructure tests * fix test * fix test * address review comments * address review comments Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bill Little <bill.little@metoffice.gov.uk> Co-authored-by: Anna Booton <anna.booton@metoffice.gov.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Unstructured scheme skeleton (SciTools#31) * create skeleton of unstructured regridding code This code is primarily based on Iris's current Area weighted regridding scheme, with the required adaptions for accepting unstructred UGRID data. * Unstructured Scheme - Basic GridInfo Handling (SciTools#32) Add basic `GridInfo` function and associated tests. It returns an ESMF regridding object for gridded data. * Unstructured scheme iris source (SciTools#33) * refresh cirrus-ci and nox * add iris artifact support * deal with special-case cirrus-ci quoting * review actions * Unstructured Scheme - Basic MeshInfo Handling (SciTools#36) * provide iris Mesh to MeshInfo conversion * test against iris feature branch * lint fixes and documentation * fix typo * address review comments. * change tests to better reflect UGRID orientation * address review comments. * address review comments * ASCII art fix * Unstructured Scheme - Cube Creation 2D (SciTools#39) * support creation of 2D cubes * lint fixes * rewrite test * remove mesh from _create_cube arguments * add TODO * add TODO * Unstructured Scheme - Mesh Fetching (SciTools#46) * support mesh fetching * fix docstring * lint fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add docstrings * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add and restructure tests * fix test * fix test * address review comments * address review comments Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bill Little <bill.little@metoffice.gov.uk> Co-authored-by: Anna Booton <anna.booton@metoffice.gov.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This copies the most basic functionality from #26 to integrate rectilinear grid handling. This allows development of the unstructured regridder to continue.