|
2 | 2 | import logging |
3 | 3 | from dataclasses import InitVar, dataclass |
4 | 4 | from numbers import Number |
5 | | -from pathlib import Path |
6 | 5 | from typing import Iterable, Optional |
7 | 6 |
|
8 | 7 | import numpy as np |
@@ -238,22 +237,20 @@ def open_sat_data(zarr_path: str, consolidated: bool) -> xr.DataArray: |
238 | 237 | # seems to slow things down a lot if the Zarr store has more than |
239 | 238 | # about a million chunks. |
240 | 239 | # 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 | + ) |
257 | 254 |
|
258 | 255 | data_array = dataset["stacked_eumetsat_data"] |
259 | 256 | del dataset |
|
0 commit comments