xskillscore.Contingency

class xskillscore.Contingency(observations, forecasts, observation_category_edges, forecast_category_edges, dim)

Class for contingency based skill scores

Parameters
  • observations (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • forecasts (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • observation_category_edges (array_like) – Bin edges for categorising observations. Bins include the left most edge, but not the right.

  • forecast_category_edges (array_like) – Bin edges for categorising forecasts. Bins include the left most edge, but not the right.

  • dim (str, list) – The dimension(s) over which to compute the contingency table

Returns

Return type

xskillscore.Contingency

Examples

>>> a = xr.DataArray(np.random.normal(size=(3,3)),
...                  coords=[('x', np.arange(3)), ('y', np.arange(3))]).to_dataset(name='test1')
>>> b = xr.DataArray(np.random.normal(size=(3,3)),
...                  coords=[('x', np.arange(3)), ('y', np.arange(3))]).to_dataset(name='test1')
>>> a['test2'] = xr.DataArray(np.random.normal(size=(3,3)),
...                           coords=[('x', np.arange(3)), ('y', np.arange(3))])
>>> b['test2'] = xr.DataArray(np.random.normal(size=(3,3)),
...                           coords=[('x', np.arange(3)), ('y', np.arange(3))])
>>> category_edges_a = np.linspace(-2,2,5)
>>> category_edges_b = np.linspace(-3,3,5)
>>> Contingency(a, b, category_edges_a, category_edges_b, dim=['x','y'])
<xskillscore.Contingency>
Dimensions:                       (forecasts_category: 4, observations_category: 4)
Coordinates:
    observations_category_bounds  (observations_category) <U12 '(-2.0, -1.0]'...
    forecasts_category_bounds     (forecasts_category) <U12 '(-3.0, -1.5]' .....
  * observations_category         (observations_category) int64 1 2 3 4
  * forecasts_category            (forecasts_category) int64 1 2 3 4
Data variables:
    test2                         (observations_category, forecasts_category) int64 ...
    test1                         (observations_category, forecasts_category) int64 ...

References

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

__init__(observations, forecasts, observation_category_edges, forecast_category_edges, dim)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(observations, forecasts, …)

Initialize self.

accuracy()

Returns the accuracy score(s) for a contingency table with K categories

bias_score([yes_category])

Returns the bias score(s) for dichotomous contingency data

correct_negatives([yes_category])

Returns the number of correct negatives (true negatives) for dichotomous contingency data.

equit_threat_score([yes_category])

Returns the equitable threat score(s) for dichotomous contingency data.

false_alarm_rate([yes_category])

Returns the false alarm rate(s) (probability of false detection) for dichotomous contingency data.

false_alarm_ratio([yes_category])

Returns the false alarm ratio(s) for dichotomous contingency data.

false_alarms([yes_category])

Returns the number of false alarms (false positives) for dichotomous contingency data.

gerrity_score()

Returns Gerrity equitable score for a contingency table with K categories.

heidke_score()

Returns the Heidke skill score(s) for a contingency table with K categories

hit_rate([yes_category])

Returns the hit rate(s) (probability of detection) for dichotomous contingency data.

hits([yes_category])

Returns the number of hits (true positives) for dichotomous contingency data.

misses([yes_category])

Returns the number of misses (false negatives) for dichotomous contingency data.

odds_ratio([yes_category])

Returns the odds ratio(s) for dichotomous contingency data

odds_ratio_skill_score([yes_category])

Returns the odds ratio skill score(s) for dichotomous contingency data

peirce_score()

Returns the Peirce skill score(s) (Hanssen and Kuipers discriminantor true skill statistic) for a contingency table with K categories.

success_ratio([yes_category])

Returns the success ratio(s) for dichotomous contingency data.

threat_score([yes_category])

Returns the threat score(s) for dichotomous contingency data.

Attributes

dichotomous

forecast_category_edges

forecasts

observation_category_edges

observations

table