climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [1/4] climate git commit: include absolute bias
Date Wed, 01 Aug 2018 05:28:09 GMT
Repository: climate
Updated Branches:
  refs/heads/master 7cdaa7c0c -> cf3ef6015


include absolute bias

Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/4fd7d491
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/4fd7d491
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/4fd7d491

Branch: refs/heads/master
Commit: 4fd7d4916f12757434fe4494940aac064ca24852
Parents: 3a80408
Author: Prateek Chanda <prateekkol21@gmail.com>
Authored: Sat Jun 23 22:25:12 2018 +0530
Committer: GitHub <noreply@github.com>
Committed: Sat Jun 23 22:25:12 2018 +0530

----------------------------------------------------------------------
 ocw/metrics.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/4fd7d491/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index 3a6477e..b266012 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -281,6 +281,29 @@ def calc_bias(target_array, reference_array, average_over_time=False):
         return ma.average(bias, axis=0)
     else:
         return bias
+    
+
+def calc_absbias(target_array, reference_array, average_over_time=False):
+    ''' Calculate absolute difference between two arrays
+
+    :param target_array: an array to be evaluated, as model output
+    :type target_array: :class:'numpy.ma.core.MaskedArray'
+
+    :param reference_array: an array of reference dataset
+    :type reference_array: :class:'numpy.ma.core.MaskedArray'
+
+    :param average_over_time: if True, calculated bias is averaged for the axis=0
+    :type average_over_time: 'bool'
+
+    :returns: Absolute Biases array of the target dataset
+    :rtype: :class:'numpy.ma.core.MaskedArray'
+    '''
+
+    bias = abs(target_array - reference_array)
+    if average_over_time:
+        return ma.average(bias, axis=0)
+    else:
+        return bias
 
 
 def calc_stddev(array, axis=None):


Mime
View raw message