xskillscore.reliability
- xskillscore.reliability(observations, forecasts, dim=None, probability_bin_edges=array([0., 0.2, 0.4, 0.6, 0.8, 1.]), keep_attrs=False)
- Returns the data required to construct the reliability diagram for an event;
the relative frequencies of occurrence of an event for a range of forecast probability bins
- Parameters
observations (xarray.Dataset or xarray.DataArray) – The observations or set of observations of the event. Data should be boolean or logical (True or 1 for event occurance, False or 0 for non-occurance).
forecasts (xarray.Dataset or xarray.DataArray) – The forecast likelihoods of the event. Data should be between 0 and 1.
dim (str or list of str, optional) – Dimension(s) over which to compute the histograms Defaults to None meaning compute over all dimensions.
probability_bin_edges (array_like, optional) – Probability bin edges used to compute the reliability. Similar to np.histogram, all but the last (righthand-most) bin include the left edge and exclude the right edge. The last bin includes both edges. Defaults to 6 equally spaced edges between 0 and 1
keep_attrs (bool, optional) – If True, the attributes (attrs) will be copied from the first input to the new one. If False (default), the new object will be returned without attributes.
- Returns
The relative frequency of occurrence for each probability bin
- Return type
Examples
>>> forecasts = xr.DataArray(np.random.normal(size=(3,3,3)), ... coords=[('x', np.arange(3)), ... ('y', np.arange(3)), ... ('member', np.arange(3))]) >>> observations = xr.DataArray(np.random.normal(size=(3,3)), ... coords=[('x', np.arange(3)), ... ('y', np.arange(3))]) >>> xs.reliability(observations > 0.1, ... (forecasts > 0.1).mean('member'), ... dim='x') <xarray.DataArray (y: 3, forecast_probability: 5)> array([[nan, 0. , nan, 1. , nan], [1. , 0.5, nan, nan, nan], [nan, 0. , nan, 0. , nan]]) Coordinates: * y (y) int64 0 1 2 * forecast_probability (forecast_probability) float64 0.1 0.3 0.5 0.7 0.9 samples (y, forecast_probability) float64 0.0 2.0 ... 1.0 0.0
Notes