In [1]:
import urllib.request
import Nio
import xarray as xr
In [2]:
url='http://thredds.ucar.edu/thredds/fileServer/grib/NCEP/WW3/Regional_Alaska/WW3_Regional_Alaska_20171012_0000.grib2'
fname = 'ww3_test.grib2'
In [3]:
urllib.request.urlretrieve(url, fname)
Out[3]:
('ww3_test.grib2', <http.client.HTTPMessage at 0x7f94d4cf4198>)
In [4]:
nc = Nio.open_file(fname)
In [5]:
nc.variables
Out[5]:
{'WDIR_P0_L1_GLL0': <Nio.NioVariable object at 0x7f951850fe10>, 'WIND_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94c5f6ea90>, 'UGRD_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11128>, 'VGRD_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d111d0>, 'HTSGW_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11278>, 'WVDIR_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11320>, 'WVHGT_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d113c8>, 'WVPER_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11470>, 'SWDIR_P0_L241_GLL0': <Nio.NioVariable object at 0x7f94d4d11518>, 'SWELL_P0_L241_GLL0': <Nio.NioVariable object at 0x7f94d4d115c0>, 'SWPER_P0_L241_GLL0': <Nio.NioVariable object at 0x7f94d4d11668>, 'DIRPW_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11710>, 'PERPW_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d117b8>, 'WSTP_P0_L1_GLL0': <Nio.NioVariable object at 0x7f94d4d11860>, 'lv_OSEQD0': <Nio.NioVariable object at 0x7f94d4d11908>, 'lat_0': <Nio.NioVariable object at 0x7f94d4d11940>, 'lon_0': <Nio.NioVariable object at 0x7f94d4d119b0>, 'forecast_time0': <Nio.NioVariable object at 0x7f94d4d11a20>}
In [6]:
ds = xr.open_dataset(fname, engine='pynio')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-8ba3ce7b7c40> in <module>()
----> 1 ds = xr.open_dataset(fname, engine='pynio')

/home/usgs/miniconda/envs/IOOS3/lib/python3.6/site-packages/xarray/backends/api.py in open_dataset(filename_or_obj, group, decode_cf, mask_and_scale, decode_times, autoclose, concat_characters, decode_coords, engine, chunks, lock, cache, drop_variables)
    299             lock = _default_lock(filename_or_obj, engine)
    300         with close_on_error(store):
--> 301             return maybe_decode_store(store, lock)
    302     else:
    303         if engine is not None and engine != 'scipy':

/home/usgs/miniconda/envs/IOOS3/lib/python3.6/site-packages/xarray/backends/api.py in maybe_decode_store(store, lock)
    223             store, mask_and_scale=mask_and_scale, decode_times=decode_times,
    224             concat_characters=concat_characters, decode_coords=decode_coords,
--> 225             drop_variables=drop_variables)
    226 
    227         _protect_dataset_variables_inplace(ds, cache)

/home/usgs/miniconda/envs/IOOS3/lib/python3.6/site-packages/xarray/conventions.py in decode_cf(obj, concat_characters, mask_and_scale, decode_times, decode_coords, drop_variables)
    944         encoding = obj.encoding
    945     elif isinstance(obj, AbstractDataStore):
--> 946         vars, attrs = obj.load()
    947         extra_coords = set()
    948         file_obj = obj

/home/usgs/miniconda/envs/IOOS3/lib/python3.6/site-packages/xarray/backends/common.py in load(self)
    120         """
    121         variables = FrozenOrderedDict((_decode_variable_name(k), v)
--> 122                                       for k, v in self.get_variables().items())
    123         attributes = FrozenOrderedDict(self.get_attrs())
    124         return variables, attributes

/home/usgs/miniconda/envs/IOOS3/lib/python3.6/site-packages/xarray/backends/pynio_.py in get_variables(self)
     55         with self.ensure_open(autoclose=False):
     56             return FrozenOrderedDict((k, self.open_store_variable(k, v))
---> 57                                      for k, v in self.ds.variables.iteritems())
     58 
     59     def get_attrs(self):

AttributeError: 'nioDict' object has no attribute 'iteritems'