8000 [skip-ci] Add cftime groupby, resample benchmarks by dcherian · Pull Request #7795 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

[skip-ci] Add cftime groupby, resample benchmarks #7795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 2, 2023
Next Next commit
[skip-ci] Add cftime groupby, resample benchmarks
xref #7730
  • Loading branch information
dcherian committed Apr 28, 2023
commit 79695e5a2f6dcd36e4fbf490adbb624fe4eee58e
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