climpred.metrics._rps¶
- climpred.metrics._rps(forecast, verif, dim=None, **metric_kwargs)[source]¶
Ranked Probability Score.
- Parameters
Note
If
category_edges
is xr.Dataset or tuple of xr.Datasets, climpred will broadcast the grouped dimensionsseason
,month
,weekofyear
,dayfofyear
onto the dimensionsinit
for forecast andtime
for observations. seeclimpred.utils.broadcast_time_grouped_to_time
.- Details:
minimum
0.0
maximum
∞
perfect
0.0
orientation
negative
See also
Example
>>> category_edges = np.array([-.5, 0., .5, 1.]) >>> HindcastEnsemble.verify(metric='rps', comparison='m2o', dim=['member', 'init'], ... alignment='same_verifs', category_edges=category_edges) <xarray.Dataset> Dimensions: (lead: 10) Coordinates: * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 observations_category_edge <U67 '[-np.inf, -0.5), [-0.5, 0.0), [0.0, 0.5... forecasts_category_edge <U67 '[-np.inf, -0.5), [-0.5, 0.0), [0.0, 0.5... skill <U11 'initialized' Data variables: SST (lead) float64 0.115 0.1123 ... 0.1687 0.1875
Provide category_edges as xr.Dataset for category_edges varying along dimensions.
>>> category_edges = xr.DataArray([9.5, 10., 10.5, 11.], dims='category_edge').assign_coords(category_edge=[9.5, 10., 10.5, 11.]).to_dataset(name='tos') >>> # category_edges = np.array([9.5, 10., 10.5, 11.]) # identical >>> PerfectModelEnsemble.verify(metric='rps', comparison='m2c', ... dim=['member','init'], category_edges=category_edges) <xarray.Dataset> Dimensions: (lead: 20) Coordinates: * lead (lead) int64 1 2 3 4 5 6 7 ... 15 16 17 18 19 20 observations_category_edge <U71 '[-np.inf, 9.5), [9.5, 10.0), [10.0, 10.... forecasts_category_edge <U71 '[-np.inf, 9.5), [9.5, 10.0), [10.0, 10.... Data variables: tos (lead) float64 0.08951 0.1615 ... 0.1399 0.2274
Provide category_edges as tuple for different category_edges to categorize forecasts and observations.
>>> q = [1 / 3, 2 / 3] >>> forecast_edges = HindcastEnsemble.get_initialized().groupby('init.month').quantile(q=q, dim=['init','member']).rename({'quantile':'category_edge'}) >>> obs_edges = HindcastEnsemble.get_observations().groupby('time.month').quantile(q=q, dim='time').rename({'quantile':'category_edge'}) >>> category_edges = (obs_edges, forecast_edges) >>> HindcastEnsemble.verify(metric='rps', comparison='m2o', ... dim=['member', 'init'], alignment='same_verifs', ... category_edges=category_edges) <xarray.Dataset> Dimensions: (lead: 10) Coordinates: * lead (lead) int32 1 2 3 4 5 6 7 8 9 10 observations_category_edge <U101 '[-np.inf, 0.3333333333333333), [0.3333... forecasts_category_edge <U101 '[-np.inf, 0.3333333333333333), [0.3333... skill <U11 'initialized' Data variables: SST (lead) float64 0.1248 0.1756 ... 0.3081 0.3413