!pip install herbie-data --quiet
ERROR: Operation cancelled by user

# linting
%load_ext nb_black
%load_ext lab_black

Skill from ECMWF downloaded with herbie#

herbie downloads forecasts data easily. The resulting datasets is out-of-the-box compatible with climpred.

import xarray as xr
import numpy as np

import climpred  # forecast verification
from herbie import Herbie

H = Herbie(date="2022-01-27 00:00", model="ecmwf", product="enfo", fxx=24 * 1)
ds = H.xarray(":2t:")
# take the first with multiple members as forecast
init = ds[0][["t2m"]]
H = Herbie(date="2022-01-28 00:00", model="ecmwf", product="enfo", fxx=0)
ds = H.xarray(":2t:")
# take first and make ensemble member mean as observations
obs = ds[0].mean("number").drop(["step", "valid_time"]).expand_dims("time")[["t2m"]]

Forecast skill verification#

Using using HindcastEnsemble.

climpred expects init, lead and optional member as dimensions, see setting-up-your-dataset. Existing dimensions are renamed automatically if CF standard_names match.

hindcast = climpred.HindcastEnsemble(
    init.expand_dims(["time", "step"])

skill = hindcast.verify(
    metric="crps", comparison="m2o", dim=["init", "member"], alignment="same_init"