Package PyFoam :: Package Basics :: Module GnuplotTimelines
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Basics.GnuplotTimelines

 1  #  ICE Revision: $Id: GnuplotTimelines.py 7832 2007-08-28 13:07:26Z bgschaid $  
 2  """Plots a collection of timelines""" 
 3   
 4  try: 
 5      from Gnuplot import Gnuplot,Data 
 6  except ImportError: 
 7      from PyFoam.ThirdParty.Gnuplot import Gnuplot,Data 
 8       
 9  from os import uname 
10   
11 -class GnuplotTimelines(Gnuplot):
12 """This class opens a gnuplot window and plots a timelines-collection in it""" 13 14 terminalNr=1 15
16 - def __init__(self,timelines,persist=None,raiseit=True,with="lines",alternateAxis=[],forbidden=[],start=None,end=None):
17 """@param timelines: The timelines object 18 @type timelines: TimeLineCollection 19 @param persist: Gnuplot window persistst after run 20 @param raiseit: Raise the window at every plot 21 @param with: how to plot the data (lines, points, steps) 22 @param alternateAxis: list with names that ought to appear on the alternate y-axis 23 @param forbidden: A list with strings. If one of those strings is found in a name, it is not plotted 24 @param start: First time that should be plotted. If undefined everything from the start is plotted 25 @param end: Last time that should be plotted. If undefined data is plotted indefinitly 26 """ 27 28 Gnuplot.__init__(self,persist=persist) 29 self.alternate=alternateAxis 30 self.forbidden=forbidden 31 32 if start or end: 33 rng="[" 34 if start: 35 rng+=str(start) 36 rng+=":" 37 if end: 38 rng+=str(end) 39 rng+="]" 40 self.set_string("xrange "+rng) 41 42 if len(self.alternate)>0: 43 self.set_string("y2tics") 44 45 if raiseit: 46 x11addition=" raise" 47 else: 48 x11addition=" noraise" 49 50 if uname()[0]=="Darwin": 51 self.set_string("terminal x11"+x11addition) 52 # self.set_string("terminal aqua "+str(GnuplotTimelines.terminalNr)) 53 GnuplotTimelines.terminalNr+=1 54 else: 55 self.set_string("terminal x11"+x11addition) 56 57 self.data=timelines 58 self.with=with 59 60 self.redo()
61
62 - def redo(self):
63 """Replot the timelines""" 64 times=self.data.getTimes() 65 if len(times)<=0: 66 return 67 68 tmp=self.data.getValueNames() 69 names=[] 70 for n in tmp: 71 addIt=True 72 for f in self.forbidden: 73 if n.find(f)>=0: 74 addIt=False 75 break 76 if addIt: 77 names.append(n) 78 79 self.itemlist=[] 80 for n in names: 81 it=Data(times,self.data.getValues(n),title=n,with=self.with) 82 if n in self.alternate: 83 it.set_option(axes="x1y2") 84 85 self.itemlist.append(it) 86 87 if len(names)>0 and len(times)>0: 88 self.replot()
89