def fitgaussimage(image, xy0, dxy, lam):
    x0 = xy0[0]
    y0 = xy0[1]
    dx = dxy[0]
    dy = dxy[1]
    print(x0, y0, dx, dy)
    data = image[(y0 - dy):(y0 + dy), (x0 - dx):(x0 + dx)]
    (params, success) = m_fun.fit_gaussian_2d(data)
    if (success in [1, 2, 3, 4]):
        (height, x, y, width_x, width_y) = params
        width_x = ((2 * np.sqrt((2 * np.log(2)))) * np.abs(width_x))
        width_y = ((2 * np.sqrt((2 * np.log(2)))) * np.abs(width_y))
        x = ((x + y0) - dy)
        y = ((y + x0) - dx)
        xyw = (y, x, width_y, width_x, lam)
        return xyw
    else:
        return (0, 0, 0, 0, 0)
def fitgaussimage(image, xy0, dxy, lam):
    x0 = xy0[0]
    y0 = xy0[1]
    dx = dxy[0]
    dy = dxy[1]
    print(x0, y0, dx, dy)
    data = image[(y0 - dy):(y0 + dy), (x0 - dx):(x0 + dx)]
    (params, success) = m_fun.fit_gaussian_2d(data)
    if (success in [1, 2, 3, 4]):
        (height, x, y, width_x, width_y) = params
        width_x = ((2 * np.sqrt((2 * np.log(2)))) * np.abs(width_x))
        width_y = ((2 * np.sqrt((2 * np.log(2)))) * np.abs(width_y))
        x = ((x + y0) - dy)
        y = ((y + x0) - dx)
        xyw = (y, x, width_y, width_x, lam)
        return xyw
    else:
        return (0, 0, 0, 0, 0)