Comments (5)
One of the variables in ds2
is cftime (probably the bounds variable). It'll work if you call .load()
on that variable.
from esmlab.
Changing the end of the call sequence to
ds2['time_bound'].load() # New call per comment above
ds2_ann = esmlab.resample(ds2, freq='ann')
gives a new error:
TypeError: unsupported operand type(s) for *: 'cftime._cftime.DatetimeNoLeap' and 'float'
Full traceback is
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-f0ede6cb0845> in <module>
1 ds2['time_bound'].load()
----> 2 ds2_ann = esmlab.resample(ds2, freq='ann')
3 ds2_ann
/glade/work/mlevy/codes/esmlab/esmlab/core.py in resample(dset, freq, weights, time_coord_name, method)
778 else:
779 ds = dset.esmlab.set_time(time_coord_name=time_coord_name).compute_ann_mean(
--> 780 weights=weights, method=method
781 )
782
/glade/work/mlevy/miniconda3/envs/cesm2-marbl/lib/python3.7/contextlib.py in inner(*args, **kwds)
72 def inner(*args, **kwds):
73 with self._recreate_cm():
---> 74 return func(*args, **kwds)
75 return inner
76
/glade/work/mlevy/codes/esmlab/esmlab/core.py in compute_ann_mean(self, weights, method)
554 return da_weighted_mean.where(mask)
555
--> 556 computed_dset = dset.apply(weighted_mean_arr, wgts=wgts)
557
558 computed_dset = self.compute_resample_times(
/glade/work/mlevy/miniconda3/envs/cesm2-marbl/lib/python3.7/site-packages/xarray/core/dataset.py in apply(self, func, keep_attrs, args, **kwargs)
4138 variables = {
4139 k: maybe_wrap_array(v, func(v, *args, **kwargs))
-> 4140 for k, v in self.data_vars.items()
4141 }
4142 if keep_attrs is None:
/glade/work/mlevy/miniconda3/envs/cesm2-marbl/lib/python3.7/site-packages/xarray/core/dataset.py in <dictcomp>(.0)
4138 variables = {
4139 k: maybe_wrap_array(v, func(v, *args, **kwargs))
-> 4140 for k, v in self.data_vars.items()
4141 }
4142 if keep_attrs is None:
/glade/work/mlevy/codes/esmlab/esmlab/core.py in weighted_mean_arr(darr, wgts)
545 )
546 da_sum = (
--> 547 (darr * wgts).resample({self.time_coord_name: 'A'}).sum(dim=self.time_coord_name)
548 )
549 ones_out = (
/glade/work/mlevy/miniconda3/envs/cesm2-marbl/lib/python3.7/site-packages/xarray/core/dataarray.py in func(self, other)
2507 variable = (
2508 f(self.variable, other_variable)
-> 2509 if not reflexive
2510 else f(other_variable, self.variable)
2511 )
/glade/work/mlevy/miniconda3/envs/cesm2-marbl/lib/python3.7/site-packages/xarray/core/variable.py in func(self, other)
1904 new_data = (
1905 f(self_data, other_data)
-> 1906 if not reflexive
1907 else f(other_data, self_data)
1908 )
TypeError: unsupported operand type(s) for *: 'cftime._cftime.DatetimeNoLeap' and 'float'
from esmlab.
The .load()
call needs to be done internally (in esmlab). I don't remember the exact location in the source code, but a while ago, @dcherian showed @matt-long and I how to address this issue.
from esmlab.
@mnlevy1981, I got the unsupported operand...
error from a mistake in PR #156.
Please check if PR #158 helps you out.
from esmlab.
Thanks @klindsay28, the branch in #158 did the trick! I didn't see any tickets for the NotImplementedError
but didn't think to search the issues again after the error changed to TypeError: unsupported operand type(s)
.
Closing this issue because it seems like it will be resolved in an existing PR.
from esmlab.
Related Issues (20)
- Climatology is broken HOT 1
- more general resample utility HOT 1
- Remove the old benchmarks notebooks
- Least squares polynomial fit with Dask HOT 4
- Potential GroupBy() bottleneck
- Failing tests in tests/test_core.py
- Esmlab Design Document HOT 8
- sel_time with optional methods HOT 1
- cannot compute annual mean with xarray 0.14.0 HOT 4
- add upstream master test env HOT 2
- Fix Tests
- indexes related error from xarray v0.14.0 when calling esmlab.resample(ds, freq='ann') HOT 7
- Move general functionality upstream HOT 9
- esmlab operations clobber existing ds.attrs['history'] values
- esmlab.climatology does not propagate all coordinate variables
- esmlab.anomaly generating error, unrealistically large time values HOT 5
- esmlab.resample reverses order of dimensions in time bounds variable
- Move weighted reductions to xarray
- esmlab.resample() error with xarray 0.15.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esmlab.