+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
'''
generalvclamp.py
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])
- self.outlet.push(to_dump)
-
+
# Makes a vector with the fitted parameters and sends it to the GUI
xtoplot=parameters[2]
ytoplot=[]
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):
'''