1 # -*- coding: utf-8 -*-
2 from ..libhooke import WX_GOOD, ClickedPoint
5 wxversion.select(WX_GOOD)
6 from wx import PostEvent
14 class curvetoolsCommands:
16 def fit_interval_nm(self,start_index,plot,nm,backwards):
18 Calculates the number of points to fit, given a fit interval in nm
19 start_index: index of point
21 backwards: if true, finds a point backwards.
23 whatset=1 #FIXME: should be decidable
24 x_vect=plot.vectors[1][0]
28 start=x_vect[start_index]
30 while abs(x_vect[i]-x_vect[start_index])*(10**9) < nm:
31 if i==0 or i==maxlen-1: #we reached boundaries of vector!
43 def find_current_peaks(self,noflatten, a=True, maxpeak=True):
46 a=self.convfilt_config['mindeviation']
50 print "Bad input, using default."
51 abs_devs=self.convfilt_config['mindeviation']
53 defplot=self.current.curve.default_plots()[0]
55 flatten=self._find_plotmanip('flatten') #Extract flatten plotmanip
56 defplot=flatten(defplot, self.current, customvalue=1) #Flatten curve before feeding it to has_peaks
57 pk_location,peak_size=self.has_peaks(defplot, abs_devs, maxpeak)
58 return pk_location, peak_size
61 def pickup_contact_point(self,N=1,whatset=1):
62 '''macro to pick up the contact point by clicking'''
63 contact_point=self._measure_N_points(N=1, whatset=1)[0]
64 contact_point_index=contact_point.index
65 self.wlccontact_point=contact_point
66 self.wlccontact_index=contact_point.index
67 self.wlccurrent=self.current.path
68 return contact_point, contact_point_index
72 def baseline_points(self,peak_location, displayed_plot):
73 clicks=self.config['baseline_clicks']
76 base_index_0=peak_location[-1]+self.fit_interval_nm(peak_location[-1], displayed_plot, self.config['auto_right_baseline'],False)
77 self.basepoints.append(self._clickize(displayed_plot.vectors[1][0],displayed_plot.vectors[1][1],base_index_0))
78 base_index_1=self.basepoints[0].index+self.fit_interval_nm(self.basepoints[0].index, displayed_plot, self.config['auto_left_baseline'],False)
79 self.basepoints.append(self._clickize(displayed_plot.vectors[1][0],displayed_plot.vectors[1][1],base_index_1))
81 print 'Select baseline'
83 self.basepoints=self._measure_N_points(N=1, whatset=1)
84 base_index_1=self.basepoints[0].index+self.fit_interval_nm(self.basepoints[0].index, displayed_plot, self.config['auto_left_baseline'], False)
85 self.basepoints.append(self._clickize(displayed_plot.vectors[1][0],displayed_plot.vectors[1][1],base_index_1))
87 self.basepoints=self._measure_N_points(N=2, whatset=1)
89 self.basecurrent=self.current.path
90 return self.basepoints