From f8ded66b801c100fc51c45191670c545b081c457 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 19 Mar 2010 09:22:44 -0400 Subject: [PATCH] Don't turn on PYLAB_VERBOSE by default (in case DISPLAY is not set) Pull bilinear definition out of analyzeSurfPosData. --- piezo/z_piezo_utils.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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 -- 2.26.2