3 from libhooke import WX_GOOD
5 wxversion.select(WX_GOOD)
6 from wx import PostEvent
8 import libhookecurve as lhc
9 from numpy import arange, mean
11 class superimposeCommands:
16 def do_selimpose(self,args):
18 SELIMPOSE (superimpose.py plugin)
19 Hand-selects the curve portion to superimpose
21 #fixme: set to superimpose should be in args
29 points=self._measure_two_points()
30 boundaries=[points[0].index, points[1].index]
34 #append the selected section
35 self.imposed.append([])
36 self.imposed[-1].append(theplot.vectors[1][0][boundaries[0]:boundaries[1]]) #x
37 self.imposed[-1].append(theplot.vectors[1][1][boundaries[0]:boundaries[1]]) #y
40 self.imposed[-1][0] = [item-self.imposed[-1][0][0] for item in self.imposed[-1][0]]
42 self.imposed[-1][1] = [item-self.imposed[-1][1][0] for item in self.imposed[-1][1]]
44 def do_plotimpose(self,args):
46 PLOTIMPOSE (sumperimpose.py plugin)
47 plots superimposed curves
49 imposed_object=lhc.PlotObject()
50 imposed_object.vectors=self.imposed
51 print 'Plotting',len(imposed_object.vectors),'imposed curves'
53 imposed_object.normalize_vectors()
55 imposed_object.units=self.plots[0].units
56 imposed_object.title='Imposed curves'
57 imposed_object.destination=1
59 plot_graph=self.list_of_events['plot_graph']
60 PostEvent(self.frame,plot_graph(plots=[imposed_object]))
62 def do_plotavgimpose(self,args):
64 PLOTAVGIMPOSE (superimpose.py plugin)
65 Plots the average of superimposed curves using a running window
68 #find extension of each superimposed curve
70 for curve in self.imposed:
71 min_x.append(min(curve[0]))
73 #find minimum extension
74 min_ext_limit=max(min_x)
76 x_avg=arange(step,min_ext_limit,step)
80 for curve in self.imposed:
81 for xvalue, yvalue in zip(curve[0],curve[1]):
82 if xvalue >= (value+step) and xvalue <= (value-step):
84 y_avg.append(mean(to_avg))
87 print len(x_avg), len(y_avg)
90 avg_object=lhc.PlotObject()
91 avg_object.vectors=[[x_avg, y_avg]]
92 avg_object.normalize_vectors()
93 avg_object.units=self.plots[0].units
94 avg_object.title="Average curve"
95 avg_object.destination=1
97 plot_graph=self.list_of_events['plot_graph']
98 PostEvent(self.frame,plot_graph(plots=[avg_object]))