!pip install herbie-data --quiet
^C
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:")
ds
# 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:")
ds
# 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"])
).add_observations(obs)
hindcast
skill = hindcast.verify(
metric="crps", comparison="m2o", dim=["init", "member"], alignment="same_init"
)
skill.t2m.plot(robust=True)