Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit c66ceec

Browse files
authored
Merge pull request #436 from openclimatefix/bug/435-open-sat-data
Bug/435 open sat data
2 parents d4d2348 + c0a691f commit c66ceec

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

nowcasting_dataset/data_sources/satellite/satellite_data_source.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import logging
33
from dataclasses import InitVar, dataclass
44
from numbers import Number
5-
from pathlib import Path
65
from typing import Iterable, Optional
76

87
import numpy as np
@@ -238,22 +237,20 @@ def open_sat_data(zarr_path: str, consolidated: bool) -> xr.DataArray:
238237
# seems to slow things down a lot if the Zarr store has more than
239238
# about a million chunks.
240239
# See https://github.com/openclimatefix/nowcasting_dataset/issues/23
241-
if Path(zarr_path).exists:
242-
# For opening a single Zarr store, we can use the simpler open_dataset
243-
dataset = xr.open_dataset(
244-
zarr_path, engine="zarr", consolidated=consolidated, mode="r", chunks=None
245-
)
246-
else:
247-
# If we are opening multiple Zarr stores (i.e. one for each month of the year) we load them
248-
# together and create a single dataset from them
249-
dataset = xr.open_mfdataset(
250-
zarr_path,
251-
chunks=None,
252-
mode="r",
253-
engine="zarr",
254-
concat_dim="time",
255-
preprocess=remove_acq_time_from_dataset,
256-
)
240+
241+
# If we are opening multiple Zarr stores (i.e. one for each month of the year) we load them
242+
# together and create a single dataset from them. open_mfdataset also works if zarr_path
243+
# points to a specific zarr directory (with no wildcards).
244+
dataset = xr.open_mfdataset(
245+
zarr_path,
246+
chunks=None,
247+
mode="r",
248+
engine="zarr",
249+
concat_dim="time",
250+
preprocess=remove_acq_time_from_dataset,
251+
consolidated=consolidated,
252+
combine="nested",
253+
)
257254

258255
data_array = dataset["stacked_eumetsat_data"]
259256
del dataset

0 commit comments

Comments
 (0)