def analyze(data): """ Do all the analysis that's needed to create the interface """ prepared, centre = preparedata(data) xx, yy, dx, dy, angle = fastfit.d4s(prepared) xx += centre[0] yy += centre[1] xr, yr = fastfit.getellipse(xx, yy, dx, dy, angle) # fix axes calculation so no more -1 is needed angle *= -1 adeg = "%.1f deg" %(angle / np.pi * 180) xxx = [xx - dx/2*np.cos(angle), xx + dx/2*np.cos(angle)] xxy = [yy + dx/2*np.sin(angle), yy - dx/2*np.sin(angle)] yyx = [xx + dy/2*np.sin(angle), xx - dy/2*np.sin(angle)] yyy = [yy + dy/2*np.cos(angle), yy - dy/2*np.cos(angle)] xwidth = (dx*np.cos(angle)**2 + dy*np.sin(angle)**2)/4.0 ywidth = (dx*np.sin(angle)**2 + dy*np.cos(angle)**2)/4.0 try: xc = int(np.round(xx)) yc = int(np.round(yy)) except ValueError: xc = 320 yc = 240 sy, sx = data.shape xcut = data[yc, :] ycut = data[:, xc] xline = range(0, sx) yline = range(0, sy) xcutg = gauss(xline, xx, xwidth, max(xcut)) ycutg = gauss(yline, yy, ywidth, max(ycut)) return (xx, yy, dx, dy, angle, xr, yr, adeg, xxx, xxy, yyx, yyy, xwidth, ywidth, xc, yc, xcut, ycut, xcutg, ycutg)
def analyze(data): """ Do all the analysis that's needed to create the interface """ prepared, centre = interface.preparedata(data) xx, yy, dx, dy, angle = fastfit.d4s(prepared) xx += centre[0] yy += centre[1] try: outparams = gaussfit.fitgaussian(prepared) # Order somehow changed between x and y if outparams is None: return None (a, y, x, ddy, ddx, angle, b) = outparams dx = 4*ddx dy = 4*ddy print "Gaussian fit" except (ValueError): print "D4s fit" pass xr, yr = fastfit.getellipse(xx, yy, dx, dy, angle) # fix axes calculation so no more -1 is needed angle *= -1 adeg = "%.1f deg" %(angle / np.pi * 180) xxx = [xx - dx/2*np.cos(angle), xx + dx/2*np.cos(angle)] xxy = [yy + dx/2*np.sin(angle), yy - dx/2*np.sin(angle)] yyx = [xx + dy/2*np.sin(angle), xx - dy/2*np.sin(angle)] yyy = [yy + dy/2*np.cos(angle), yy - dy/2*np.cos(angle)] xwidth = (dx*np.cos(angle)**2 + dy*np.sin(angle)**2)/4.0 ywidth = (dx*np.sin(angle)**2 + dy*np.cos(angle)**2)/4.0 try: xc = int(np.round(xx)) yc = int(np.round(yy)) except ValueError: xc = 320 yc = 240 xcut = data[yc, :] ycut = data[:, xc] xline = range(0, sx) yline = range(0, sy) xcutg = gauss(xline, xx, xwidth, max(xcut)) ycutg = gauss(yline, yy, ywidth, max(ycut)) return (xx, yy, dx, dy, angle, xr, yr, adeg, xxx, xxy, yyx, yyy, xwidth, ywidth, xc, yc, xcut, ycut, xcutg, ycutg)