-
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 - Cube Creation 2D #39
Unstructured Scheme - Cube Creation 2D #39
Conversation
Codecov Report
@@ Coverage Diff @@
## unstructured_scheme #39 +/- ##
=======================================================
+ Coverage 92.08% 93.00% +0.91%
=======================================================
Files 12 13 +1
Lines 455 486 +31
=======================================================
+ Hits 419 452 +33
+ Misses 36 34 -2
Continue to review full report at Codecov.
|
new_cube.metadata = copy.deepcopy(src_cube.metadata) | ||
|
||
for coord in src_cube.coords(dimensions=()): | ||
new_cube.add_aux_coord(coord.copy()) |
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.
Code is copied from https://github.com/SciTools/iris/blob/f76288cb82eefc5bc3c74461bfd8f397618eda14/lib/iris/analysis/_regrid.py#L360-L363 . This is from a regridder which is specifically for 2D cubes.
This code is likely to be replaced when we update to handle more dimensions.
@@ -70,7 +72,7 @@ def _cube_to_GridInfo(cube): | |||
# return result | |||
|
|||
|
|||
def _create_cube(data, src_cube, mesh_dim, mesh, grid_x, grid_y): | |||
def _create_cube(data, src_cube, mesh_dim, grid_x, grid_y): |
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.
Originally this followed a pattern seen for example here. In this pattern, (x_dim
, y_dim
) is equivalent to mesh_dim
and (src_x_coord
, src_y_coord
) is equivalent to mesh
. If we followed the same pattern then the purpose of mesh
would be to determine which coordinates to copy over from src_cube
to the new cube, this would be done by performing a comparison which used mesh
. We anticipate that this would be done in multidimensional regridding. However, since a cube can only have one mesh, all that will need to be checked is whether the coord is a MeshCoord (or has a mesh attribute). It is therefore unlikely we will need mesh
during cube creation and so I am removing it from the arguments.
@@ -81,7 +83,13 @@ def _create_cube(data, src_cube, mesh_dim, mesh, grid_x, grid_y): | |||
|
|||
new_cube = iris.cube.Cube(data) | |||
|
|||
# TODO: add coords and metadata. | |||
new_cube.add_dim_coord(grid_x, mesh_dim + 1) | |||
new_cube.add_dim_coord(grid_y, mesh_dim) |
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 dimension ordering is set so that grid_y
is explicitly before grid_x
. This will be the case even if the dimension ordering is the other way around in the target cube. The ability to be preserve the target cube dimension ordering may be added in future.
TODO: add a comment describing this design decision.
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.
@stephenworsley thanks for making the changes we discussed. could you make this comment just a tad more descriptive of what would need to be done? i.e. this is the specific case that will work for 2D, but needs to be reworked for 3D. Thanks!
4120efa
to
3155be3
Compare
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.
Great work @stephenworsley , LGTM!
* 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 <[email protected]> Co-authored-by: Anna Booton <[email protected]> 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 <[email protected]> Co-authored-by: Anna Booton <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fleshes out the creation of cubes. Now adds grid coordinates from the target cube and copies over metadata and scalar coords from the source cube. Code is mostly copied from a similar iris functionality here https://github.com/SciTools/iris/blob/master/lib/iris/analysis/_regrid.py#L360-L363.