# Path: tecs/sat/datum.py
# C20 = -1082.63e-6


import datetime
from math import sin, cos, atan2, sqrt
from tecs.sat import datum
    elif tk < -302400:
        tk += 604800

    n = sqrt(datum.mu / a0 ** 3) + dn
    mk = m0 + n * tk

    ek = mk
    ek_1 = ek + 1

    prv_d_ek = 0
    cur_d_ek = 1
    #   while ( abs(ek-ek_1) > e_ps ):
    while prv_d_ek != cur_d_ek:
        prv_d_ek = abs(ek - ek_1)
        ek_1 = ek
        ek = ek_1 - (ek_1 - e0 * sin(ek_1) - mk) / (1 - e0 * cos(ek_1))
        cur_d_ek = abs(ek - ek_1)
        # print prv_d_ek, cur_d_ek

    fs = (sqrt(1 - e0 ** 2) * sin(ek)) / (1 - e0 * cos(ek))
    fc = (cos(ek) - e0) / (1 - e0 * cos(ek))
    tettak = atan2(fs, fc)

    u0k = tettak + w0
    uk = u0k + cuc * cos(2 * u0k) + cus * sin(2 * u0k)

    rk = a0 * (1 + e0 * cos(ek)) + crc * cos(2 * u0k) + crs * sin(2 * u0k)

    ik = i0 + (cic * cos(2 * u0k) + cis * sin(2 * u0k)) + i_dot * tk


# Path: tecs/sat/datum.py
# C20 = -1082.63e-6


# Path: tecs/sat/gps.py
import datetime
from math import sin, cos, atan2, sqrt
from tecs.sat import datum

    elif tk < -302400:
        tk += 604800

    n = sqrt(datum.mu / a0 ** 3) + dn
    mk = m0 + n * tk

    ek = mk
    ek_1 = ek + 1

    prv_d_ek = 0
    cur_d_ek = 1
    #   while ( abs(ek-ek_1) > e_ps ):
    while prv_d_ek != cur_d_ek:
        prv_d_ek = abs(ek - ek_1)
        ek_1 = ek
        ek = ek_1 - (ek_1 - e0 * sin(ek_1) - mk) / (1 - e0 * cos(ek_1))
        cur_d_ek = abs(ek - ek_1)
        # print prv_d_ek, cur_d_ek

    fs = (sqrt(1 - e0 ** 2) * sin(ek)) / (1 - e0 * cos(ek))
    fc = (cos(ek) - e0) / (1 - e0 * cos(ek))
    tettak = atan2(fs, fc)

    u0k = tettak + w0
    uk = u0k + cuc * cos(2 * u0k) + cus * sin(2 * u0k)

    rk = a0 * (1 + e0 * cos(ek)) + crc * cos(2 * u0k) + crs * sin(2 * u0k)

    ik = i0 + (cic * cos(2 * u0k) + cis * sin(2 * u0k)) + i_dot * tk


    omega_k = omega_0 + (omega_dot - datum.omega) * tk - datum.omega * toe