From 7568832b90154e5196af7fa05f7d7ad6a0a2371b Mon Sep 17 00:00:00 2001 From: EddyCMWF Date: Tue, 8 Oct 2024 08:53:57 +0100 Subject: [PATCH] hotfix dont overwrite chunks --- cads_adaptors/tools/convertors.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cads_adaptors/tools/convertors.py b/cads_adaptors/tools/convertors.py index b71e1482..e19bb477 100644 --- a/cads_adaptors/tools/convertors.py +++ b/cads_adaptors/tools/convertors.py @@ -18,6 +18,8 @@ } } +DEFAULT_OPEN_ENGINE = "cfgrib" + DEFAULT_CHUNKS = { "time": 12, "step": 1, @@ -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 @@ -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(