Skip to content

Commit

Permalink
hotfix dont overwrite chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyCMWF committed Oct 8, 2024
1 parent 2be0178 commit 7568832
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cads_adaptors/tools/convertors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
}
}

DEFAULT_OPEN_ENGINE = "cfgrib"

DEFAULT_CHUNKS = {
"time": 12,
"step": 1,
Expand Down Expand Up @@ -577,6 +579,10 @@ def prepare_open_datasets_kwargs_grib(
out_open_datasets_kwargs: list[dict[str, Any]] = []
for open_ds_kwargs in ensure_list(open_datasets_kwargs):
open_ds_kwargs.update(kwargs)
# Ensure chunks and engine are set
open_ds_kwargs.setdefault("chunks", DEFAULT_CHUNKS)
open_ds_kwargs.setdefault("engine", DEFAULT_OPEN_ENGINE)

split_on_keys: list[str] | None = open_ds_kwargs.pop("split_on", None)
split_on_keys_alias: dict[str, str] | None = open_ds_kwargs.pop(
"split_on_alias", None
Expand Down Expand Up @@ -661,10 +667,6 @@ def open_grib_file_as_xarray_dictionary(
if open_datasets_kwargs is None:
open_datasets_kwargs = {}

# Ensure chunks and engine are set
kwargs.setdefault("chunks", DEFAULT_CHUNKS)
kwargs.setdefault("engine", "cfgrib")

# Do any automatic splitting of the open_datasets_kwargs,
# This will add kwargs to the open_datasets_kwargs
open_datasets_kwargs = prepare_open_datasets_kwargs_grib(
Expand Down

0 comments on commit 7568832

Please sign in to comment.