Skip to content

Cannot specify options for pynio engine through backend_kwargs of open_dataset/open_dataarray #2380

@joshcoden

Description

@joshcoden

Code Sample

frost_run = xr.open_dataarray("nam.grib2", engine="pynio", backend_kwargs={"SingleElementDimensions": "Initial_time"})
# or
import Nio
nio_options = Nio.options()
nio_options.SingleElementDimensions = "Initial_time"
frost_run = xr.open_dataarray("nam.grib2", engine="pynio", backend_kwargs={"options": nio_options})

Problem description

The problem is that there is not a way through xarray to set the PyNio specific options, and I have confirmed by taking a look at the initializer signature of NioDataStore

def __init__(self, filename, mode='r', autoclose=False):

Which does not provide a way to specify that value of the options parameter of the Nio.open_file method it uses

The only workaround is modify the global defaults for Nio prior to opening, i.e.,

import Nio
Nio.option_defaults["SingleElementDimensions"] = "Initial_time"
# open datasets now

Expected Output

Either way from the sample results in TypeError: __init__() got an unexpected keyword argument

Output of xr.show_versions()

Details INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Darwin OS-release: 17.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

xarray: 0.10.8
pandas: 0.23.4
numpy: 1.15.0
scipy: 1.1.0
netCDF4: 1.4.1
h5netcdf: 0.6.2
h5py: 2.8.0
Nio: 1.5.2
zarr: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.18.2
distributed: 1.22.1
matplotlib: 2.2.3
cartopy: 0.16.0
seaborn: 0.9.0
setuptools: 40.0.0
pip: 18.0
conda: 4.5.11
pytest: 3.7.2
IPython: 6.5.0
sphinx: 1.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions