Skip to content

Commit 24cfdd2

Browse files
Add new h5netcdf backend phony_dims kwarg (#3753)
* ADD: add `phony_dims` keyword arg to h5netcdf backend available from h5netcdf v0.8.0 * ADD: add `whats-new.rst` entry * FIX: raise ValueError Co-authored-by: Deepak Cherian <[email protected]>
1 parent 66625c9 commit 24cfdd2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

doc/whats-new.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ Breaking changes
2424

2525
New Features
2626
~~~~~~~~~~~~
27+
28+
- Support new h5netcdf backend keyword `phony_dims` (available from h5netcdf
29+
v0.8.0 for :py:class:`~xarray.backends.H5NetCDFStore`.
30+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
2731
- implement pint support. (:issue:`3594`, :pull:`3706`)
2832
By `Justus Magin <https://github.com/keewis>`_.
2933

34+
3035
Bug fixes
3136
~~~~~~~~~
3237
- Use ``dask_array_type`` instead of ``dask_array.Array`` for type

xarray/backends/h5netcdf_.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import functools
2+
from distutils.version import LooseVersion
23

34
import numpy as np
45

@@ -117,13 +118,22 @@ def open(
117118
lock=None,
118119
autoclose=False,
119120
invalid_netcdf=None,
121+
phony_dims=None,
120122
):
121123
import h5netcdf
122124

123125
if format not in [None, "NETCDF4"]:
124126
raise ValueError("invalid format for h5netcdf backend")
125127

126128
kwargs = {"invalid_netcdf": invalid_netcdf}
129+
if phony_dims is not None:
130+
if LooseVersion(h5netcdf.__version__) >= LooseVersion("0.8.0"):
131+
kwargs["phony_dims"] = phony_dims
132+
else:
133+
raise ValueError(
134+
"h5netcdf backend keyword argument 'phony_dims' needs "
135+
"h5netcdf >= 0.8.0."
136+
)
127137

128138
if lock is None:
129139
if mode == "r":

0 commit comments

Comments
 (0)