3 from hooke.libhooke import WX_GOOD, ClickedPoint
6 wxversion.select(WX_GOOD)
7 from wx import PostEvent
15 warnings.simplefilter('ignore',np.RankWarning)
18 class multidistanceCommands(object):
20 def do_multidistance(self,args):
24 Based on the convolution recognition automatically give the distances between the peaks found.
25 The command allow also to remove the unwanted peaks that can be due to interference.
26 When you first issue the command, it will ask for the filename. If you are giving the filename
27 of an existing file, autopeak will resume it and append measurements to it. If you are giving
28 a new filename, it will create the file and append to it until you close Hooke.
29 You can also define a minimun deviation of the peaks.
32 multidistance [deviation]
33 deviation = number of times the convolution signal is above the noise absolute deviation.
38 peaks_location, peak_size=self.find_current_peaks(noflatten)
40 #if no peaks, we have nothing to plot. exit.
41 if len(peaks_location)==0:
44 #otherwise, we plot the peak locations.
45 xplotted_ret=self.plots[0].vectors[1][0]
46 yplotted_ret=self.plots[0].vectors[1][1]
47 xgood=[xplotted_ret[index] for index in peaks_location]
48 ygood=[yplotted_ret[index] for index in peaks_location]
50 recplot=self._get_displayed_plot()
51 recplot.vectors.append([xgood,ygood])
52 if recplot.styles==[]:
53 recplot.styles=[None,None,'scatter']
54 recplot.colors=[None,None,None]
56 recplot.styles+=['scatter']
57 recplot.colors+=[None]
59 self._send_plot([recplot])
61 print 'Peaks to ignore (0,1...n from contact point,return to take all)'
62 print 'N to discard measurement'
63 exclude_raw=raw_input('Input:')
68 if not exclude_raw=='':
69 exclude=exclude_raw.split(',')
70 #we convert in numbers the input
72 exclude=[int(item) for item in exclude]
74 print 'Bad input, taking nothing.'
77 # we remove the peaks that we don't want from the list, we need a counter beacause if we remove
78 # a peaks the other peaks in the list are shifted by one at each step
82 peaks_location=peaks_location[1:]
85 peaks_location= peaks_location[0:new_a]+peaks_location[new_a+1:]
86 peak_size= peak_size[0:new_a]+peak_size[new_a+1:]
89 #we calculate the distance vector
91 for i in range(len(peaks_location)-1):
92 dist.append(xplotted_ret[peaks_location[i]]-xplotted_ret[peaks_location[i+1]])
100 self.autofile=raw_input('Multidistance filename? (return to ignore) ')
101 if self.autofile=='':
105 if not os.path.exists(self.autofile):
106 f=open(self.autofile,'w+')
107 f.write('Analysis started '+time.asctime()+'\n')
108 f.write('----------------------------------------\n')
109 f.write('; Delta Distance length (m)\n')
110 f.write(self.current.path+'\n')
118 f=open(self.autofile,'a+')
120 f.write(self.current.path+'\n')