From a05989c34fd7cb4c34831db79f3f365f89ad85df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20Bakketun?= Date: Fri, 3 May 2024 15:40:47 +0200 Subject: [PATCH] correct obsmon statistics (#42) * correct obsmon statistics * clean obsmon statistics --- pysurfex/obsmon.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/pysurfex/obsmon.py b/pysurfex/obsmon.py index 1d277eb..d628ba4 100644 --- a/pysurfex/obsmon.py +++ b/pysurfex/obsmon.py @@ -195,23 +195,7 @@ def rmse(predictions, targets): """ if len(predictions) > 0: - return np.sqrt(np.nanmin(((predictions - targets) ** 2))) - else: - return "NULL" - - -def bias(predictions): - """Bias. - - Args: - predictions (_type_): _description_ - - Returns: - _type_: _description_ - - """ - if len(predictions) > 0: - return np.nanmean(np.subtract(predictions, np.nanmean(predictions))) + return np.sqrt(np.nanmean(((predictions - targets) ** 2))) else: return "NULL" @@ -227,7 +211,7 @@ def absbias(predictions): """ if len(predictions) > 0: - return np.nanmean(np.subtract(abs(predictions), np.nanmean(predictions))) + return np.nanmean(abs(predictions)) else: return "NULL" @@ -303,7 +287,7 @@ def calculate_statistics(observations, modes, stat_cols): if col == "nobs": statistics.update({tab: len(obs)}) elif col == "fg_bias": - statistics.update({tab: bias(fg_dep)}) + statistics.update({tab: mean(fg_dep)}) elif col == "fg_abs_bias": statistics.update({tab: absbias(fg_dep)}) elif col == "fg_rms": @@ -315,7 +299,7 @@ def calculate_statistics(observations, modes, stat_cols): elif col == "bc": statistics.update({tab: 0}) elif col == "an_bias": - statistics.update({tab: bias(an_dep)}) + statistics.update({tab: mean(an_dep)}) elif col == "an_abs_bias": statistics.update({tab: absbias(an_dep)}) elif col == "an_rms":