def find_bbox(thresh, g):
    """Calculate bounding box for gaussian.

    This function calculates size of the box for evaluating
    gaussian, so that value of gaussian is smaller than threshold
    outside of the box.

    Parameters:
    thres: threshold
    g: Gaussian object or list of paramters
    """
    from math import ceil, sqrt, log
    if isinstance(g, list):
        A = g[0]
        S = g[3]
    else:
        A = g.peak_flux
        S = g.size_pix[0]
    if A == 0.0:
        return ceil(S * 1.5)
    if thresh / A >= 1.0 or thresh / A <= 0.0:
        return ceil(S * 1.5)
    return ceil(S * sqrt(-2 * log(thresh / A)))
