Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Time decoding/encoding functionality not working #128

Open
andersy005 opened this issue May 6, 2019 · 0 comments
Open

Time decoding/encoding functionality not working #128

andersy005 opened this issue May 6, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@andersy005
Copy link
Contributor

andersy005 commented May 6, 2019

It appears that #122 may have broken other functionality. For example, when a dataset has decoded time values, resample fails:

cam_chem
<xarray.Dataset>
Dimensions:       (ilev: 33, lev: 32, nbnd: 2, ncol: 48602, time: 12)
Coordinates:
  * lev           (lev) float64 3.643 7.595 14.36 24.61 ... 957.5 976.3 992.6
  * ilev          (ilev) float64 2.255 5.032 10.16 18.56 ... 967.5 985.1 1e+03
  * time          (time) object 2013-02-01 00:00:00 ... 2014-01-01 00:00:00

esmlab.resample(cam_chem, freq='ann')
Please open dataset with `decode_times=False`
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-7c31f1f5dede> in <module>
----> 1 esmlab.resample(cam_chem, freq='ann')

/glade/work/abanihi/softwares/miniconda3/envs/analysis/lib/python3.7/site-packages/esmlab/core.py in resample(dset, freq, weights, time_coord_name)
    760 
    761     else:
--> 762         ds = dset.esmlab.set_time(time_coord_name=time_coord_name).compute_ann_mean(weights=weights)
    763 
    764     new_history = f'\n{datetime.now()} esmlab.resample(<DATASET>, freq="{freq}")'

/glade/work/abanihi/softwares/miniconda3/envs/analysis/lib/python3.7/site-packages/esmlab/core.py in set_time(self, time_coord_name, year_offset)
    345                 except Exception as exc:
    346                     print('Please open dataset with `decode_times=False`')
--> 347                     raise exc
    348         self.setup()
    349         return self

/glade/work/abanihi/softwares/miniconda3/envs/analysis/lib/python3.7/site-packages/esmlab/core.py in set_time(self, time_coord_name, year_offset)
    340                         self._ds[self.tb_name],
    341                         units=self.time_attrs['units'],
--> 342                         calendar=self.time_attrs['calendar'],
    343                     )
    344                     self.time_bound.data = tb_data

cftime/_cftime.pyx in cftime._cftime.date2num()

cftime/_cftime.pyx in cftime._cftime._dateparse()

cftime/_cftime.pyx in cftime._cftime._datesplit()

AttributeError: 'NoneType' object has no attribute 'split'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant