From: W. Trevor King Date: Fri, 19 Mar 2010 13:22:44 +0000 (-0400) Subject: Don't turn on PYLAB_VERBOSE by default (in case DISPLAY is not set) X-Git-Tag: 0.2^0 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f8ded66b801c100fc51c45191670c545b081c457;p=pypiezo.git Don't turn on PYLAB_VERBOSE by default (in case DISPLAY is not set) Pull bilinear definition out of analyzeSurfPosData. --- diff --git a/piezo/z_piezo_utils.py b/piezo/z_piezo_utils.py index 7d48802..29002e3 100644 --- a/piezo/z_piezo_utils.py +++ b/piezo/z_piezo_utils.py @@ -1,6 +1,6 @@ TEXT_VERBOSE = False PYLAB_INTERACTIVE = True -PYLAB_VERBOSE = True +PYLAB_VERBOSE = False BASE_FIG_NUM = 60 LOG_DATA = True LOG_DIR = '$DEFAULT$/z_piezo_utils' @@ -226,6 +226,19 @@ def getSurfPosData(zpiezo, maxDefl, textVerbose=False, plotVerbose=False) : return {"ret1":ret1, "mtpod":mtpod, "ret2":ret2, "approach":data, "ret3":ret3} +def bilinear(x, params): + """bilinear fit for surface bumps. Model has two linear regimes + which meet at x=kink_position and have independent slopes. + """ + assert type(x) == type(array([0,1])), "Invalid x array: %s" % type(x) + left_offset,left_slope,kink_position,right_slope = params + left_mask = x < kink_position + right_mask = x >= kink_position # = not left_mask + left_y = left_offset + left_slope*x + right_y = left_offset + left_slope*kink_position \ + + right_slope*(x-kink_position) + return left_mask * left_y + right_mask * right_y + def analyzeSurfPosData(ddict, textVerbose=False, plotVerbose=False, retAllParams=False) : # ususes ddict["approach"] for analysis # the others are just along to be plotted @@ -258,13 +271,6 @@ def analyzeSurfPosData(ddict, textVerbose=False, plotVerbose=False, retAllParams if TEXT_VERBOSE or textVerbose : print "start Def %d, final def %d, start pos %d, final pos %d" % (startDef, finalDef, startPos, finalPos) print "Guessed params ", pstart - def bilinear(x, params): - left_offset,left_slope,kink_position,right_slope = params - if x < kink_position: - y = left_offset + left_slope*x - else: - y = left_offset + left_slope*kink_position \ - + right_slope*(x-kink_position) def residual(p, y, x): Y = bilinear(x, p) return Y-y