-
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
Unify unstructured and rectilinear schemes (curvilinear support) #175
Conversation
Codecov Report
@@ Coverage Diff @@
## main #175 +/- ##
==========================================
- Coverage 99.40% 99.38% -0.02%
==========================================
Files 28 28
Lines 2703 2785 +82
==========================================
+ Hits 2687 2768 +81
- Misses 16 17 +1
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py
Show resolved
Hide resolved
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 how this has gone, but I still think we can make it easier to read/maintain:
if regridder_type == "GridToMeshESMFRegridder":
grid_name = SOURCE_NAME
mesh_name = TARGET_NAME
elif regridder_type == "MeshToGridESMFRegridder":
mesh_name = SOURCE_NAME
grid_name = TARGET_NAME
else:
msg = (
f"Expected a regridder of type `GridToMeshESMFRegridder` or "
f"`MeshToGridESMFRegridder`, got type {regridder_type}."
)
raise TypeError(msg)
grid_cube = _standard_grid_cube((rg.grid_y, rg.grid_x), grid_name)
mesh_coords = rg.mesh.to_MeshCoords(rg.location)
mesh_data = np.zeros(tgt_mesh_coords[0].points.shape[0])
mesh_cube = Cube(tgt_data, var_name=mesh_name, long_name=mesh_name)
for coord in tgt_mesh_coords:
mesh_cube.add_aux_coord(coord, 0)
We then wouldn't need the if/else here too https://github.com/SciTools-incubator/iris-esmf-regrid/blob/d2e22bc97283512a0c4fab131818f4b0c1643b8d/esmf_regrid/experimental/io.py#L147-L150
Actually, I think we can get rid of this anyway because it seems like the bug in iris it's trying to work around has been fixed. I'm hesitant to organise the cubes by being |
Generalises the helper functions (
_cube_to_GridInfo
and_create_cube
) so that one of each type of function can be used for all regridding schemes. This reduces code copying and begins to unify the behaviour of the regridders.This adds curvilinear support to the unstructured regridders.