changeset 74:d3e1a7cf3375

added functions to get simply the values of indicators (and arccos transform for cosines
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 21 Jan 2011 18:27:55 -0500
parents 930a6282c9a9
children 46ec876ce90e
files python/moving.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/python/moving.py	Mon Jan 17 16:46:48 2011 -0500
+++ b/python/moving.py	Fri Jan 21 18:27:55 2011 -0500
@@ -386,6 +386,7 @@
     
     def __init__(self, name, values, timeInterval=None):
         self.name = name
+        self.isCosine = name.find('Cosine')
         self.values = values
         self.timeInterval = timeInterval
         if timeInterval:
@@ -418,6 +419,23 @@
             else:
                 return self.values.values()[self.iterInstantNum-1]
 
+    def getValues(self):
+        if self.timeInterval:
+            return self.values
+        else:
+            return self.values.values()
+
+    def getAngleValues(self):
+        '''if the indicator is a function of an angle, 
+        transform it to an angle (eg cos)
+        (no transformation otherwise)'''
+        from numpy import arccos
+        values = self.getValues()
+        if self.isCosine >= 0:
+            return [arccos(c) for c in values]
+        else: 
+            return values
+
 class SeverityIndicator(TemporalIndicator):
     '''Class for severity indicators 
     field mostSevereIsMax is True