You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by le...@apache.org on 2018/08/01 05:28:10 UTC

[2/4] climate git commit: Add a new class for Absolute Bias involving the function

Add a new class for Absolute Bias involving the function

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

Branch: refs/heads/master
Commit: 8104a2b24f1cf04c299d27276fc500650089eac2
Parents: 4fd7d49
Author: Prateek Chanda <pr...@gmail.com>
Authored: Wed Jun 27 07:15:46 2018 +0530
Committer: GitHub <no...@github.com>
Committed: Wed Jun 27 07:15:46 2018 +0530

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


http://git-wip-us.apache.org/repos/asf/climate/blob/8104a2b2/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index b266012..199ab16 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -89,6 +89,28 @@ class Bias(BinaryMetric):
         :rtype: :class:`numpy.ndarray`
         '''
         return calc_bias(target_dataset.values, ref_dataset.values)
+    
+
+class AbsoluteBias(BinaryMetric):
+    '''Calculate the absolute bias between a reference and target dataset.'''
+
+    def run(self, ref_dataset, target_dataset):
+        '''Calculate the absolute bias between a reference and target dataset.
+
+        .. note::
+           Overrides BinaryMetric.run()
+
+        :param ref_dataset: The reference dataset to use in this metric run.
+        :type ref_dataset: :class:`dataset.Dataset`
+
+        :param target_dataset: The target dataset to evaluate against the
+            reference dataset in this metric run.
+        :type target_dataset: :class:`dataset.Dataset`
+
+        :returns: The absolute difference between the reference and target datasets.
+        :rtype: :class:`numpy.ndarray`
+        '''
+        return calc_absbias(target_dataset.values, ref_dataset.values)
 
 
 class SpatialPatternTaylorDiagram(BinaryMetric):