Commit 68ef1e4b authored by tozech's avatar tozech
Browse files

Fix: Import problem numba, prints removed

parent 3214c1db
......@@ -115,6 +115,9 @@ categories:
- for binary probability forecasts: ``brier_score``
- for threshold exceedances with an ensemble forecast: ``threshold_brier_score``
* Mean CRPS with decomposition into reliability, resolution, uncertainty:
- for an ensemble via the Hersbach method: ``mean_crps``
All functions are robust to missing values represented by the floating
point value ``NaN``.
......
......@@ -124,34 +124,28 @@ def _mean_crps_rel_pot(observations, forecasts, mean_crps, reliability, crps_pot
for i in range(N):
e = forecasts[i, :]
x = observations[i]
print('i', i, 'e', e, 'x', x, 'Alpha', alpha_k, 'Beta', beta_k)
#print('i', i, 'e', e, 'x', x, 'Alpha', alpha_k, 'Beta', beta_k)
if (k > 0) and (k < M):
if e[k] < x:
print('case 1')
alpha_k += e[k] - e[k-1]
beta_k += 0
elif (e[k-1] < x) and (x <= e[k]):
print('case 2')
alpha_k += x - e[k-1]
beta_k += e[k] - x
elif x <= e[k-1]:
print('case 3')
alpha_k += 0
beta_k += e[k] - e[k-1]
elif (k == 0):
if x < e[0]:
print('case 4')
alpha_k += 0
beta_k += e[0] - x
elif (k == M):
if e[M-1] < x:
print('case 5')
alpha_k += x - e[M-1]
beta_k += 0
alpha_k /= N
beta_k /= N
print('k', k, 'p_k', p_k, 'Alpha', alpha_k, 'Beta', beta_k)
mea += alpha_k * p_k**2 + beta_k * (1 - p_k)**2
g_k = alpha_k + beta_k
......
......@@ -8,7 +8,7 @@ Created on Wed Nov 13 16:37:32 2019
import numpy as np
from scipy.stats import rankdata
from properscoring._gufuncs import _uncertainty_comp, _mean_crps_rel_pot
#def ranks(obs, ensemble):#, mask=):
......@@ -33,7 +33,14 @@ from properscoring._gufuncs import _uncertainty_comp, _mean_crps_rel_pot
# ranks[ties==tie[i]]=[np.random.randint(index[j],index[j]+tie[i]+1,tie[i])[0] for j in range(len(index))]
# return ranks
try:
from properscoring._gufuncs import _uncertainty_comp, _mean_crps_rel_pot
except ImportError as exc:
def _make_import_error(a):
raise ImportError('Numba is not installed.')
_uncertainty_comp = lambda x: _make_import_error(x)
def _mean_crps_hersbach(observations, forecasts):
"""mean CRPS with reliability, resolution and uncertainty
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment