Skip to content
forked from pydata/xarray

Commit

Permalink
Add cftime groupby, resample benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Apr 28, 2023
1 parent 2657787 commit f0accfc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions asv_bench/benchmarks/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,34 @@ def setup(self, *args, **kwargs):
super().setup(**kwargs)
self.ds1d = self.ds1d.chunk({"time": 50})
self.ds2d = self.ds2d.chunk({"time": 50, "z": 4})


class ResampleCFTime:
def setup(self, *args, **kwargs):
self.ds1d = xr.Dataset(
{
"b": ("time", np.arange(365.0 * 24)),
},
coords={
"time": xr.date_range(
"2001-01-01", freq="H", periods=365 * 24, calendar="noleap"
)
},
)
self.ds2d = self.ds1d.expand_dims(z=10)
self.ds1d_mean = self.ds1d.resample(time="48H").mean()
self.ds2d_mean = self.ds2d.resample(time="48H").mean()


class GroupByCFTime:
def setup(self, *args, **kwargs):
arr = np.random.randn(10, 10, 365 * 30)
time = xr.date_range("2000", periods=30 * 365, calendar="noleap")
self.da = xr.DataArray(arr, dims=("y", "x", "time"), coords={"time": time})
self.gb = self.da.groupby("time.year")

def time_init(self, ndim):
self.da.groupby("time.year")

def time_mean(self):
self.gb.mean()

0 comments on commit f0accfc

Please sign in to comment.