comparison python/indicators.py @ 306:93d851d0d21e

bug correction, minor work on indicators
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 02 Apr 2013 15:27:42 -0400
parents 66691c06928c
children 6c068047edbf
comparison
equal deleted inserted replaced
305:ca9131968bce 306:93d851d0d21e
16 16
17 it should have more information like name, unit''' 17 it should have more information like name, unit'''
18 18
19 def __init__(self, name, values, timeInterval=None, maxValue = None): 19 def __init__(self, name, values, timeInterval=None, maxValue = None):
20 self.name = name 20 self.name = name
21 self.isCosine = name.find('Cosine') 21 self.isCosine = (name.find('Cosine') >= 0)
22 if timeInterval: 22 if timeInterval:
23 assert len(values) == timeInterval.length() 23 assert len(values) == timeInterval.length()
24 self.timeInterval = timeInterval 24 self.timeInterval = timeInterval
25 self.values = {} 25 self.values = {}
26 for i in xrange(int(round(self.timeInterval.length()))): 26 for i in xrange(int(round(self.timeInterval.length()))):
76 '''if the indicator is a function of an angle, 76 '''if the indicator is a function of an angle,
77 transform it to an angle (eg cos) 77 transform it to an angle (eg cos)
78 (no transformation otherwise)''' 78 (no transformation otherwise)'''
79 from numpy import arccos 79 from numpy import arccos
80 values = self.getValues() 80 values = self.getValues()
81 if self.isCosine >= 0: 81 if self.isCosine:
82 return [arccos(c) for c in values] 82 return [arccos(c) for c in values]
83 else: 83 else:
84 return values 84 return values
85 85
86 def plot(self, options = '', xfactor = 1., **kwargs): 86 def plot(self, options = '', xfactor = 1., **kwargs):