Skip to content

Commit 689eb8c

Browse files
Improve legacy gridspec (#916)
1 parent 34e3518 commit 689eb8c

File tree

7 files changed

+42
-198
lines changed

7 files changed

+42
-198
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ dependencies = [
2828
"cfgrib>=0.9.10.1",
2929
"dask",
3030
"deprecation",
31-
"earthkit-utils>=0.2",
31+
"earthkit-utils>0.2.1",
3232
"eccodes>=1.7",
33+
"eckit==2.0.1.13",
3334
"entrypoints",
3435
"filelock",
3536
"jinja2",
@@ -65,7 +66,6 @@ optional-dependencies.docs = [
6566
]
6667
optional-dependencies.ecmwf-opendata = [ "ecmwf-opendata>=0.3.3" ]
6768
optional-dependencies.fdb = [ "pyfdb>=0.1" ]
68-
optional-dependencies.geo = [ "earthkit-geo>=0.2" ]
6969
optional-dependencies.geopandas = [ "geopandas" ]
7070
optional-dependencies.geotiff = [ "pyproj", "rasterio", "rioxarray" ]
7171
optional-dependencies.gribjump = [ "pyfdb>=0.1", "pygribjump" ]

src/earthkit/data/conf/gridspec.yaml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ types:
8383
- dx
8484
- dy
8585
- *area
86-
reduced_ll:
87-
grid_type: reduced_ll
88-
spec:
89-
- *shared_keys
90-
- grid:
91-
- dy
92-
- *area
9386
regular_gg:
9487
grid_type: regular_gg
9588
rotated_type: rotated_gg
@@ -111,56 +104,6 @@ types:
111104
octahedral:
112105
0: N
113106
1: O
114-
# mercator:
115-
# grid_type: mercator
116-
# spec:
117-
# - *shared_keys
118-
# - grid:
119-
# - dx_in_metres
120-
# - dy_in_metres
121-
# - *area
122-
# - nx
123-
# - ny
124-
# - lad
125-
# - orientation
126-
# polar_stereographic:
127-
# grid_type: polar_stereographic
128-
# spec:
129-
# - *shared_keys
130-
# - grid:
131-
# - dx_in_metres
132-
# - dy_in_metres
133-
# - *first_point
134-
# - nx
135-
# - ny
136-
# - lad
137-
# - orientation
138-
# lambert:
139-
# grid_type: lambert
140-
# spec:
141-
# - *shared_keys
142-
# - grid:
143-
# - dx_in_metres
144-
# - dy_in_metres
145-
# - *first_point
146-
# - nx
147-
# - ny
148-
# - lad
149-
# - lov
150-
# - latin_1
151-
# - latin_2
152-
# lambert_azimuthal_equal_area:
153-
# grid_type: lambert_azimuthal_equal_area
154-
# spec:
155-
# - *shared_keys
156-
# - grid:
157-
# - dx_in_metres
158-
# - dy_in_metres
159-
# - *first_point
160-
# - nx
161-
# - ny
162-
# - standard_parallel
163-
# - central_longitude
164107
healpix:
165108
grid_type: healpix
166109
spec:

src/earthkit/data/conf/gridspec_schema.json

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -216,28 +216,6 @@
216216
]
217217
}
218218
},
219-
{
220-
"if": {
221-
"properties": {
222-
"type": {
223-
"const": "reduced_ll"
224-
}
225-
},
226-
"required": [
227-
"type"
228-
]
229-
},
230-
"then": {
231-
"required": [
232-
"grid"
233-
],
234-
"properties": {
235-
"grid": {
236-
"type": "number"
237-
}
238-
}
239-
}
240-
},
241219
{
242220
"if": {
243221
"properties": {
@@ -287,113 +265,6 @@
287265
}
288266
}
289267
},
290-
{
291-
"if": {
292-
"properties": {
293-
"type": {
294-
"const": "mercator"
295-
}
296-
},
297-
"required": [
298-
"type"
299-
]
300-
},
301-
"then": {
302-
"required": [
303-
"grid",
304-
"nx",
305-
"ny",
306-
"lad"
307-
],
308-
"properties": {
309-
"grid": {
310-
"type": "array"
311-
}
312-
}
313-
}
314-
},
315-
{
316-
"if": {
317-
"properties": {
318-
"type": {
319-
"const": "polar_stereographic"
320-
}
321-
},
322-
"required": [
323-
"type"
324-
]
325-
},
326-
"then": {
327-
"required": [
328-
"grid",
329-
"first_point",
330-
"nx",
331-
"ny",
332-
"lad"
333-
],
334-
"properties": {
335-
"grid": {
336-
"type": "array"
337-
}
338-
}
339-
}
340-
},
341-
{
342-
"if": {
343-
"properties": {
344-
"type": {
345-
"const": "lambert"
346-
}
347-
},
348-
"required": [
349-
"type"
350-
]
351-
},
352-
"then": {
353-
"required": [
354-
"grid",
355-
"first_point",
356-
"nx",
357-
"ny",
358-
"lad",
359-
"lov",
360-
"latin_1",
361-
"latin_2"
362-
],
363-
"properties": {
364-
"grid": {
365-
"type": "array"
366-
}
367-
}
368-
}
369-
},
370-
{
371-
"if": {
372-
"properties": {
373-
"type": {
374-
"const": "lambert_azimuthal_equal_area"
375-
}
376-
},
377-
"required": [
378-
"type"
379-
]
380-
},
381-
"then": {
382-
"required": [
383-
"grid",
384-
"first_point",
385-
"nx",
386-
"ny",
387-
"standard_parallel",
388-
"central_longitude"
389-
],
390-
"properties": {
391-
"grid": {
392-
"type": "array"
393-
}
394-
}
395-
}
396-
},
397268
{
398269
"if": {
399270
"properties": {

src/earthkit/data/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def validate(self, name, value):
189189
none_ok=True,
190190
),
191191
"maximum-cache-disk-usage": _(
192-
"95%",
192+
"98%",
193193
"""Disk usage threshold after which earthkit-data expires older cached
194194
entries (% of the full disk capacity). Can be set to None.
195195
See :ref:`caching` for more information.""",

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,27 @@ def make(self):
146146
for k in self.conf["rotation_keys"]:
147147
d.pop(k, None)
148148

149+
# only canonical scanning mode is supported
150+
for k in list(d.keys()):
151+
if k == "j_points_consecutive":
152+
if d[k] != 0:
153+
return dict()
154+
else:
155+
d.pop(k)
156+
if k == "i_scans_negatively":
157+
if d[k] != 0:
158+
return dict()
159+
else:
160+
d.pop(k)
161+
if k == "j_scans_positively":
162+
if d[k] != 0:
163+
return dict()
164+
else:
165+
d.pop(k)
166+
167+
if k == "type":
168+
d.pop(k, None)
169+
149170
# CONF.validate(d)
150171
return d
151172

tests/grib/test_grib_gridspec.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525
SUPPORTED_GRID_TYPES = [
2626
"sh",
2727
"regular_ll",
28-
"reduced_ll",
2928
"regular_gg",
3029
"reduced_gg",
3130
"healpix",
3231
]
33-
UNSUPPORTED_GRID_TYPES = ["rotated_ll", "rotated_gg", "reduced_rotated_gg"]
32+
33+
UNSUPPORTED_GRID_TYPES = [
34+
"rotated_ll",
35+
"rotated_gg",
36+
"reduced_rotated_gg",
37+
"reduced_ll",
38+
]
3439

3540

3641
def _make_gridspec_list(grid_types):
@@ -82,6 +87,10 @@ def test_grib_gridspec_from_metadata_valid(metadata, ref, name):
8287
]:
8388
pytest.skip()
8489

90+
ref = ref.copy()
91+
for k in ["type", "i_scans_negatively", "j_points_consecutive", "j_scans_positively"]:
92+
ref.pop(k, None)
93+
8594
gridspec = make_legacy_gridspec(metadata)
8695
assert dict(gridspec) == ref, name
8796

@@ -116,12 +125,12 @@ def test_grib_gridspec_from_file():
116125
)
117126

118127
ref = {
119-
"type": "regular_ll",
128+
# "type": "regular_ll",
120129
"grid": [5.0, 5.0],
121130
"area": [75.0, -60.0, 10.0, 40.0],
122-
"j_points_consecutive": 0,
123-
"i_scans_negatively": 0,
124-
"j_scans_positively": 0,
131+
# "j_points_consecutive": 0,
132+
# "i_scans_negatively": 0,
133+
# "j_scans_positively": 0,
125134
}
126135
gs = ds[0].geography.grid_spec()
127136
assert isinstance(gs, dict), type(gs)

tests/xr_engine/test_xr_engine_grid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ def test_xr_engine_gridspec(allow_holes, lazy_load):
101101
r = ds.to_xarray(profile="mars", allow_holes=allow_holes, lazy_load=lazy_load)
102102

103103
gs = r["r"].earthkit.grid_spec
104-
assert gs["type"] == "reduced_gg"
104+
# assert gs["type"] == "reduced_gg"
105105
assert gs["grid"] == "O32"
106106

107107
gs = r["t"].earthkit.grid_spec
108-
assert gs["type"] == "reduced_gg"
108+
# assert gs["type"] == "reduced_gg"
109109
assert gs["grid"] == "O32"
110110

111111
gs = r.earthkit.grid_spec
112-
assert gs["type"] == "reduced_gg"
112+
# assert gs["type"] == "reduced_gg"
113113
assert gs["grid"] == "O32"

0 commit comments

Comments
 (0)