Better plotting of FJC but not there yet
[hooke.git] / flatfilts.py
index e0283b5e6e0e14b11b816c2849244ece6f7d1670..3e9f9c8979b287a096140de64ead608ee8f207eb 100755 (executable)
@@ -147,19 +147,22 @@ class flatfiltsCommands:
     #-----Convolution-based peak recognition and filtering.
     #Requires the libpeakspot.py library
     
-    def has_peaks(self, plot, abs_devs):
+    def has_peaks(self, plot, abs_devs=None):
         '''
         Finds peak position in a force curve.
         FIXME: should be moved in libpeakspot.py
         '''
+        if abs_devs==None:
+            abs_devs=self.convfilt_config['mindeviation']
+        
+        
         xret=plot.vectors[1][0]
         yret=plot.vectors[1][1]
         #Calculate convolution.
         convoluted=lps.conv_dx(yret, self.convfilt_config['convolution'])
         
         #surely cut everything before the contact point
-        cut_index=self.find_contact_point()
-        
+        cut_index=self.find_contact_point(plot)
         #cut even more, before the blind window
         start_x=xret[cut_index]
         blind_index=0
@@ -168,11 +171,10 @@ class flatfiltsCommands:
                 break
             blind_index+=1
         cut_index+=blind_index
-        
         #do the dirty convolution-peak finding stuff
         noise_level=lps.noise_absdev(convoluted[cut_index:], self.convfilt_config['positive'], self.convfilt_config['maxcut'], self.convfilt_config['stable'])               
         above=lps.abovenoise(convoluted,noise_level,cut_index,abs_devs)     
-        peak_location,peak_size=lps.find_peaks(above)
+        peak_location,peak_size=lps.find_peaks(above,seedouble=self.convfilt_config['seedouble'])
                 
         #take the maximum
         for i in range(len(peak_location)):
@@ -222,12 +224,11 @@ class flatfiltsCommands:
         if len(args)==0:
             args=self.convfilt_config['mindeviation']
         
-           
-        
         try:
             abs_devs=float(args)
         except:
-            pass
+            print 'Wrong argument, using config value'
+            abs_devs=float(self.convfilt_config['mindeviation'])
                         
         defplots=self.current.curve.default_plots()[0] #we need the raw, uncorrected plots
         
@@ -257,8 +258,10 @@ class flatfiltsCommands:
         recplot.vectors.append([xgood,ygood])
         if recplot.styles==[]:
             recplot.styles=[None,None,'scatter']
+            recplot.colors=[None,None,None]
         else:
             recplot.styles+=['scatter']
+            recplot.colors+=[None]
         
         self._send_plot([recplot])
         
@@ -296,7 +299,6 @@ class flatfiltsCommands:
         print '(Please wait)'
         notflat_list=[]
         
-        
         c=0
         for item in self.current_list:
             c+=1
@@ -334,6 +336,7 @@ class flatfiltsCommands:
             self.current=self.current_list[self.pointer]
             self.do_plot(0)
         
+        
     def do_setconv(self,args):
         '''
         SETCONV