xskillscore.discrimination

xskillscore.discrimination(observations, forecasts, dim=None, probability_bin_edges=array([0., 0.2, 0.4, 0.6, 0.8, 1.]))
Returns the data required to construct the discrimination diagram for an event;

the histogram of forecasts likelihood when observations indicate an event has occurred and has not occurred.

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 histograms. 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

Returns

Array with added dimension “event” containing the histograms of forecast probabilities when the event was observed and not observed

Return type

xarray.Dataset or xarray.DataArray

Examples

>>> observations = xr.DataArray(np.random.normal(size=(30, 30)),
...                             coords=[('x', np.arange(30)),
...                                     ('y', np.arange(30))])
>>> forecasts = xr.DataArray(np.random.normal(size=(30, 30, 10)),
...                          coords=[('x', np.arange(30)),
...                                  ('y', np.arange(30)),
...                                  ('member', np.arange(10))])
>>> forecast_event_likelihood = (forecasts > 0).mean('member')
>>> observed_event = observations > 0
>>> xs.discrimination(observed_event, forecast_event_likelihood, dim=['x','y'])
<xarray.DataArray (event: 2, forecast_probability: 5)>
array([[0.00437637, 0.15536105, 0.66739606, 0.12472648, 0.04814004],
       [0.00451467, 0.16704289, 0.66365688, 0.1241535 , 0.04063205]])
Coordinates:
  * forecast_probability  (forecast_probability) float64 0.1 0.3 0.5 0.7 0.9
  * event                 (event) bool True False

References

http://www.cawcr.gov.au/projects/verification/