Skip to content

Commit

Permalink
fixed issue for eventless forecasts and observations
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgruber committed Jan 16, 2024
1 parent e215a0c commit c1b9a5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion code/compute_FSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def compute_fss(fcst, obs, window, fcst_cache=None, obs_cache=None):
num = np.power(fhat - ohat, 2).sum()
denom = (np.power(fhat, 2) + np.power(ohat, 2)).sum()

return num, denom, 1. - num / denom
if num == 0 and denom == 0:
fss = 1
else:
fss = 1. - num / denom

return num, denom, fss


def fss_prob(fcst, obs, thrsh, window):
Expand Down
18 changes: 15 additions & 3 deletions code/mod_fss.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ SUBROUTINE compute_fss_table (n1, n2, kernel, field1, field2, fss)
numinator = SUM( (fhat1 - fhat2)**2 )
denominator = SUM( fhat1**2 + fhat2**2 )

fss = 1. - numinator / denominator
IF (numinator == 0. .AND. denominator == 0) THEN
fss = 1.
ELSE
fss = 1. - numinator / denominator
END IF
END SUBROUTINE compute_fss_table


Expand All @@ -111,7 +115,11 @@ SUBROUTINE compute_fss_from_binary (n1, n2, kernel, field1, field2, fss)
numinator = SUM( (fhat1 - fhat2)**2 )
denominator = SUM( fhat1**2 + fhat2**2 )

fss = 1. - numinator / denominator
IF (numinator == 0. .AND. denominator == 0) THEN
fss = 1.
ELSE
fss = 1. - numinator / denominator
END IF
END SUBROUTINE compute_fss_from_binary


Expand All @@ -135,7 +143,11 @@ SUBROUTINE fss_one_thrsh (n1, n2, nkernel, kernel, field1, field2, fss)
numinator = SUM( (field1 - field2)**2 )
denominator = SUM( field1**2 + field2**2 )

fss(i) = 1. - numinator / denominator
IF (numinator == 0. .AND. denominator == 0) THEN
fss = 1.
ELSE
fss = 1. - numinator / denominator
END IF
ELSE
CALL compute_fss_table(n1, n2, kernel(i), table1, table2, fss(i))
END IF
Expand Down

0 comments on commit c1b9a5e

Please sign in to comment.