def moments(data):
    'Returns (height, x, y, width_x, width_y)\n    the gaussian parameters of a 2D distribution by calculating its\n    moments '
    height = data.max()
    background = data.min()
    data = (data - np.min(data))
    total = data.sum()
    (x, y) = np.indices(data.shape)
    x = ((x * data).sum() / total)
    y = ((y * data).sum() / total)
    col = data[:, int(y)]
    width_x = np.sqrt((abs((((np.arange(col.size) - y) ** 2) * col)).sum() / col.sum()))
    row = data[int(x), :]
    width_y = np.sqrt((abs((((np.arange(row.size) - x) ** 2) * row)).sum() / row.sum()))
    width_x /= gaussian_sigma_to_fwhm
    width_y /= gaussian_sigma_to_fwhm
    return (height, x, y, width_x, width_y, 0.0, background)
Returns (height, x, y, width_x, width_y)
the gaussian parameters of a 2D distribution by calculating its
moments
def moments(data):
    'Returns (height, x, y, width_x, width_y)\n    the gaussian parameters of a 2D distribution by calculating its\n    moments '
    height = data.max()
    background = data.min()
    data = (data - np.min(data))
    total = data.sum()
    (x, y) = np.indices(data.shape)
    x = ((x * data).sum() / total)
    y = ((y * data).sum() / total)
    col = data[:, int(y)]
    width_x = np.sqrt((abs((((np.arange(col.size) - y) ** 2) * col)).sum() / col.sum()))
    row = data[int(x), :]
    width_y = np.sqrt((abs((((np.arange(row.size) - x) ** 2) * row)).sum() / row.sum()))
    width_x /= gaussian_sigma_to_fwhm
    width_y /= gaussian_sigma_to_fwhm
    return (height, x, y, width_x, width_y, 0.0, background)