Package PyFoam :: Package LogAnalysis :: Module ValueLineAnalyzer
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.LogAnalysis.ValueLineAnalyzer

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/LogAnalysis/ValueLineAnalyzer.py 1906 2007-08-28T16:16:19.392553Z bgschaid  $  
 2  """Do analysis for a line with values""" 
 3   
 4  from FileLineAnalyzer import FileLineAnalyzer 
 5  from  NameFinderLineAnalyzer import NameFinderLineAnalyzer 
 6   
7 -class ValueLineAnalyzer(FileLineAnalyzer):
8 """Parses lines for numeric values 9 10 The line starts with a predefined string""" 11
12 - def __init__(self,name,pre,titles=[]):
13 """ 14 @param name: name of the expression (needed for output) 15 @param pre: the string that starts the line 16 """ 17 FileLineAnalyzer.__init__(self,titles) 18 19 self.name=name 20 self.pre=pre
21
22 - def doAnalysis(self,line):
23 """Analyzes line and writes the data""" 24 tm=self.parent.getTime() 25 if tm=="": 26 return 27 28 m=line.find(self.pre) 29 if m>=0: 30 rest=line[m+len(self.pre):] 31 fdata=() 32 for teil in rest.split(): 33 try: 34 val=float(teil) 35 fdata+=(val,) 36 except ValueError: 37 pass 38 39 self.files.write(self.name,tm,fdata)
40
41 -class ValueNameFinderLineAnalyzer(NameFinderLineAnalyzer):
42 """Finds the names and notifies it's ValueLineAnalyzer""" 43
44 - def __init__(self,trigger,analyze,val,idNr=1,nr=1):
45 """ 46 @param trigger: The regular expression that has to match before data is collected 47 @param nr: The number of lines after the match that data is collected 48 @param analyze: The regular expression that is used for analysis 49 @param idNr: The id of the group that is used for analysis 50 @param val: The ValueLineAnalyzer that needs the names 51 """ 52 53 NameFinderLineAnalyzer.__init__(self,trigger,analyze,idNr=idNr,nr=nr) 54 55 self.val=val
56
57 - def callOnChange(self):
58 self.val.setTitles(self.names)
59