Ran update_copyright.py, updating all the copyright blurbs and adding AUTHORS.
[hooke.git] / hooke / plugin / procplots.py
old mode 100755 (executable)
new mode 100644 (file)
index 612ae0b..3868a83
@@ -1,20 +1,39 @@
-'''
-PROCPLOTS
-Processed plots plugin for force curves.
-
-Licensed under the GNU GPL version 2
-'''
-from libhooke import WX_GOOD
+# Copyright (C) 2008-2010 Alberto Gomez-Casado
+#                         Massimo Sandal <devicerandom@gmail.com>
+#                         W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation, either
+# version 3 of the License, or (at your option) any later version.
+#
+# Hooke is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+"""Processed plots plugin for force curves.
+"""
+
+from ..libhooke import WX_GOOD
 import wxversion
 wxversion.select(WX_GOOD)
 
 import wx
-import libhookecurve as lhc
 import numpy as np
 import scipy as sp
 import scipy.signal
 import copy
 
+from .. import curve as lhc
+
+
 class procplotsCommands(object):
 
     def _plug_init(self):
@@ -51,7 +70,7 @@ class procplotsCommands(object):
 
         return dplot
 
-    def do_subtplot(self,args):
+    def do_subtplot(self, args):
         '''
         SUBTPLOT
         (procplots.py plugin)
@@ -155,6 +174,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