From ae55285a7ce3c42d2d94e1fecf2e1d11d9e79cb9 Mon Sep 17 00:00:00 2001 From: devicerandom Date: Wed, 10 Feb 2010 21:04:56 +0000 Subject: [PATCH] (generalvclamp.py) Error checking in flatten plot manipulator - fixes issue 31 --- generalvclamp.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/generalvclamp.py b/generalvclamp.py index 1c71de0..85a4bce 100644 --- a/generalvclamp.py +++ b/generalvclamp.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: iso-8859-1 -*- ''' generalvclamp.py @@ -120,10 +121,10 @@ class generalvclampCommands: print str(forcebase*(10**12))+' pN' to_dump='forcebase '+self.current.path+' '+str(forcebase*(10**12))+' pN' self.outlet.push(to_dump) - + def plotmanip_multiplier(self, plot, current): ''' - Multiplies all the Y values of an SMFS curve by a value stored in the 'force_multiplier' + 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. ''' @@ -137,15 +138,15 @@ class generalvclampCommands: #multiplier is 1... if (self.config['force_multiplier']==1): - return plot - + 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'] - + 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 + plot.vectors[1][1][i]=plot.vectors[1][1][i]*self.config['force_multiplier'] + + return plot def plotmanip_flatten(self, plot, current, customvalue=False): @@ -183,6 +184,16 @@ class generalvclampCommands: 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:] -- 2.26.2