Skip to content

Commit a1f17c9

Browse files
restrict on steps (#297)
* restrict on steps * mypy * ignore arg type
1 parent e073496 commit a1f17c9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/nwp_consumer/internal/repositories/raw_repositories/ecmwf_realtime.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from typing import override
4040

4141
import cfgrib
42+
import numpy as np
4243
import s3fs
4344
import xarray as xr
4445
from joblib import delayed
@@ -270,14 +271,17 @@ def _convert(path: pathlib.Path) -> ResultE[list[xr.DataArray]]:
270271
num_skipped: int = 0
271272
expected_lons = ECMWFRealTimeS3RawRepository.model().expected_coordinates.longitude
272273
expected_lats = ECMWFRealTimeS3RawRepository.model().expected_coordinates.latitude
274+
expected_steps = ECMWFRealTimeS3RawRepository.model().expected_coordinates.step
273275

274276
for i, ds in enumerate(dss):
275277
# ECMWF Realtime provides all regions in one set of datasets,
276278
# so distinguish via their coordinates
279+
step = np.timedelta64(ds.coords["step"].values, "h").astype(int) # type: ignore[arg-type]
277280
is_relevant_dataset_predicate: bool = (
278281
(expected_lons is not None and expected_lats is not None)
279282
and (expected_lons[0] <= max(ds.coords["longitude"].values) <= expected_lons[-1])
280283
and (expected_lats[-1] <= max(ds.coords["latitude"].values) <= expected_lats[0])
284+
and (expected_steps[0] <= step <= expected_steps[-1])
281285
)
282286
if not is_relevant_dataset_predicate:
283287
num_skipped += 1

0 commit comments

Comments
 (0)