From b632d48105cd6b662a201ebd8673d31684add3bf Mon Sep 17 00:00:00 2001 From: Michael Joyce Date: Wed, 2 Jul 2014 07:48:22 -0700 Subject: [PATCH] CLIMATE-482 - Add basic StdDevRatio metric - Add a version of StdDevRatio without an yearly/seasonal rebinning prior to metric calculation. --- ocw/metrics.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ocw/metrics.py b/ocw/metrics.py index d040c11e..b7036c40 100644 --- a/ocw/metrics.py +++ b/ocw/metrics.py @@ -106,6 +106,26 @@ def run(self, target_dataset): 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)'''