Skip to content

Commit f0accfc

Browse files
committed
Add cftime groupby, resample benchmarks
xref pydata#7730
1 parent 2657787 commit f0accfc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

asv_bench/benchmarks/groupby.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,34 @@ def setup(self, *args, **kwargs):
132132
super().setup(**kwargs)
133133
self.ds1d = self.ds1d.chunk({"time": 50})
134134
self.ds2d = self.ds2d.chunk({"time": 50, "z": 4})
135+
136+
137+
class ResampleCFTime:
138+
def setup(self, *args, **kwargs):
139+
self.ds1d = xr.Dataset(
140+
{
141+
"b": ("time", np.arange(365.0 * 24)),
142+
},
143+
coords={
144+
"time": xr.date_range(
145+
"2001-01-01", freq="H", periods=365 * 24, calendar="noleap"
146+
)
147+
},
148+
)
149+
self.ds2d = self.ds1d.expand_dims(z=10)
150+
self.ds1d_mean = self.ds1d.resample(time="48H").mean()
151+
self.ds2d_mean = self.ds2d.resample(time="48H").mean()
152+
153+
154+
class GroupByCFTime:
155+
def setup(self, *args, **kwargs):
156+
arr = np.random.randn(10, 10, 365 * 30)
157+
time = xr.date_range("2000", periods=30 * 365, calendar="noleap")
158+
self.da = xr.DataArray(arr, dims=("y", "x", "time"), coords={"time": time})
159+
self.gb = self.da.groupby("time.year")
160+
161+
def time_init(self, ndim):
162+
self.da.groupby("time.year")
163+
164+
def time_mean(self):
165+
self.gb.mean()

0 commit comments

Comments
 (0)