New plotmanip 'centerzero' shifts the curves to 0 force
authoralbertogomcas <devnull@localhost>
Wed, 27 Jan 2010 03:01:14 +0000 (03:01 +0000)
committeralbertogomcas <devnull@localhost>
Wed, 27 Jan 2010 03:01:14 +0000 (03:01 +0000)
hooke.conf
procplots.py

index 43625b48c465381888d34c411b546862f88caca3..bda56132dab29fcf779f3418c2cbb06471e80ec1 100755 (executable)
@@ -2,7 +2,7 @@
 <!-- To comment something, put dashes and ! like here -->\r
 <config>\r
 <!-- Internal variabls. -->\r
-    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" fit_function="wlc" temperature="301" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" auto_fit_nm="5" auto_min_p="0.005" auto_max_p="10" baseline_clicks="0" auto_left_baseline="20" auto_right_baseline="20" force_multiplier="1" fc_showphase="0" fc_showimposed="0" fc_interesting="0" tccd_threshold="0" tccd_coincident="0"/>\r
+    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" fit_function="wlc" temperature="301" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" auto_fit_nm="5" auto_min_p="0.005" auto_max_p="10" baseline_clicks="0" auto_left_baseline="20" auto_right_baseline="20" force_multiplier="1" fc_showphase="0" fc_showimposed="0" fc_interesting="0" tccd_threshold="0" tccd_coincident="0" centerzero="1"/>\r
 \r
 <!-- \r
 The following section defines your own work directory. Substitute your work directory.\r
@@ -66,7 +66,8 @@ and -IMPORTANTLY- their order.
     <multiplier/>\r
     <clamp/>\r
     <threshold/>\r
-    <coincident/>\r
+    <coincident/>
+    <centerzero/>\r
 </plotmanips>\r
 \r
 </config>\r
index f1cc0a31230fdc3c4caafccd7236c9ac4d869de6..0b2b9bd964c21003d2619b08662558f1b2ff5834 100755 (executable)
@@ -156,6 +156,41 @@ class procplotsCommands:
         plot.vectors[1][0]=[(zpoint-deflpoint) for zpoint,deflpoint in zip(plot.vectors[1][0],defl_ret)]
 
         return plot
+
+
+    def plotmanip_centerzero(self, plot, current, customvalue=None):
+        '''
+        Centers the force curve so the median (the free level) corresponds to 0 N
+        Assumes that:
+        - plot.vectors[0][1] is the Y of extension curve
+        - plot.vectors[1][1] is the Y of retraction curve
+        
+       
+        '''
+        #use only for force spectroscopy experiments!
+        if current.curve.experiment != 'smfs':
+            return plot
+    
+        if customvalue != None:
+            execute_me=customvalue
+        else:
+            execute_me=self.config['centerzero']
+        if not execute_me:
+            return plot
+     
+        
+       
+       levelapp=float(np.median(plot.vectors[0][1]))
+       levelret=float(np.median(plot.vectors[1][1]))
+
+       level=(levelapp+levelret)/2     
+
+       approach=[i-level for i in plot.vectors[0][1]]
+       retract=[i-level for i in plot.vectors[1][1]]
+       
+       plot.vectors[0][1]=approach     
+       plot.vectors[1][1]=retract      
+        return plot
     
     '''
     def plotmanip_detriggerize(self, plot, current, customvalue=None):
@@ -248,4 +283,4 @@ class procplotsCommands:
         fftplot.units=['frequency', 'power']
         plot_graph=self.list_of_events['plot_graph']       
         wx.PostEvent(self.frame,plot_graph(plots=[fftplot]))
-        
\ No newline at end of file
+