Skip to content

Commit

Permalink
Refactor and unify regridding schemes (#198)
Browse files Browse the repository at this point in the history
* rearrange helper functions

* tidy dimension variable names

* switch data chunking

* fix tests

* fix tests

* refactor AreaWeightedRegridder

* fix

* fix

* fix keywords

* refactor unstructured schemes

* fix tests

* fill out unstructured schemes

* add error handling

* remove old code, improve docstrings

* refresh cache

* remove old code

* increment pip cache

* remove old code

* fix imports

* fix test imports

* remove imports

* fix imports

* fix imports

* fix imports

* fix test

* remove old code

* add test files

* run benchmarks on python 3.9, add test files

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refresh cache

* refresh cache

* lint fix

* reset CI changes

* fix tests

* add and fix tests

* fix tests

* revert changes to _mesh_to_MeshInfo

* add tests

* revert lazy data handling to previous solution

* address review comments

* address review comments

* address review comments

* address review comments

* add test, fix docstring

* fix tests

* remove superfluous test__cube_to_GridInfo.py

* move test__mesh_to_MeshInfo.py, fix tests

* move tests

* fix tests

* parameterize laziness tests

* clarify target type

* remove resolution keyword

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix loading

* combine docstring descriptions

* remove TODO

* retain more detailed commented code

* retain mesh checking behaviour

* fix benchmarks

* fix tests

* Apply suggestions from code review

Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>

* address review comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
  • Loading branch information
3 people committed May 12, 2023
1 parent e1a9465 commit 68de5c5
Show file tree
Hide file tree
Showing 19 changed files with 1,324 additions and 848 deletions.
4 changes: 2 additions & 2 deletions benchmarks/benchmarks/esmf_regridder/scalability.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def src_cube(self, height):

def add_src_metadata(self, cube):
"""Add appropriate MeshCoords from _gridlike_mesh to the given `cube`."""
from esmf_regrid.tests.unit.experimental.unstructured_scheme.test__mesh_to_MeshInfo import (
from esmf_regrid.tests.unit.schemes.test__mesh_to_MeshInfo import (
_gridlike_mesh,
)

Expand Down Expand Up @@ -306,7 +306,7 @@ def setup_cache(self):

def tgt_cube(self):
"""Cube containing the regridding target grid."""
from esmf_regrid.tests.unit.experimental.unstructured_scheme.test__mesh_to_MeshInfo import (
from esmf_regrid.tests.unit.schemes.test__mesh_to_MeshInfo import (
_gridlike_mesh,
)

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def external(*args, **kwargs):
"""
from iris import save

from esmf_regrid.tests.unit.experimental.unstructured_scheme.test__mesh_to_MeshInfo import (
from esmf_regrid.tests.unit.schemes.test__mesh_to_MeshInfo import (
_gridlike_mesh_cube as original,
)

Expand Down
10 changes: 9 additions & 1 deletion esmf_regrid/experimental/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,23 @@ def load_regridder(filename):
else:
use_tgt_mask = False

if scheme is GridToMeshESMFRegridder:
resolution_keyword = "src_resolution"
elif scheme is MeshToGridESMFRegridder:
resolution_keyword = "tgt_resolution"
else:
raise NotImplementedError
kwargs = {resolution_keyword: resolution}

regridder = scheme(
src_cube,
tgt_cube,
mdtol=mdtol,
method=method,
precomputed_weights=weight_matrix,
resolution=resolution,
use_src_mask=use_src_mask,
use_tgt_mask=use_tgt_mask,
**kwargs,
)

esmf_version = weights_cube.attributes[VERSION_ESMF]
Expand Down

0 comments on commit 68de5c5

Please sign in to comment.