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

Add new h5netcdf backend phony_dims kwarg #3753

Merged
merged 4 commits into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Breaking changes

New Features
~~~~~~~~~~~~
- Support new h5netcdf backend keyword `phony_dims` (available from h5netcdf
v0.8.0 for :py:class:`~xarray.backends.H5NetCDFStore`.
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.

Bug fixes
~~~~~~~~~
Expand Down
10 changes: 10 additions & 0 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
from distutils.version import LooseVersion

import numpy as np

Expand Down Expand Up @@ -117,13 +118,22 @@ def open(
lock=None,
autoclose=False,
invalid_netcdf=None,
phony_dims=None,
):
import h5netcdf

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

kwargs = {"invalid_netcdf": invalid_netcdf}
if phony_dims is not None:
if LooseVersion(h5netcdf.__version__) >= LooseVersion("0.8.0"):
kwargs["phony_dims"] = phony_dims
else:
raise (
kmuehlbauer marked this conversation as resolved.
Show resolved Hide resolved
"h5netcdf backend keyword argument 'phony_dims' needs "
"h5netcdf >= 0.8.0."
)

if lock is None:
if mode == "r":
Expand Down