1 from ..libhooke import WX_GOOD
3 wxversion.select(WX_GOOD)
4 from wx import PostEvent
5 from numpy import arange, mean
7 from .. import curve as lhc
9 class superimposeCommands(object):
14 def do_selimpose(self,args):
16 SELIMPOSE (superimpose.py plugin)
17 Hand-selects the curve portion to superimpose
19 #fixme: set to superimpose should be in args
27 points=self._measure_two_points()
28 boundaries=[points[0].index, points[1].index]
32 #append the selected section
33 self.imposed.append([])
34 self.imposed[-1].append(theplot.vectors[1][0][boundaries[0]:boundaries[1]]) #x
35 self.imposed[-1].append(theplot.vectors[1][1][boundaries[0]:boundaries[1]]) #y
38 self.imposed[-1][0] = [item-self.imposed[-1][0][0] for item in self.imposed[-1][0]]
40 self.imposed[-1][1] = [item-self.imposed[-1][1][0] for item in self.imposed[-1][1]]
42 def do_plotimpose(self,args):
44 PLOTIMPOSE (sumperimpose.py plugin)
45 plots superimposed curves
47 imposed_object=lhc.PlotObject()
48 imposed_object.vectors=self.imposed
49 print 'Plotting',len(imposed_object.vectors),'imposed curves'
51 imposed_object.normalize_vectors()
53 imposed_object.units=self.plots[0].units
54 imposed_object.title='Imposed curves'
55 imposed_object.destination=1
57 plot_graph=self.list_of_events['plot_graph']
58 PostEvent(self.frame,plot_graph(plots=[imposed_object]))
60 def do_plotavgimpose(self,args):
62 PLOTAVGIMPOSE (superimpose.py plugin)
63 Plots the average of superimposed curves using a running window
66 #find extension of each superimposed curve
68 for curve in self.imposed:
69 min_x.append(min(curve[0]))
71 #find minimum extension
72 min_ext_limit=max(min_x)
74 x_avg=arange(step,min_ext_limit,step)
78 for curve in self.imposed:
79 for xvalue, yvalue in zip(curve[0],curve[1]):
80 if xvalue >= (value+step) and xvalue <= (value-step):
82 y_avg.append(mean(to_avg))
85 print len(x_avg), len(y_avg)
88 avg_object=lhc.PlotObject()
89 avg_object.vectors=[[x_avg, y_avg]]
90 avg_object.normalize_vectors()
91 avg_object.units=self.plots[0].units
92 avg_object.title="Average curve"
93 avg_object.destination=1
95 plot_graph=self.list_of_events['plot_graph']
96 PostEvent(self.frame,plot_graph(plots=[avg_object]))