You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by hu...@apache.org on 2015/07/15 08:17:12 UTC

[1/5] climate git commit: metrics.py now uses numpy.ma modules to calculate metrics

Repository: climate
Updated Branches:
  refs/heads/master 751c7a418 -> a54b66ebd


metrics.py now uses numpy.ma modules to calculate metrics


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

Branch: refs/heads/master
Commit: 61fb7134acdeb792cad522abe30e87c994e0d78e
Parents: fe190b6
Author: huikyole <hu...@jpl.nasa.gov>
Authored: Mon Jun 8 11:14:56 2015 -0700
Committer: huikyole <hu...@jpl.nasa.gov>
Committed: Mon Jun 8 11:14:56 2015 -0700

----------------------------------------------------------------------
 ocw/metrics.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/61fb7134/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index 47c20de..23e0dd4 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -23,7 +23,8 @@ Classes:
 from abc import ABCMeta, abstractmethod
 import ocw.utils as utils
 import numpy
-from scipy import stats
+import numpy.ma as ma
+from scipy.stats import mstats
 
 class Metric(object):
     '''Base Metric Class'''
@@ -105,7 +106,7 @@ class TemporalStdDev(UnaryMetric):
         :returns: The temporal standard deviation of the target dataset
         :rtype: :class:`ndarray`
         '''
-        return target_dataset.values.std(axis=0, ddof=1)
+        return ma.std(target_dataset.values.std, axis=0)
 
 
 class StdDevRatio(BinaryMetric):
@@ -150,7 +151,7 @@ class PatternCorrelation(BinaryMetric):
         # stats.pearsonr returns correlation_coefficient, 2-tailed p-value
         # We only care about the correlation coefficient
         # Docs at http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pearsonr.html
-        return stats.pearsonr(ref_dataset.values.flatten(), target_dataset.values.flatten())[0]
+        return mstats.pearsonr(ref_dataset.values.flatten(), target_dataset.values.flatten())[0]
 
 
 class TemporalCorrelation(BinaryMetric):
@@ -177,12 +178,12 @@ class TemporalCorrelation(BinaryMetric):
             coefficients
         '''
         num_times, num_lats, num_lons = reference_dataset.values.shape
-        coefficients = numpy.zeros([num_lats, num_lons])
-        levels = numpy.zeros([num_lats, num_lons])
+        coefficients = ma.zeros([num_lats, num_lons])
+        levels = ma.zeros([num_lats, num_lons])
         for i in numpy.arange(num_lats):
             for j in numpy.arange(num_lons):
                 coefficients[i, j], levels[i, j] = (
-                    stats.pearsonr(
+                    mstats.pearsonr(
                         reference_dataset.values[:, i, j],
                         target_dataset.values[:, i, j]
                     )
@@ -213,7 +214,7 @@ class TemporalMeanBias(BinaryMetric):
         diff = target_dataset.values - ref_dataset.values 
         if absolute:
             diff = abs(diff)
-        mean_bias = diff.mean(axis=0)
+        mean_bias = ma.mean(diff, axis=0)
 
         return mean_bias
 
@@ -239,7 +240,7 @@ class SpatialMeanOfTemporalMeanBias(BinaryMetric):
         '''
 
         bias = target_dataset.values - reference_dataset.values 
-        return bias.mean()
+        return ma.mean(bias)
 
 
 class RMSError(BinaryMetric):
@@ -265,5 +266,5 @@ class RMSError(BinaryMetric):
         '''
 
         sqdiff = (reference_dataset.values - target_dataset.values) ** 2
-        return numpy.sqrt(sqdiff.mean())
+        return (ma.mean(sqdiff))**0.5
 


[3/5] climate git commit: Merge branch 'CLIMATE-641' of https://github.com/huikyole/climate into CLIMATE-641

Posted by hu...@apache.org.
Merge branch 'CLIMATE-641' of https://github.com/huikyole/climate into CLIMATE-641


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

Branch: refs/heads/master
Commit: ca756c686bab61d3c6f8747303272880480e65af
Parents: 8641bdb 35694ad
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Tue Jul 14 23:08:56 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Tue Jul 14 23:08:56 2015 -0700

----------------------------------------------------------------------
 ocw/metrics.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[4/5] climate git commit: Merge branch 'master' of https://github.com/apache/climate into CLIMATE-641

Posted by hu...@apache.org.
Merge branch 'master' of https://github.com/apache/climate into CLIMATE-641


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

Branch: refs/heads/master
Commit: 78b69b78780de46d6ed1470d613d3b0abbbe3133
Parents: ca756c6 751c7a4
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Tue Jul 14 23:09:38 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Tue Jul 14 23:09:38 2015 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



[5/5] climate git commit: Resolve CLIMATE-641. Merge pull request # 208.

Posted by hu...@apache.org.
Resolve CLIMATE-641. Merge pull request # 208.


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

Branch: refs/heads/master
Commit: a54b66ebd4323010981a0c00e1f966ce99473f7c
Parents: 751c7a4 78b69b7
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Tue Jul 14 23:16:06 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Tue Jul 14 23:16:06 2015 -0700

----------------------------------------------------------------------
 ocw/metrics.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[2/5] climate git commit: debugging after local testing

Posted by hu...@apache.org.
debugging after local testing


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

Branch: refs/heads/master
Commit: 35694adcd3133cace3c57a10228ac09f663d5c6d
Parents: 61fb713
Author: huikyole <hu...@jpl.nasa.gov>
Authored: Fri Jun 12 13:20:48 2015 -0700
Committer: huikyole <hu...@jpl.nasa.gov>
Committed: Fri Jun 12 13:20:48 2015 -0700

----------------------------------------------------------------------
 ocw/metrics.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/35694adc/ocw/metrics.py
----------------------------------------------------------------------
diff --git a/ocw/metrics.py b/ocw/metrics.py
index 23e0dd4..9b9aad6 100644
--- a/ocw/metrics.py
+++ b/ocw/metrics.py
@@ -106,7 +106,7 @@ class TemporalStdDev(UnaryMetric):
         :returns: The temporal standard deviation of the target dataset
         :rtype: :class:`ndarray`
         '''
-        return ma.std(target_dataset.values.std, axis=0)
+        return ma.std(target_dataset.values, axis=0, ddof=1)
 
 
 class StdDevRatio(BinaryMetric):
@@ -127,7 +127,7 @@ class StdDevRatio(BinaryMetric):
 
         :returns: The standard deviation ratio of the reference and target
         '''
-        return target_dataset.values.std() / ref_dataset.values.std()
+        return ma.std(target_dataset.values)/ma.std(ref_dataset.values)
 
 
 class PatternCorrelation(BinaryMetric):