Skip to content

Commit

Permalink
Improve orca gridspec checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz committed Dec 20, 2024
1 parent b3da4eb commit c1a1696
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/earthkit/regrid/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

HEALPIX_PATTERN = re.compile(r"[Hh]\d+")
RGG_PATTERN = re.compile(r"[OoNn]\d+")
ORCA_PATTERN = re.compile(r"eORCA\d+_[TUVW]")
ORCA_PATTERN = re.compile(r"^e?ORCA\d+_[FTUV]$")


# NOTE: this is a temporary code until the full gridspec
# implementation is available via earthkit-geo.
Expand Down
4 changes: 3 additions & 1 deletion tests/test_gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def test_gridspec_ok(gs_in, gs_out):
({"grid": "N32", "shape": 6599680}, {"grid": [10, 10]}, None),
({"grid": "N32", "area": [90, 0, -90, 359.999]}, {"grid": [10, 10]}, None),
({"grid": "N32", "area": [90, -0.1, -90, 360]}, {"grid": [10, 10]}, None),
({"grid": "ORCA025_T"}, {"grid": "O96"}, ValueError),
({"grid": "ORCA025_T"}, {"grid": "O96"}, None),
({"grid": "eORCA025_U"}, {"grid": "O96"}, None),
({"grid": "bORCA025_T"}, {"grid": "O96"}, ValueError),
({"grid": "ORCA025_TU"}, {"grid": "O96"}, ValueError),
],
)
def test_gridspec_bad(gs_in, gs_out, err):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ def test_local_gridspec_ok(gs_in, gs_out):
({"grid": "N32", "area": [90, 0, -90, 359.999]}, {"grid": [10, 10]}, None),
({"grid": "N32", "area": [90, -0.1, -90, 360]}, {"grid": [10, 10]}, None),
({"grid": "H4", "ordering": "any"}, {"grid": [10, 10]}, ValueError),
({"grid": "ORCA025_T"}, {"grid": "O96"}, ValueError),
({"grid": "ORCA025_T"}, {"grid": "O96"}, None),
({"grid": "eORCA025_U"}, {"grid": "O96"}, None),
({"grid": "bORCA025_T"}, {"grid": "O96"}, ValueError),
({"grid": "ORCA025_TU"}, {"grid": "O96"}, ValueError),
],
)
def test_local_gridspec_bad(gs_in, gs_out, err):
Expand Down

0 comments on commit c1a1696

Please sign in to comment.