def month_means(month): pattern = MONTHLY_PATTERN.format(month) files = glob.glob(pattern) x = xr.open_mfdataset(files, chunks=CHUNKS or None) return x.mean(dim='time')