Beispiel #1
0
    def test_eccentric2mean(self):
        E = n.linspace(0, 2.0 * n.pi, num=100, dtype=n.float)
        M = dpt.eccentric2mean(E, 0.0)
        nt.assert_array_almost_equal(E, M, decimal=7)

        e = n.linspace(0, 0.9, num=100, dtype=n.float)
        M = dpt.eccentric2mean(n.pi, e)
        M0 = n.ones(e.shape, dtype=n.float) * n.pi
        nt.assert_array_almost_equal(M0, M, decimal=7)
Beispiel #2
0
    def test_mean_eccentric_inverse_float(self):
        M = n.linspace(0.0, 2.0 * n.pi, num=100, dtype=n.float)
        e = n.linspace(0, 0.99, num=100, dtype=n.float)

        for eit in e:
            for Mit in M:
                E_test = dpt.mean2eccentric(Mit, eit)
                M_test = dpt.eccentric2mean(E_test, eit)
                nt.assert_almost_equal(M_test, Mit, decimal=7)
Beispiel #3
0
    def test_mean_eccentric_inverse_array(self):
        M = n.linspace(0.0, 2.0 * n.pi, num=100, dtype=n.float)
        e = n.linspace(0, 0.99, num=100, dtype=n.float)

        Mv, ev = n.meshgrid(M, e)

        E_test = dpt.mean2eccentric(Mv, ev)
        M_test = dpt.eccentric2mean(E_test, ev)
        nt.assert_array_almost_equal(M_test, Mv, decimal=7)
Beispiel #4
0
    def test_kepler_guess(self):
        E = n.linspace(0.0, 2.0 * n.pi, num=100, dtype=n.float)
        e = n.linspace(0, 0.99, num=100, dtype=n.float)

        Ev, ev = n.meshgrid(E, e)

        Mv = dpt.eccentric2mean(Ev, ev)

        E0 = dpt.kepler_guess(Mv, ev)

        #the initial guess SHOULD be at least 30 degrees to true
        test_accuracy = n.abs(E0 - Ev) * 180.0 / n.pi < 30.0
        nt.assert_array_equal(test_accuracy, n.full(test_accuracy.shape, True))
Beispiel #5
0
    def test_laguerre_solve_kepler(self):
        E = n.linspace(0.0, 2.0 * n.pi, num=300, dtype=n.float)
        e = n.linspace(0, 0.99, num=500, dtype=n.float)

        for I, eit in enumerate(e):
            for J, Eit in enumerate(E):
                M = dpt.eccentric2mean(Eit, eit)

                E0 = dpt.kepler_guess(M, eit)
                E_calc, it = dpt.laguerre_solve_kepler(E0, M, eit, tol=1e-12)
                fun_err = n.abs(M - E_calc + eit * n.sin(E_calc))

                nt.assert_almost_equal(Eit, E_calc, decimal=1e-9)
                assert fun_err < 1e-11
Beispiel #6
0
import numpy as n
import dpt_tools as dpt

import matplotlib.pyplot as plt

E = n.linspace(0.0, 2.0 * n.pi, num=100, dtype=n.float)
e = n.linspace(0, 0.99, num=100, dtype=n.float)

Ev, ev = n.meshgrid(E, e)

Mv = dpt.eccentric2mean(Ev, ev)

E0 = dpt.kepler_guess(Mv, ev)

fig, ax = plt.subplots()
CS = ax.contour(Ev * 180.0 / n.pi, ev, n.abs(Ev - E0) * 180.0 / n.pi)
ax.clabel(CS, inline=1, fontsize=10)
ax.set_xlabel('E [deg]')
ax.set_ylabel('e')

E = n.linspace(1.7, 2.7, num=500, dtype=n.float)
e = n.linspace(0.8, 0.99, num=500, dtype=n.float)

Ev, ev = n.meshgrid(E, e)

Mv = dpt.eccentric2mean(Ev, ev)

E0 = dpt.kepler_guess(Mv, ev)

fig, ax = plt.subplots()
CS = ax.contour(Ev * 180.0 / n.pi, ev, n.abs(Ev - E0) * 180.0 / n.pi)
Beispiel #7
0
import numpy as n
import dpt_tools as dpt
import matplotlib.pyplot as plt

E = n.linspace(0.0, 2.0 * n.pi, num=300, dtype=n.float)
e = n.linspace(0, 0.99, num=500, dtype=n.float)

Ev, ev = n.meshgrid(E, e)
Mv = dpt.eccentric2mean(Ev, ev)

it_num = n.empty(Mv.shape, dtype=n.int)
err = n.empty(Mv.shape, dtype=n.float)
f_eval = n.empty(Mv.shape, dtype=n.float)

for I, eit in enumerate(e):
    for J, Eit in enumerate(E):
        M = dpt.eccentric2mean(Eit, eit)

        E0 = dpt.kepler_guess(M, eit)
        E_calc, it = dpt.laguerre_solve_kepler(E0, M, eit, tol=1e-12)

        f_eval[I, J] = n.abs(M - E_calc + eit * n.sin(E_calc))
        it_num[I, J] = it
        err[I, J] = n.abs(Eit - E_calc)

fig, ax = plt.subplots()
CS = ax.contour(Ev * 180.0 / n.pi, ev, err * 180.0 / n.pi)
ax.clabel(CS, inline=1, fontsize=10)
ax.set_xlabel('E [deg]')
ax.set_ylabel('e')