-'''
-generalvclamp.py
-
-Plugin regarding general velocity clamp measurements
-'''
-
-from libhooke import WX_GOOD, ClickedPoint
+# Copyright (C) 2008-2010 Alberto Gomez-Casado
+# Fabrizio Benedetti
+# Marco Brucale
+# 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/>.
+
+"""Plugin regarding general velocity clamp measurements
+"""
+
+from hooke.libhooke import WX_GOOD, ClickedPoint
import wxversion
wxversion.select(WX_GOOD)
from wx import PostEvent
print str(forcebase*(10**12))+' pN'
to_dump='forcebase '+self.current.path+' '+str(forcebase*(10**12))+' pN'
self.outlet.push(to_dump)
-\r
+
def plotmanip_multiplier(self, plot, current):
'''
- Multiplies all the Y values of an SMFS curve by a value stored in the 'force_multiplier'\r
+ Multiplies all the Y values of an SMFS curve by a value stored in the 'force_multiplier'
configuration variable. Useful for calibrations and other stuff.
'''
#multiplier is 1...
if (self.config['force_multiplier']==1):
- return plot\r
-\r
+ return plot
+
for i in range(len(plot.vectors[0][1])):
- plot.vectors[0][1][i]=plot.vectors[0][1][i]*self.config['force_multiplier'] \r
-\r
- for i in range(len(plot.vectors[1][1])):
- plot.vectors[1][1][i]=plot.vectors[1][1][i]*self.config['force_multiplier']\r
-\r
- return plot \r
+ plot.vectors[0][1][i]=plot.vectors[0][1][i]*self.config['force_multiplier']
+ for i in range(len(plot.vectors[1][1])):
+ plot.vectors[1][1][i]=plot.vectors[1][1][i]*self.config['force_multiplier']
+ return plot
+
+
def plotmanip_flatten(self, plot, current, customvalue=False):
'''
Subtracts a polynomial fit to the non-contact part of the curve, as to flatten it.
valn=[[] for item in range(max_exponent)]
yrn=[0.0 for item in range(max_exponent)]
errn=[0.0 for item in range(max_exponent)]
-
+
+ #Check if we have a proper numerical value
+ try:
+ zzz=int(max_cycles)
+ except:
+ #Loudly and annoyingly complain if it's not a number, then fallback to zero
+ print '''Warning: flatten value is not a number!
+ Use "set flatten" or edit hooke.conf to set it properly
+ Using zero.'''
+ max_cycles=0
+
for i in range(int(max_cycles)):
x_ext=plot.vectors[0][0][contact_index+delta_contact:]
if fitspan == 0:
# Gets the Xs of two clicked points as indexes on the current curve vector
print 'Click twice to delimit chunk'
- clickedpoints=[]
points=self._measure_N_points(N=2,whatset=1)
- clickedpoints=[points[0].index,points[1].index]
- clickedpoints.sort()
else:
print 'Click once on the leftmost point of the chunk (i.e.usually the peak)'
- clickedpoints=[]
points=self._measure_N_points(N=1,whatset=1)
- clickedpoints=[points[0].index-fitspan,points[0].index]
+
+ slope=self._slope(points,fitspan)
- # Calls the function linefit_between
+ # Outputs the relevant slope parameter
+ print 'Slope:'
+ print str(slope)
+ to_dump='slope '+self.current.path+' '+str(slope)
+ self.outlet.push(to_dump)
+
+ def _slope(self,points,fitspan):
+ # Calls the function linefit_between
parameters=[0,0,[],[]]
+ try:
+ clickedpoints=[points[0].index,points[1].index]
+ clickedpoints.sort()
+ except:
+ clickedpoints=[points[0].index-fitspan,points[0].index]
+
try:
parameters=self.linefit_between(clickedpoints[0],clickedpoints[1])
except:
print 'Cannot fit. Did you click twice the same point?'
return
-
+
# Outputs the relevant slope parameter
print 'Slope:'
print str(parameters[0])
- to_dump='slope '+self.current.path+' '+str(parameters[0])
+ to_dump='slope '+self.curve.path+' '+str(parameters[0])
self.outlet.push(to_dump)
# Makes a vector with the fitted parameters and sends it to the GUI
else:
lineplot.styles+=[None,'scatter']
if lineplot.colors==[]:
- lineplot.styles=[None,None,None,None]
+ lineplot.colors=[None,None,'black',None]
else:
- lineplot.colors+=[None,None]
+ lineplot.colors+=['black',None]
+
+
+ self._send_plot([lineplot])
+ return parameters[0]
- self._send_plot([lineplot])
def linefit_between(self,index1,index2,whatset=1):
'''