From b3914ebdfbb318e20bde6f6ed420f9eddaee4ff3 Mon Sep 17 00:00:00 2001 From: malmans2 Date: Wed, 3 Dec 2025 16:22:00 +0100 Subject: [PATCH 1/2] do not expand coordinates' dims --- tests/test_20_open_dataset.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_20_open_dataset.py b/tests/test_20_open_dataset.py index 0fcec02..e44371d 100644 --- a/tests/test_20_open_dataset.py +++ b/tests/test_20_open_dataset.py @@ -30,6 +30,7 @@ def test_open_dataset(tmp_path: Path, index_node: str, download: bool) -> None: ) assert (esgpull_path / "data" / "CMIP6").exists() is download + # Dims assert ds.sizes == { "experiment_id": 2, "time": 24, @@ -37,6 +38,8 @@ def test_open_dataset(tmp_path: Path, index_node: str, download: bool) -> None: "lat": 256, "lon": 512, } + + # Coords assert set(ds.coords) == { "experiment_id", "height", @@ -47,7 +50,17 @@ def test_open_dataset(tmp_path: Path, index_node: str, download: bool) -> None: "time", "time_bnds", } + assert set(ds[["lat_bnds", "lon_bnds", "time_bnds"]].dims) == { + "bnds", + "lat", + "lon", + "time", + } + + # Data vars assert set(ds.data_vars) == {"tas", "pr"} + + # Attributes assert ds.dataset_ids == [ "CMIP6.ScenarioMIP.EC-Earth-Consortium.EC-Earth3-CC.ssp245.r1i1p1f1.Amon.pr.gr.v20210113", "CMIP6.ScenarioMIP.EC-Earth-Consortium.EC-Earth3-CC.ssp245.r1i1p1f1.Amon.tas.gr.v20210113", From 0b7f8759bdfe038b78ca8c6999f3ba26316695e5 Mon Sep 17 00:00:00 2001 From: malmans2 Date: Wed, 3 Dec 2025 16:25:53 +0100 Subject: [PATCH 2/2] move expand_dims --- xarray_esgf/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray_esgf/client.py b/xarray_esgf/client.py index 18d5fb3..40b9c5d 100644 --- a/xarray_esgf/client.py +++ b/xarray_esgf/client.py @@ -149,10 +149,10 @@ def open_dataset( compat="override", combine_attrs="drop_conflicts", ) - ds = ds.expand_dims({dim: [dataset_id_dict[dim]] for dim in concat_dims}) ds = ds.set_coords([ name for name, da in ds.variables.items() if "bnds" in da.dims ]) + ds = ds.expand_dims({dim: [dataset_id_dict[dim]] for dim in concat_dims}) combined_datasets[dataset_id] = ds check_dimensions(combined_datasets)