You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2014/06/11 17:10:24 UTC

[1/2] git commit: CLIMATE-471 - Add seasonal std dev ratio and pattern corr metrics

Repository: climate
Updated Branches:
  refs/heads/master 41d4d0751 -> cbe10b793


CLIMATE-471 - Add seasonal std dev ratio and pattern corr metrics

- Add seasonally averaged SpatialStdDevRatio and
  SeasonalPatternCorrelation metrics.
- Note, these metrics need to have tests added for them.


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

Branch: refs/heads/master
Commit: 18c941cdde87b49bee124717a93a391db1c9076b
Parents: 8b84418
Author: Michael Joyce <jo...@apache.org>
Authored: Tue Jun 10 21:08:49 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Tue Jun 10 21:08:49 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/climate/blob/18c941cd/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index d85caec..b31cd66 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -194,3 +194,61 @@ class MeanBias(BinaryMetric):
 
         return mean_bias
 
+class SeasonalSpatialStdDevRatio(BinaryMetric):
+    '''Calculate the ratio of spatial standard deviation (model standard
+          deviation)/(observed standard deviation)'''
+
+    def __init__(self, month_start=1, month_end=12):
+        self.month_start = month_start
+        self.month_end = month_end
+
+    def run(self, ref_dataset, target_dataset):
+        '''Calculate the ratio of spatial std. dev. 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: Dataset.
+        :param target_dataset: The target dataset to evaluate against the
+            reference dataset in this metric run.
+        :type target_dataset: Dataset.
+
+        :returns: The ratio of standard deviation of the reference and target
+            dataset.
+        '''
+
+        ref_t_series, ref_means = utils.calc_climatology_season(self.month_start, self.month_end, ref_dataset)
+        target_t_series, target_means = utils.calc_climatology_season(self.month_start, self.month_end, target_dataset)
+
+        return numpy.std(ref_means) / numpy.std(target_means)
+
+
+class SeasonalPatternCorrelation(BinaryMetric):
+    '''Calculate the spatial correlation'''
+
+    def __init__(self, month_start=1, month_end=12):
+        self.month_start = month_start
+        self.month_end = month_end
+
+    def run(self, ref_dataset, target_dataset):
+        '''Calculate the spatial correlation between a reference and target dataset.
+            Using: scipy.stats.pearsonr
+
+        .. note::
+           Overrides BinaryMetric.run()
+
+        :param ref_dataset: The reference dataset to use in this metric run.
+        :type ref_dataset: Dataset.
+        :param target_dataset: The target dataset to evaluate against the
+            reference dataset in this metric run.
+        :type target_dataset: Dataset.
+
+        :returns: The spatial correlation between a reference and target dataset.
+        '''
+        ref_t_series, ref_means = utils.calc_climatology_season(self.month_start, self.month_end, ref_dataset)
+        target_t_series, target_means = utils.calc_climatology_season(self.month_start, self.month_end, target_dataset)
+
+        pattern_correlation, p_value = stats.pearsonr(target_means.flatten(),ref_means.flatten())
+        return pattern_correlation, p_value


[2/2] git commit: Merge CLIMATE-471. Resolve PR #71.

Posted by jo...@apache.org.
Merge CLIMATE-471. Resolve PR #71.


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

Branch: refs/heads/master
Commit: cbe10b793cf3683e7cdf49fb8c6780a1d13b35cb
Parents: 41d4d07 18c941c
Author: Michael Joyce <jo...@apache.org>
Authored: Wed Jun 11 08:09:50 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Wed Jun 11 08:09:50 2014 -0700

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