xskillscore.core.resampling.resample_iterations_idx(forecast, iterations, dim='member', dim_max=None, replace=True)

Resample over dim by index iterations times.


This is a much faster way to bootstrap/resample each iteration individually and applying the function to it. This will create a DataArray with dimension iteration of size iterations. When using dask, the number of tasks in resample_iterations() will scale with iterations but constant chunksize, whereas the tasks in resample_iterations_idx() will stay constant with increasing chunksize.

  • forecast (xr.DataArray, xr.Dataset) – Forecast.

  • iterations (int) – Number of resampling iterations.

  • dim (str) – Dimension name to resample over. Defaults to 'member'.

  • replace (bool) – Resampling with or without replacement. Defaults to True.

  • dim_max (int) – Number of item from dim to return.


forecast_smp – data resampled along dimension dim with additional dim='iteration'.

Return type:

xr.DataArray, xr.Dataset


>>> a = xr.DataArray(
...     np.random.rand(1000, 3, 3),
...     coords=[
...         ("time", np.arange(1000)),
...         ("x", np.arange(3)),
...         ("y", np.arange(3)),
...     ],
... )
>>> xs.resample_iterations_idx(a, 500, "time")  
<xarray.DataArray (time: 1000, x: 3, y: 3, iteration: 500)>

See also



  • Mason, S. J., & Mimmack, G. M. (1992). The use of bootstrap confidence intervals for the correlation coefficient in climatology. Theoretical and Applied Climatology, 45(4), 229–233. https://doi.org/10/b6fnsv

  • Mason, S. J. (2008). Understanding forecast verification statistics. Meteorological Applications, 15(1), 31–40. https://doi.org/10/bgvgnz

  • Goddard, L., Kumar, A., Solomon, A., Smith, D., Boer, G., Gonzalez, P., Kharin, V., Merryfield, W., Deser, C., Mason, S. J., Kirtman, B. P., Msadek, R., Sutton, R., Hawkins, E., Fricker, T., Hegerl, G., Ferro, C. a. T., Stephenson, D. B., Meehl, G. A., … Delworth, T. (2013). A verification framework for interannual-to-decadal predictions experiments. Climate Dynamics, 40(1–2), 245–272. https://doi.org/10/f4jjvf