Skip to content

Commit

Permalink
Enable NaN filtering in NSE and PBIAS #79
Browse files Browse the repository at this point in the history
  • Loading branch information
thouska committed Feb 21, 2019
1 parent 3b64f6c commit 74ca4a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spotpy/objectivefunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def bias(evaluation, simulation):
"""
if len(evaluation) == len(simulation):
obs, sim = np.array(evaluation), np.array(simulation)
bias = np.sum(obs - sim) / len(obs)
bias = np.nansum(obs - sim) / len(obs)
return float(bias)

else:
Expand Down Expand Up @@ -62,7 +62,7 @@ def pbias(evaluation, simulation):
if len(evaluation) == len(simulation):
sim = np.array(simulation)
obs = np.array(evaluation)
return 100 * (float(np.sum(sim - obs)) / float(np.sum(obs)))
return 100 * (float(np.nansum(sim - obs)) / float(np.nansum(obs)))

else:
logging.warning("evaluation and simulation lists does not have the same length.")
Expand Down Expand Up @@ -90,10 +90,10 @@ def nashsutcliffe(evaluation, simulation):
if len(evaluation) == len(simulation):
s, e = np.array(simulation), np.array(evaluation)
# s,e=simulation,evaluation
mean_observed = np.mean(e)
mean_observed = np.nanmean(e)
# compute numerator and denominator
numerator = sum((e - s) ** 2)
denominator = sum((e - mean_observed)**2)
numerator = np.nansum((e - s) ** 2)
denominator = np.nansum((e - mean_observed)**2)
# compute coefficient
return 1 - (numerator / denominator)

Expand Down

0 comments on commit 74ca4a0

Please sign in to comment.