def sigma_clipping(date, mag, err, threshold=3, iteration=1):

    # Check length.
    if (len(date) != len(mag)) \
        or (len(date) != len(err)) \
        or (len(mag) != len(err)):
        raise RuntimeError('The length of date, mag, and err must be same.')

    # By magnitudes
    for i in range(int(iteration)):
        mean = np.median(mag)
        std = np.std(mag)

        index = (mag >= mean - threshold*std) & (mag <= mean + threshold*std)
        date = date[index]
        mag = mag[index]
        err = err[index]

    return date, mag, err
Remove any fluctuated data points by magnitudes.
dataset/ETHPy150Open dwkim78/upsilon/upsilon/utils/utils.py/sigma_clipping