From 1eed4875480edb3848ef38bad03f2ac2b7f2ff50 Mon Sep 17 00:00:00 2001 From: aladinor Date: Tue, 3 Sep 2024 17:48:00 -0500 Subject: [PATCH 1/5] passing missing arguments to when opening hdf5 datatrees --- xarray/backends/h5netcdf_.py | 21 +++++++++++++++++++-- xarray/backends/netCDF4_.py | 19 ++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py index 0b7ebbbeb0c..6f0176f57e2 100644 --- a/xarray/backends/h5netcdf_.py +++ b/xarray/backends/h5netcdf_.py @@ -450,8 +450,25 @@ def open_datatree( ) -> DataTree: from xarray.core.datatree import DataTree - - groups_dict = self.open_groups_as_dict(filename_or_obj, **kwargs) + groups_dict = self.open_groups_as_dict( + filename_or_obj, + mask_and_scale=mask_and_scale, + decode_times=decode_times, + concat_characters=concat_characters, + decode_coords=decode_coords, + drop_variables=drop_variables, + use_cftime=use_cftime, + decode_timedelta=decode_timedelta, + format=format, + group=group, + lock=lock, + invalid_netcdf=invalid_netcdf, + phony_dims=phony_dims, + decode_vlen_strings=decode_vlen_strings, + driver=driver, + driver_kwds=driver_kwds, + **kwargs + ) return DataTree.from_dict(groups_dict) diff --git a/xarray/backends/netCDF4_.py b/xarray/backends/netCDF4_.py index ec2fe25216a..4b338d1fbca 100644 --- a/xarray/backends/netCDF4_.py +++ b/xarray/backends/netCDF4_.py @@ -691,7 +691,24 @@ def open_datatree( from xarray.core.datatree import DataTree - groups_dict = self.open_groups_as_dict(filename_or_obj, **kwargs) + groups_dict = self.open_groups_as_dict( + filename_or_obj, + mask_and_scale=mask_and_scale, + decode_times=decode_times, + concat_characters=concat_characters, + decode_coords=decode_coords, + drop_variables=drop_variables, + use_cftime=use_cftime, + decode_timedelta=decode_timedelta, + group=group, + format=format, + clobber=clobber, + diskless=diskless, + persist=persist, + lock=lock, + autoclose=autoclose, + **kwargs + ) return DataTree.from_dict(groups_dict) From 956c82011c9715f00e2b44765f3836c0553c616b Mon Sep 17 00:00:00 2001 From: aladinor Date: Tue, 3 Sep 2024 17:48:12 -0500 Subject: [PATCH 2/5] passing missing arguments to when opening netcdf4 datatrees --- xarray/backends/netCDF4_.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/backends/netCDF4_.py b/xarray/backends/netCDF4_.py index 4b338d1fbca..a641b593ab6 100644 --- a/xarray/backends/netCDF4_.py +++ b/xarray/backends/netCDF4_.py @@ -690,7 +690,6 @@ def open_datatree( ) -> DataTree: from xarray.core.datatree import DataTree - groups_dict = self.open_groups_as_dict( filename_or_obj, mask_and_scale=mask_and_scale, From 75258798112da4758bef521573ab6b8bf73c3676 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:52:43 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/backends/h5netcdf_.py | 3 ++- xarray/backends/netCDF4_.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py index 6f0176f57e2..6facc1d713f 100644 --- a/xarray/backends/h5netcdf_.py +++ b/xarray/backends/h5netcdf_.py @@ -450,6 +450,7 @@ def open_datatree( ) -> DataTree: from xarray.core.datatree import DataTree + groups_dict = self.open_groups_as_dict( filename_or_obj, mask_and_scale=mask_and_scale, @@ -467,7 +468,7 @@ def open_datatree( decode_vlen_strings=decode_vlen_strings, driver=driver, driver_kwds=driver_kwds, - **kwargs + **kwargs, ) return DataTree.from_dict(groups_dict) diff --git a/xarray/backends/netCDF4_.py b/xarray/backends/netCDF4_.py index a641b593ab6..d2e438de2c0 100644 --- a/xarray/backends/netCDF4_.py +++ b/xarray/backends/netCDF4_.py @@ -690,6 +690,7 @@ def open_datatree( ) -> DataTree: from xarray.core.datatree import DataTree + groups_dict = self.open_groups_as_dict( filename_or_obj, mask_and_scale=mask_and_scale, @@ -706,7 +707,7 @@ def open_datatree( persist=persist, lock=lock, autoclose=autoclose, - **kwargs + **kwargs, ) return DataTree.from_dict(groups_dict) From a8d280cefed1900565bd8dfcf9770d46c387ed43 Mon Sep 17 00:00:00 2001 From: aladinor Date: Tue, 3 Sep 2024 19:34:27 -0500 Subject: [PATCH 4/5] changes documented in 'whats-new.rst file' --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 712ad68aeb3..0648bacf1ee 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -60,6 +60,8 @@ Bug fixes - Fix deprecation warning that was raised when calling ``np.array`` on an ``xr.DataArray`` in NumPy 2.0 (:issue:`9312`, :pull:`9393`) By `Andrew Scherer `_. +- Fix passing missing arguments to when opening hdf5 and necdf4 datatrees + (:issue:`9427`, :pull: `9428`) Documentation ~~~~~~~~~~~~~ From bf426f3627ae71fa242c9ff9eb625172a0d57cef Mon Sep 17 00:00:00 2001 From: aladinor Date: Tue, 1 Oct 2024 10:16:09 -0500 Subject: [PATCH 5/5] passing missing arguments to open_groups_as_dict when opening zarr datatrees --- xarray/backends/zarr.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xarray/backends/zarr.py b/xarray/backends/zarr.py index c048ea63419..a822bbc02d3 100644 --- a/xarray/backends/zarr.py +++ b/xarray/backends/zarr.py @@ -1297,7 +1297,25 @@ def open_datatree( from xarray.core.datatree import DataTree filename_or_obj = _normalize_path(filename_or_obj) - groups_dict = self.open_groups_as_dict(filename_or_obj, **kwargs) + groups_dict = self.open_groups_as_dict( + filename_or_obj=filename_or_obj, + mask_and_scale=mask_and_scale, + decode_times=decode_times, + concat_characters=concat_characters, + decode_coords=decode_coords, + drop_variables=drop_variables, + use_cftime=use_cftime, + decode_timedelta=decode_timedelta, + group=group, + mode=mode, + synchronizer=synchronizer, + consolidated=consolidated, + chunk_store=chunk_store, + storage_options=storage_options, + stacklevel=stacklevel, + zarr_version=zarr_version, + **kwargs, + ) return DataTree.from_dict(groups_dict)