Repository: climate
Updated Branches:
  refs/heads/master 9b6d73d48 -> 2b71d0b9e


CLIMATE-482 - Add basic StdDevRatio metric

- Add a version of StdDevRatio without an yearly/seasonal rebinning
  prior to metric calculation.


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

Branch: refs/heads/master
Commit: b632d48105cd6b662a201ebd8673d31684add3bf
Parents: 9b6d73d
Author: Michael Joyce <[email protected]>
Authored: Wed Jul 2 07:48:22 2014 -0700
Committer: Michael Joyce <[email protected]>
Committed: Wed Jul 2 07:48:22 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/climate/blob/b632d481/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index d040c11..b7036c4 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -106,6 +106,26 @@ class TemporalStdDev(UnaryMetric):
         return target_dataset.values.std(axis=0, ddof=1)
 
 
+class StdDevRatio(BinaryMetric):
+    '''Calculate the standard deviation ratio between two datasets.'''
+
+    def run(self, ref_dataset, target_dataset):
+        '''Calculate the standard deviation ratio.
+
+        .. note::
+            Overrides BinaryMetric.run()
+
+        :param ref_dataset: The reference dataset to use in this metric run.
+        :type ref_dataset: ocw.dataset.Dataset object
+        :param target_dataset: The target dataset to evaluate against the
+            reference dataset in this metric run.
+        :type target_dataset: ocw.dataset.Dataset object
+
+        :returns: The standard deviation ratio of the reference and target
+        '''
+        return target_dataset.values.std() / ref_dataset.values.std()
+
+
 class SpatialStdDevRatio(BinaryMetric):
     '''Calculate the ratio of spatial standard deviation (model standard
           deviation)/(observed standard deviation)'''

Reply via email to