Closed ocefpaf closed 7 years ago
It looks like this variable has an attribute _FillValue = -1
, which isn't a valid string value:
In [18]: ds['tidenames'].encoding
Out[18]:
{'_FillValue': -1,
'dtype': dtype('S1'),
'original_shape': (38, 64),
'source': 'http://geoport.whoi.edu/thredds/dodsC/usgs/vault0/models/tides/vdatum_gulf_of_maine/adcirc54_38_orig.nc'}
Potentially we could update xarray's CF conventions code to handle inconsistent dtypes and _FillValue
attributes, or possibly this file should be fixed instead.
A work around is to set mask_and_scale=False
:
In [19]: ds = xr.open_dataset(url, mask_and_scale=False)
In [21]: ds['tidenames']
Out[21]:
<xarray.DataArray 'tidenames' (ntides: 38)>
array([b'STEADY ', b'MN ', b'SM ', b'K1 ', b'O1 ', b'P1 ',
b'Q1 ', b'SO1 ', b'MNS2 ', b'2MS2 ', b'N2 ', b'M2 ',
b'2MN2 ', b'S2 ', b'K2 ', b'MSN2 ', b'2SM2 ', b'MO3 ',
b'SO3/MK3', b'SK3 ', b'N4 ', b'3MS4 ', b'MN4 ', b'M4 ',
b'3MN4 ', b'MS4 ', b'2MSN4 ', b'2NM6 ', b'2MN6 ', b'M6 ',
b'MSN6 ', b'2MS6 ', b'2SM6 ', b'2(MN)8 ', b'3MN8 ', b'M8 ',
b'2MSN8 ', b'3MS8 '],
dtype='|S64')
Dimensions without coordinates: ntides
Attributes:
long_name: Tide Constituent
missing_value: -1
standard_name: tide_constituent
Totally missed your answer here @shoyer. Thanks!
The workaround is fine and the _FillValue =-1
seems wrong to me. Pinging @rsignell-usgs who is know more about the conventions and was interested into this in the first place.
Closing this as I don't think anything is broken with xarray
.
Not sure if the dataset is pathological or if the problem is in
xarray
.netCDF4 1.2.4
correctly returnsdtype
S1
butxarray 0.9.6
returns'float64'
and then fails to open the dataset. (I am also having issues loading this variable withnetCDF4 >1.2.4
.)I will try to investigate this later this week.