Skip to content

Commit 4e06c3a

Browse files
committed
Simplify legacy gridspec for reduced_gg
1 parent 689eb8c commit 4e06c3a

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/earthkit/data/field/grib/legacy_grid_spec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class LegacyGridSpecMaker(dict):
110110
def __init__(self, metadata):
111111
self.conf = CONF.config
112112

113+
self._global = metadata.get("global", 0) == 1
114+
113115
# remap metadata keys and get values
114116
d = {}
115117
for k, v in self.conf["grib_key_map"].items():
@@ -146,7 +148,10 @@ def make(self):
146148
for k in self.conf["rotation_keys"]:
147149
d.pop(k, None)
148150

149-
# only canonical scanning mode is supported
151+
if d.get("type", None) == "reduced_gg" and self._global:
152+
d.pop("area", None)
153+
154+
# only canonical scanning mode is supported
150155
for k in list(d.keys()):
151156
if k == "j_points_consecutive":
152157
if d[k] != 0:

tests/data/gridspec/reduced_gg.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
longitudeOfLastGridPointInDegrees: -70.0
2727
- file: reduced_gg/t_reduced_gg_O128_global.grib1
2828
gridspec:
29-
area:
30-
- 89.463
31-
- 0.0
32-
- -89.463
33-
- 359.319
29+
# area:
30+
# - 89.463
31+
# - 0.0
32+
# - -89.463
33+
# - 359.319
3434
grid: O128
3535
i_scans_negatively: 0
3636
j_points_consecutive: 0

tests/grib/test_grib_gridspec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
from earthkit.data.utils.testing import earthkit_remote_test_data_file
2323
from earthkit.data.utils.testing import earthkit_test_data_file
2424

25+
# TODO: all the se tests are for the legacy gridspec. We should add tests for the
26+
# new one from eckit.geo as well, and then remove the legacy one.
27+
28+
2529
SUPPORTED_GRID_TYPES = [
2630
"sh",
2731
"regular_ll",
@@ -88,6 +92,7 @@ def test_grib_gridspec_from_metadata_valid(metadata, ref, name):
8892
pytest.skip()
8993

9094
ref = ref.copy()
95+
9196
for k in ["type", "i_scans_negatively", "j_points_consecutive", "j_scans_positively"]:
9297
ref.pop(k, None)
9398

0 commit comments

Comments
 (0)