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

esmlab.resample fails when method chaining is used #136

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

esmlab.resample fails when method chaining is used #136

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

Comments

@andersy005
Copy link
Contributor

esmlab.resample(esmlab.resample(dset(), freq='mon'), freq='mon')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-48-fef802d43a24> in <module>
----> 1 esmlab.resample(esmlab.resample(dset(), freq='mon'), freq='mon')

/gpfs/u/home/mclong/codes/esmlab/esmlab/core.py in resample(dset, freq, weights, time_coord_name, method)
    774 
    775     if freq == 'mon':
--> 776         ds = dset.esmlab.set_time(time_coord_name=time_coord_name).compute_mon_mean(method=method)
    777 
    778     else:

/gpfs/u/home/mclong/codes/esmlab/esmlab/core.py in set_time(self, time_coord_name, year_offset)
    346                     print('Please open dataset with `decode_times=False`')
    347                     raise exc
--> 348         self.setup()
    349         return self
    350 

/gpfs/u/home/mclong/codes/esmlab/esmlab/core.py in setup(self)
    351     def setup(self):
    352         self.get_variables()
--> 353         self.compute_time()
    354         self.get_original_metadata()
    355 

/gpfs/u/home/mclong/codes/esmlab/esmlab/core.py in compute_time(self)
     80 
     81         if self.time_bound is not None:
---> 82             groupby_coord = self.get_time_decoded(midpoint=True)
     83 
     84         else:

/gpfs/u/home/mclong/codes/esmlab/esmlab/core.py in get_time_decoded(self, midpoint)
    184                 units=self.time_attrs['units'],
    185                 calendar=self.time_attrs['calendar'],
--> 186                 only_use_cftime_datetimes=True,
    187             )
    188         )

/glade/work/mclong/miniconda3/envs/dev/lib/python3.7/site-packages/xarray/core/common.py in __setattr__(self, name, value)
    191                     "style assignment (e.g., `ds['name'] = ...`) instead to "
    192                     "assign variables." % (name, type(self).__name__))
--> 193         object.__setattr__(self, name, value)
    194 
    195     def __dir__(self):

/glade/work/mclong/miniconda3/envs/dev/lib/python3.7/site-packages/xarray/core/dataarray.py in data(self, value)
    403     @data.setter
    404     def data(self, value):
--> 405         self.variable.data = value
    406 
    407     @property

/glade/work/mclong/miniconda3/envs/dev/lib/python3.7/site-packages/xarray/core/variable.py in data(self, data)
   1832     @Variable.data.setter  # type: ignore
   1833     def data(self, data):
-> 1834         Variable.data.fset(self, data)
   1835         if not isinstance(self._data, PandasIndexAdapter):
   1836             self._data = PandasIndexAdapter(self._data)

/glade/work/mclong/miniconda3/envs/dev/lib/python3.7/site-packages/xarray/core/variable.py in data(self, data)
    302         if data.shape != self.shape:
    303             raise ValueError(
--> 304                 "replacement data must match the Variable's shape")
    305         self._data = data
    306 

ValueError: replacement data must match the Variable's shape
@andersy005 andersy005 added bug Something isn't working and removed bug labels Jul 31, 2019
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