Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Zech
properscoring
Commits
68ef1e4b
Commit
68ef1e4b
authored
Nov 18, 2019
by
tozech
Browse files
Fix: Import problem numba, prints removed
parent
3214c1db
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.rst
View file @
68ef1e4b
...
...
@@ -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``.
...
...
properscoring/_gufuncs.py
View file @
68ef1e4b
...
...
@@ -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
...
...
properscoring/_mean_crps.py
View file @
68ef1e4b
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment