Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Computes the CRPS of verification data ``o`` relative to normally distributed
forecasts with mean ``mu`` and standard deviation ``sig``.
.. note::
This is a helper function for CRPSS and cannot be called directly by a user.
Args:
forecast (xr.object): Forecast with ``member`` dim.
mu (xr.object): The mean of the verification data.
sig (xr.object): The standard deviation verification data.
See also:
* properscoring.crps_gaussian
* xskillscore.crps_gaussian
"""
return crps_gaussian(forecast, mu, sig)
Args:
forecast (xr.object): Forecast with ``member`` dim.
cdf_or_dist (callable or scipy.stats.distribution): Function which returns the
cumulative density of the forecast distribution at value x.
xmin (float): Lower bounds for integration.
xmax (float): Upper bounds for integration.
tol (float, optional): The desired accuracy of the CRPS. Larger values will
speed up integration. If ``tol`` is set to ``None``,
bounds errors or integration tolerance errors will be
ignored.
See also:
* properscoring.crps_quadrature
* xskillscore.crps_quadrature
"""
return crps_quadrature(forecast, cdf_or_dist, xmin, xmax, tol)
Example:
>>> def pos(x): return x > 0
>>> compute_perfect_model(ds, control, metric='brier_score', logical=pos)
"""
if 'logical' in metric_kwargs:
logical = metric_kwargs['logical']
if not callable(logical):
raise ValueError(f'`logical` must be `callable`, found {type(logical)}')
else:
raise ValueError(
'Please provide a callable `logical` to be applied to comparison and \
verification data to get values in interval [0,1]; \
see properscoring.brier_score.'
)
return brier_score(logical(verif), logical(forecast).mean('member'))
| **orientation** | negative |
+-----------------+-----------+
Reference:
* Matheson, James E., and Robert L. Winkler. “Scoring Rules for
Continuous Probability Distributions.” Management Science 22, no. 10
(June 1, 1976): 1087–96. https://doi.org/10/cwwt4g.
* https://www.lokad.com/continuous-ranked-probability-score
See also:
* properscoring.crps_ensemble
* xskillscore.crps_ensemble
"""
weights = metric_kwargs.get('weights', None)
# switch positions because xskillscore.crps_ensemble(verif, forecasts)
return crps_ensemble(verif, forecast, weights=weights)
+-----------------+-----------------+
| **minimum** | 0.0 |
+-----------------+-----------------+
| **maximum** | ∞ |
+-----------------+-----------------+
| **perfect** | N/A |
+-----------------+-----------------+
| **orientation** | positive |
+-----------------+-----------------+
Reference:
* Bretherton, Christopher S., et al. "The effective number of spatial degrees of
freedom of a time-varying field." Journal of climate 12.7 (1999): 1990-2009.
"""
skipna = metric_kwargs.get('skipna', False)
return effective_sample_size(forecast, verif, dim=dim, skipna=skipna)
+-----------------+-----------+
| **orientation** | negative |
+-----------------+-----------+
See also:
* xskillscore.mae
Reference:
* Ian T. Jolliffe and David B. Stephenson. Forecast Verification: A
Practitioner’s Guide in Atmospheric Science. John Wiley & Sons, Ltd,
Chichester, UK, December 2011. ISBN 978-1-119-96000-3 978-0-470-66071-3.
URL: http://doi.wiley.com/10.1002/9781119960003.
"""
weights = metric_kwargs.get('weights', None)
skipna = metric_kwargs.get('skipna', False)
return mae(forecast, verif, dim=dim, weights=weights, skipna=skipna)
+-----------------+-----------+
| **minimum** | 0.0 |
+-----------------+-----------+
| **maximum** | ∞ |
+-----------------+-----------+
| **perfect** | 0.0 |
+-----------------+-----------+
| **orientation** | negative |
+-----------------+-----------+
See also:
* xskillscore.mape
"""
weights = metric_kwargs.get('weights', None)
skipna = metric_kwargs.get('skipna', False)
return mape(forecast, verif, dim=dim, weights=weights, skipna=skipna)
Details:
+-----------------+-----------+
| **minimum** | 0.0 |
+-----------------+-----------+
| **maximum** | ∞ |
+-----------------+-----------+
| **perfect** | 0.0 |
+-----------------+-----------+
| **orientation** | negative |
+-----------------+-----------+
See also:
* xskillscore.median_absolute_error
"""
skipna = metric_kwargs.get('skipna', False)
return median_absolute_error(forecast, verif, dim=dim, skipna=skipna)
+-----------------+-----------+
| **orientation** | negative |
+-----------------+-----------+
See also:
* xskillscore.mse
Reference:
* Ian T. Jolliffe and David B. Stephenson. Forecast Verification: A
Practitioner’s Guide in Atmospheric Science. John Wiley & Sons, Ltd,
Chichester, UK, December 2011. ISBN 978-1-119-96000-3 978-0-470-66071-3.
URL: http://doi.wiley.com/10.1002/9781119960003.
"""
weights = metric_kwargs.get('weights', None)
skipna = metric_kwargs.get('skipna', False)
return mse(forecast, verif, dim=dim, weights=weights, skipna=skipna)
| **maximum** | 1.0 |
+-----------------+-----------+
| **perfect** | 1.0 |
+-----------------+-----------+
| **orientation** | positive |
+-----------------+-----------+
See also:
* xskillscore.pearson_r
* xskillscore.pearson_r_p_value
* climpred.pearson_r_p_value
* climpred.pearson_r_eff_p_value
"""
weights = metric_kwargs.get('weights', None)
skipna = metric_kwargs.get('skipna', False)
return pearson_r(forecast, verif, dim=dim, weights=weights, skipna=skipna)