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'
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
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