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/07/14 16:41:49 UTC

[1/4] git commit: CLIMATE-484 - Remove rebinning metrics

Repository: climate
Updated Branches:
  refs/heads/master f4d39668b -> 557a8b3a7


CLIMATE-484 - Remove rebinning metrics

- Drop SpatialStdDevRation, TemporalPatternCorrelation,
  SeasonalSpatialStdDevRation, and SeasonalPatternCorrelation.


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

Branch: refs/heads/master
Commit: 9102a17cbbadca18bf46ba6039dd66fa71421ab1
Parents: f4d3966
Author: Michael Joyce <jo...@apache.org>
Authored: Wed Jul 2 09:51:11 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Wed Jul 2 09:51:11 2014 -0700

----------------------------------------------------------------------
 ocw/metrics.py | 121 ----------------------------------------------------
 1 file changed, 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/9102a17c/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index a7dbdc3..8458210 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -126,40 +126,6 @@ class StdDevRatio(BinaryMetric):
         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)'''
-
-    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: 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 ratio of standard deviation of the reference and target
-            dataset.
-        '''
-
-        # This is calcClimYear function for ref_dataset
-        reshaped_ref_data = utils.reshape_monthly_to_annually(ref_dataset)
-        ref_t_series = reshaped_ref_data.mean(axis=1)
-        ref_means = ref_t_series.mean(axis=0)
-
-        # This is calcClimYear function for target_dataset
-        reshaped_target_data = utils.reshape_monthly_to_annually(target_dataset)
-        target_t_series = reshaped_target_data.mean(axis=1)
-        target_means = target_t_series.mean(axis=0)
-
-        return numpy.std(ref_means) / numpy.std(target_means)
-
-
 class PatternCorrelation(BinaryMetric):
     '''Calculate the correlation coefficient between two datasets'''
 
@@ -183,37 +149,6 @@ class PatternCorrelation(BinaryMetric):
         return stats.pearsonr(ref_dataset.values.flatten(), target_dataset.values.flatten())[0]
 
 
