def calc_ring_stats(taun, t, f, f_err, rad_ri, re, k, dst, tmin, tmax):
    'full statistics function for ring fit to photometric data'
    # convolve and make smoothed ring photometry
    strip, dummy, g = exorings.ellipse_strip(rad_ri, \
        exorings.y_to_tau(taun), re[0], re[1], re[2], re[3], k, dst)

    # select points within the rings_tmin/tmax range
    mask = (t > tmin) * (t < tmax)
    t_sel = t[mask]
    f_sel = f[mask]
    f_err_sel = f_err[mask]

    print '%d points in time range %.2f to %.2f' % (t_sel.size, tmin, tmax)

    # interpolate the smoothed curve....
    ring_model = interp1d(g[0], g[1], kind='linear')

    # ... to the times of the photometry
    ring_model_phot = ring_model(t_sel)

    # calculate the residuals and the chi squared
    diff = f_sel - ring_model_phot

    chisq = np.sum(np.power(diff/f_err_sel, 2))
    # degrees of freedom = number of photometry points - number of ring edges - 1
    dof = taun.size - 1 - diff.size
    red_chisq = chisq / dof
    print 'number of photometric = %d ' % diff.size
    print 'number of ring edges  = %d ' % taun.size
    print 'number of DOF         = %d ' % dof
    print 'chi squared           = %.2f' % chisq
    print ' reduced chi squared  = %.2f' % red_chisq

    # http://en.wikipedia.org/wiki/Bayesian_information_criterion
    # n - number of points in data
    # k - number of free parameters
    # BIC = chisquared + k . ln(n) + C
    # C is a constant which does not change between candidate models but is
    # dependent on the data points

    BIC = chisq + (taun.size) * np.log(diff.size)
    print ' BIC                  = %.2f' % BIC
    return red_chisq
dataset/ETHPy150Open mkenworthy/exorings/disk_sim.py/calc_ring_stats/swapped operands of `-`