def ellipse_nest(im, i_deg, phi_deg, r=None, tau=None):
    Ys = im[0]
    Xs = im[1]
    # http://www.maa.org/external_archive/joma/Volume8/Kalman/General.html

    # im[0],im[1] are points in the sky plane that we transform to the ring plane
    # ellipse projection will occur automatically
    (Xr, Yr, ellipse) = sky_to_ring(Xs, Ys, 90.-i_deg, phi_deg)

    # in ring space, the tangent of a circle on point (X,Y) is (Y,-X)
    (Xs_tang, Ys_tang, ellipse2) = ring_to_sky(Yr, -Xr, 90.-i_deg, phi_deg)

    tan_out = np.arctan2(Ys_tang, Xs_tang)

    im_out = ellipse

    if r is not None:
        im_out = np.zeros_like(Xs) + 0.0
        r_inner = 0.0
        # loop from smallest r to biggest r
        for r_outer, curr_tau in zip(r, tau):
            sel = (ellipse >= r_inner) * (ellipse < r_outer)
            im_out[np.where(sel)] = curr_tau

            # must be last line in r_outer loop
            r_inner = r_outer

    return(im_out, tan_out)
Read header lines.
dataset/ETHPy150Open mkenworthy/exorings/exorings.py/ellipse_nest--crossover with--dataset/ETHPy150Open ofermend/medicare-demo/socialite/jython/Lib/rfc822.py/Message.readheaders