4 def _generate_vectors(self):
6 Here we parse the data and generate the raw vectors. This
7 method has only to do with the peculiar file format here, so
8 it's of no big interest (I just wrote it to present a
11 Only thing to remember, it can be nice to call methods that
12 are used only "internally" by the driver (or by plugins) with
13 a "_" prefix, so to have a visual remark. But it's just an
16 vectors={'PLOT1':[[],[],[],[]] , 'PLOT2':[[],[],[],[]]}
17 positions={'X1':0,'Y1':1,'X2':2,'Y2':3}
20 for item in self.data:
23 vectors[whatplot][pos].append(num)
25 if item[:-1]=='PLOT1':
27 elif item[:-1]=='PLOT2':
29 elif item[0]=='X' or item[0]=='Y':
30 pos=positions[item[:-1]]
36 def default_plots(self):
38 THIS METHOD MUST BE DEFINED.
39 RETURNS: [ lhc.PlotObject ] or [ lhc.PlotObject, lhc.PlotObject]
41 This is the method that returns the plots to Hooke.
42 It must return a list with *one* or *two* PlotObjects.
44 See the curve.py source code to see how PlotObjects are defined and work in detail.
46 gen_vectors=self._generate_vectors()
48 #Here we create the main plot PlotObject and initialize its vectors.
49 main_plot=lhc.PlotObject()
51 #The same for the other plot.
52 other_plot=lhc.PlotObject()
56 Now we fill the plot vectors with our data.
58 The "correct" shape of the vector is [ [[x1,x2,x3...],[y1,y2,y3...]] , [[x1,x2,x3...],[y1,y2,y3...]] ], so we have to put stuff in this way into it.
60 The add_set() method takes care of this , just use plot.add_set(x,y).
62 main_plot.add_set(gen_vectors['PLOT1'][0],gen_vectors['PLOT1'][1])
63 main_plot.add_set(gen_vectors['PLOT1'][2],gen_vectors['PLOT1'][3])
65 other_plot.add_set(gen_vectors['PLOT2'][0],gen_vectors['PLOT2'][1])
66 other_plot.add_set(gen_vectors['PLOT2'][2],gen_vectors['PLOT2'][3])
69 normalize_vectors() trims the vectors, so that if two x/y couples are of different lengths, the latest
70 points are trimmed (otherwise we have a python error). Always a good idea to run it, to avoid crashes.
72 main_plot.normalize_vectors()
73 other_plot.normalize_vectors()
77 - units: [string, string], define the measure units of X and Y axes
78 - destination: 0/1 , defines where to plot the plot (0=top, 1=bottom), default=0
79 - title: string , the plot title.
82 Again, see curve.py comments for details.
84 main_plot.units=['unit of x','unit of y']
85 main_plot.destination=0
86 main_plot.title=self.filename+' main'
88 other_plot.units=['unit of x','unit of y']
89 other_plot.destination=1
90 other_plot.title=self.filename+' other'
92 return [main_plot, other_plot]