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

Source Code for Module PyFoam.Basics.GnuplotTimelines

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