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

Commit ad6bbd1

Browse files
authored
Load NetCDF files for live Satellite service (#649)
* Load NetCDF files * Fix PosixPath issue
1 parent 374ab47 commit ad6bbd1

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

nowcasting_dataset/data_sources/satellite/satellite_data_source.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,21 @@ def open_sat_data(
411411

412412
# add logger to preprocess function
413413
p_dedupe_time_coords = partial(dedupe_time_coords, logger=logger)
414-
415-
# Open datasets.
416-
dataset = xr.open_mfdataset(
417-
zarr_path,
418-
chunks="auto", # See issue #456 for why we use "auto".
419-
mode="r",
420-
engine="zarr",
421-
concat_dim="time",
422-
preprocess=p_dedupe_time_coords,
423-
consolidated=consolidated,
424-
combine="nested",
425-
)
414+
if str(zarr_path).split(".")[-1] == "nc":
415+
dataset = xr.load_dataset(str(zarr_path), engine="h5netcdf")
416+
417+
else:
418+
# Open datasets.
419+
dataset = xr.open_mfdataset(
420+
zarr_path,
421+
chunks="auto", # See issue #456 for why we use "auto".
422+
mode="r",
423+
engine="zarr",
424+
concat_dim="time",
425+
preprocess=p_dedupe_time_coords,
426+
consolidated=consolidated,
427+
combine="nested",
428+
)
426429

427430
# Rename
428431
# These renamings will no longer be necessary when the Zarr uses the 'correct' names,

0 commit comments

Comments
 (0)