Merged with trunk
[hooke.git] / hooke / plugin / procplots.py
index b8baa15c12275eee223f772f0b75db809a9e9dfc..b7826aed227cc2499adf0778c9365ddb6db1c24f 100644 (file)
@@ -157,6 +157,41 @@ class procplotsCommands(object):
 
         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][-300:-1]))
+
+       level=levelret  
+
+       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):
         #DEPRECATED