Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix dont overwrite chunks #226

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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