Open
Description
Following commit c5a68ca, units are now read from the cf metadata of the NetCDF file. This now causes a ValueError when opening netcdf files with monthly mean data. When constructing the StandardTime
axis, units=months is not a valid option. The code fails when checking whether units has a unitfactor.
Note that the cf metadata conventions advise caution when using month as a unit. Should .open
do something clever with months?
~/.local/lib/python3.6/site-packages/pygeode-1.4.0-py3.6-linux-x86_64.egg/pygeode/formats/__init__.py in open(filename, format, value_override, dimtypes, namemap, varlist, cfmeta, **kwargs)
160
161 return format.open(filename, value_override=value_override, dimtypes=dimtypes, \
--> 162 namemap=namemap, varlist=varlist, cfmeta=cfmeta, **kwargs)
163 # }}}
164
~/.local/lib/python3.6/site-packages/pygeode-1.4.0-py3.6-linux-x86_64.egg/pygeode/formats/netcdf4.py in open(filename, value_override, dimtypes, namemap, varlist, cfmeta)
255 # with the same name as the dimension)
256 dataset = dims2axes(dataset)
--> 257 return finalize_open(dataset, dimtypes, namemap, varlist, cfmeta)
258 except IOError: # Problem accessing the file?
259 raise
~/.local/lib/python3.6/site-packages/pygeode-1.4.0-py3.6-linux-x86_64.egg/pygeode/formats/__init__.py in finalize_open(dataset, dimtypes, namemap, varlist, cfmeta)
264 # Skip anything that we're going to override in dimtypes
265 # (so we don't get any meaningless warnings or other crap from cfmeta)
--> 266 dataset = cf.decode_cf(dataset, ignore=list(dimtypes.keys()))
267
268 # Apply custom axis types?
~/.local/lib/python3.6/site-packages/pygeode-1.4.0-py3.6-linux-x86_64.egg/pygeode/formats/cfmeta.py in decode_cf(***failed resolving arguments***)
410 # Create the time axis
411 startdate={'year':year, 'month':month, 'day':day, 'hour':hour, 'minute':minute, 'second':second}
--> 412 axisdict[name] = cls(a.values, startdate=startdate, units=res, name=name, atts=atts)
413 # Special case: start year=0 implies a climatology
414 #NOTE: 'climatology' attribute not used, since we don't currently keep
~/.local/lib/python3.6/site-packages/pygeode-1.4.0-py3.6-linux-x86_64.egg/pygeode/timeaxis.py in __init__(self, values, datefmt, units, startdate, **kwargs)
416
417 if units not in self.unitfactor.keys():
--> 418 raise ValueError('units ("%s") must be one of the following: %s' % (units, list(self.unitfactor.keys())))
419
420 return Time.__init__(self, values=values, units=units, startdate=startdate, **kwargs)
ValueError: units ("months") must be one of the following: ['seconds', 'minutes', 'hours', 'days']
Metadata
Metadata
Assignees
Labels
No labels