computing annual mean with resample(ds, freq='ann') yields incorrect results
Closed this issue · 0 comments
When I compute annual means with ds_ann = esmlab.resample(ds, freq='ann')
, I am getting incorrect results.
If I run the following python lines, using the function xr_ds_ex
in xr_ds_ex.py.txt
that generates an example xarray.Dataset object, I see that while ds.var_ex
is all ones, ds_ann.var_ex
is 1/12. If the example dataset has 2 years of monthly ones, the computed mean is 1/24. So it looks like the result is effectively being incorrectly divided by the number of samples in the input.
I am using xarray 0.12.1 and esmlab as of commit c0903ad.
import esmlab
from xr_ds_ex import xr_ds_ex
ds = xr_ds_ex(decode_times=True, nyrs=1, var_const=True)
ds_ann = esmlab.resample(ds, freq='ann')
print(ds)
print(ds_ann)
<xarray.Dataset>
Dimensions: (d2: 2, time: 12)
Coordinates:
- time (time) object 0001-01-16 12:00:00 ... 0001-12-16 12:00:00
Dimensions without coordinates: d2
Data variables:
var_ex (time) float64 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
time_bounds (time, d2) object 0001-01-01 00:00:00 ... 0002-01-01 00:00:00
<xarray.Dataset>
Dimensions: (d2: 2, time: 1)
Coordinates:- time (time) object 0001-07-01 17:00:00
Dimensions without coordinates: d2
Data variables:
var_ex (time) float64 0.08333
time_bounds (time, d2) float64 0.0 365.0
Attributes:
history: \n2019-04-09 06:46:11.072221 esmlab.resample(, freq="a...