-class TemporalPatternCorrelation(BinaryMetric):
-    '''Calculate the spatial correlation'''
-
-    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: 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 spatial correlation between a reference and target dataset.
-        '''
-        # This is calcClimYear function for ref_dataset
-        reshaped_ref_data = utils.reshape_monthly_to_annually(ref_dataset)
-        ref_t_series = reshaped_ref_data.mean(axis=1)
-        ref_means = ref_t_series.mean(axis=0)
-
-        # This is calcClimYear function for target_dataset
-        reshaped_target_data = utils.reshape_monthly_to_annually(target_dataset)
-        target_t_series = reshaped_target_data.mean(axis=1)
-        target_means = target_t_series.mean(axis=0)
-
-        pattern_correlation, p_value = stats.pearsonr(target_means.flatten(),ref_means.flatten())
-        return pattern_correlation, p_value
-
 class MeanBias(BinaryMetric):
     '''Calculate the bias averaged over time.'''
 
@@ -238,59 +173,3 @@ class MeanBias(BinaryMetric):
         mean_bias = diff.mean(axis=0)
 
         return mean_bias
-
-class SeasonalSpatialStdDevRatio(BinaryMetric):
-    '''Calculate the seasonal spatial standard deviation ratio.'''
-
-    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 seasonal spatial 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 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 seasonal pattern 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 seasonal pattern correlation.
-
-        .. 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 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


[3/4] git commit: CLIMATE-484 - Remove rebinning metrics from examples.

Posted by jo...@apache.org.
CLIMATE-484 - Remove rebinning metrics from examples.


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

Branch: refs/heads/master
Commit: 26eb92fc9737a432e1ee5758d48ab2d32e52c3c4
Parents: 71706a9
Author: Michael Joyce <jo...@apache.org>
Authored: Wed Jul 2 10:01:22 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Wed Jul 2 10:01:22 2014 -0700

----------------------------------------------------------------------
 examples/taylor_diagram_example.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/26eb92fc/examples/taylor_diagram_example.py
----------------------------------------------------------------------
diff --git a/examples/taylor_diagram_example.py b/examples/taylor_diagram_example.py
index f60bfe6..b08502e 100644
--- a/examples/taylor_diagram_example.py
+++ b/examples/taylor_diagram_example.py
@@ -85,7 +85,7 @@ wrf_dataset = dsp.spatial_regrid(wrf_dataset, new_lats, new_lons)
 
 # Load the metrics that we want to use for the evaluation.
 ################################################################################
-sstdr = metrics.SpatialStdDevRatio()
+sstdr = metrics.StdDevRatio()
 pc = metrics.PatternCorrelation()
 
 # Create our new evaluation object. The knmi dataset is the evaluations
@@ -99,9 +99,7 @@ test_evaluation.run()
 # Pull our the evaluation results and prepare them for drawing a Taylor diagram.
 ################################################################################
 spatial_stddev_ratio = test_evaluation.results[0][0]
-# Pattern correlation results are a tuple, so we need to index and grab
-# the component we care about.
-spatial_correlation = test_evaluation.results[0][1][0]
+spatial_correlation = test_evaluation.results[0][1]
 
 taylor_data = numpy.array([[spatial_stddev_ratio], [spatial_correlation]]).transpose()
 


[2/4] git commit: CLIMATE-484 - Remove rebinning metrics from tests

Posted by jo...@apache.org.
CLIMATE-484 - Remove rebinning metrics from tests


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

Branch: refs/heads/master
Commit: 71706a9c72e67d96d758eb17e29e3049b4cc4fd5
Parents: 9102a17
Author: Michael Joyce <jo...@apache.org>
Authored: Wed Jul 2 09:52:54 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Wed Jul 2 09:52:54 2014 -0700

----------------------------------------------------------------------
 ocw/tests/test_metrics.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/71706a9c/ocw/tests/test_metrics.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_metrics.py b/ocw/tests/test_metrics.py
index ae8570a..739224c 100644
--- a/ocw/tests/test_metrics.py
+++ b/ocw/tests/test_metrics.py
@@ -79,10 +79,10 @@ class TestTemporalStdDev(unittest.TestCase):
         npt.assert_almost_equal(self.temporal_std_dev.run(self.target_dataset), expected_result)
 
 
-class TestSpatialStdDevRatio(unittest.TestCase):
-    '''Test the metrics.SpatialStdDevRatio metric'''
+class TestStdDevRatio(unittest.TestCase):
+    '''Test the metrics.StdDevRatio metric'''
     def setUp(self):
-        self.spatial_std_dev_ratio = metrics.SpatialStdDevRatio()
+        self.std_dev_ratio = metrics.StdDevRatio()
         self.ref_dataset = Dataset(
             np.array([1., 1., 1., 1., 1.]),
             np.array([1., 1., 1., 1., 1.]),
@@ -102,7 +102,7 @@ class TestSpatialStdDevRatio(unittest.TestCase):
         )
 
     def test_function_run(self):
-        self.assertTrue(self.spatial_std_dev_ratio.run(self.ref_dataset, self.tar_dataset), 2.5)
+        self.assertTrue(self.std_dev_ratio.run(self.ref_dataset, self.tar_dataset), 2.5)
 
 
 class TestPatternCorrelation(unittest.TestCase):


[4/4] git commit: Resolve CLIMATE-484. Merge PR #86.

Posted by jo...@apache.org.
Resolve CLIMATE-484. Merge PR #86.


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

Branch: refs/heads/master
Commit: 557a8b3a78f53843809ed993a7549f7ea3931969
Parents: f4d3966 26eb92f
Author: Michael Joyce <jo...@apache.org>
Authored: Mon Jul 14 07:41:03 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Mon Jul 14 07:41:03 2014 -0700

----------------------------------------------------------------------
 examples/taylor_diagram_example.py |   6 +-
 ocw/metrics.py                     | 121 --------------------------------
 ocw/tests/test_metrics.py          |   8 +--
 3 files changed, 6 insertions(+), 129 deletions(-)
----------------------------------------------------------------------