-
Notifications
You must be signed in to change notification settings - Fork 17
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
Unstructured Scheme - Basic GridInfo Handling #32
Unstructured Scheme - Basic GridInfo Handling #32
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate these into two tests, consider the naming convention (keep consistent with iris).
@@ -28,7 +37,17 @@ def _cube_to_MeshInfo(cube): | |||
def _cube_to_GridInfo(cube): | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.