def METHOD_NAME(interpolator, md, roiSize=5):
    global sintheta, costheta, calibrated, _svr, _cal_images
    _cal_images = []
    #global zvals, dWidth
    #generate grid to evaluate function on
    X, Y, Z, safeRegion = interpolator.getCoords(md, slice(-roiSize,roiSize), slice(-roiSize,roiSize), slice(0, 2))
    #print Z, safeRegion
    axialShift = md.getOrDefault('Analysis.AxialShift', 0)
    ratio = 0.5#md.Analysis.ColourRatio
    if len(X.shape) > 1: #X is a matrix
        X_ = X[:, 0, 0]
        Y_ = Y[0, :, 0]
    else:
        X_ = X
        Y_ = Y
    zmin, zmax  = safeRegion[2]
    #print zmin, zmax
    zmin = max(zmin, zmin - axialShift)
    zmax = min(zmax, zmax - axialShift)
    #print zmin, zmax
    z = numpy.arange(max(-800, zmin), min(800, zmax), 10)
    ps = []
    ps1 = []
    dx = 1 * 70 * np.random.normal(size=len(z))
    dy = 1 * 70 * np.random.normal(size=len(z))
    #print axialShift
    for x0, y0, z0 in zip(dx, dy, z):
        d1 = ratio*interpolator.interp(X + x0, Y + y0, Z + z0)
        if interpolator.SplitPSF:
            d2 = (1-ratio)*interpolator.interp(X + interpolator.PSF2Offset + x0, Y + y0, Z + z0 + axialShift)
        else:
            d2 = (1-ratio)*interpolator.interp(X + x0, Y + y0, Z + z0 + axialShift)
        im = numpy.concatenate([numpy.atleast_3d(d1), numpy.atleast_3d(d2)], 2)
        ps1.append(_calcParams(im, X_, Y_))
        #add noise
        im =  np.random.poisson(2+ (2000 + np.random.exponential(1000))*im)
        ps.append(_calcParams(im, X_, Y_))
        _cal_images.append(im)
        #ps.append(_calcParams(numpy.concatenate([numpy.atleast_3d(d1), numpy.atleast_3d(d2)], 2), X_, Y_))
    ps = numpy.array(ps).T
    ps1 = np.array(ps1).T
    xp, yp =  ps1[:2, :]
    A = ps[2:4]
    feat = ps[4:]
    rawMeas['feat'] = feat
    rawMeas['z'] = z
    rawMeas['xp'] = xp + dx
    rawMeas['yp'] = yp + dy
    _svr = svm.SVR(C=1000)
    _svr.fit(feat.T, z)
    sp, u = splprep([xp], u=z, s=1)
    splines['xp'] = sp
    sp, u = splprep([yp], u=z, s=1)
    splines['yp'] = sp
    splines['z'] = True
    if DEBUG_PLOTS:
        #print feat.shape
        import matplotlib.pyplot as plt
        plt.figure(figsize=(5, 10))
        n_feats = feat.shape[0]
        for i in range(n_feats):
            plt.subplot(n_feats, 1, i+1)
            plt.plot(z, feat[i, :])