climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1506798 - /incubator/climate/branches/RefactorInput/ocw/metrics.py
Date Thu, 25 Jul 2013 02:24:46 GMT
Author: joyce
Date: Thu Jul 25 02:24:46 2013
New Revision: 1506798

URL: http://svn.apache.org/r1506798
Log:
CLIMATE-217 - Add TemporalStdDev metric

- Add temporal std. dev. as an example of implementing a "unary" metric.

Modified:
    incubator/climate/branches/RefactorInput/ocw/metrics.py

Modified: incubator/climate/branches/RefactorInput/ocw/metrics.py
URL: http://svn.apache.org/viewvc/incubator/climate/branches/RefactorInput/ocw/metrics.py?rev=1506798&r1=1506797&r2=1506798&view=diff
==============================================================================
--- incubator/climate/branches/RefactorInput/ocw/metrics.py (original)
+++ incubator/climate/branches/RefactorInput/ocw/metrics.py Thu Jul 25 02:24:46 2013
@@ -50,6 +50,7 @@ class Metric():
         :trype: List
         '''
 
+
 class Bias(Metric):
     '''Calculate the bias between a reference and target dataset.'''
 
@@ -68,3 +69,29 @@ class Bias(Metric):
         :rtype: List
         '''
         return [datasets[0].values - datasets[1].values]
+
+
+class TemporalStdDev(Metric):
+    '''Calculate the standard deviation over the time.'''
+
+    def __init__(self):
+        '''Default constructor.
+
+        .. note::
+           Overrides Metric.__init__()
+        '''
+        self.isUnary = True
+
+    def run(self, datasets):
+        '''Calculate the temporal std. dev. for a datasets.
+
+        .. note::
+           Overrides Metric.run()
+
+        :param datasets: The datasets on which to calculate the temporal \
+                std. dev. in datasets[0].
+        :type datasets: Tuple
+        :returns: A list containing the temporal std. dev.
+        :rtype: List
+        '''
+        return datasets[0].values.std(axi=0, ddof=1)



Mime
View raw message