def test_nu2anom_zero(): """ Make sure that at zero nu=E=M """ M_true = 0.0 ecc = 1.2 E_true = 0.0 nu_true = 0.0 E_python, M_python = kepler.nu2anom(nu_true,ecc) np.testing.assert_allclose((E_python, M_python),(E_true,M_true))
def test_nu2anom_zero(): """ Make sure that at zero nu=E=M """ M_true = 0.0 ecc = 1.2 E_true = 0.0 nu_true = 0.0 E_python, M_python = kepler.nu2anom(nu_true,ecc) np.testing.assert_allclose((E_python, M_python),(E_true,M_true))
def test_nu2anom_pi(): """ Make sure that at pi nu=E=M """ M_true = np.pi ecc = 0.9 E_true = np.pi nu_true = np.pi E_python, M_python = kepler.nu2anom(nu_true,ecc) np.testing.assert_allclose(E_python, E_true) np.testing.assert_allclose(M_python, M_true)
def test_nu2anom(): """ A matlab test case which is copied here """ M_matlab = np.deg2rad(110) ecc = 0.9 E_matlab = 2.475786297687611 nu_matlab = 2.983273149717047 E_python, M_python = kepler.nu2anom(nu_matlab,ecc) np.testing.assert_allclose(E_python, E_matlab) np.testing.assert_allclose(M_python, M_matlab)
def test_nu2anom_pi(): """ Make sure that at pi nu=E=M """ M_true = np.pi ecc = 0.9 E_true = np.pi nu_true = np.pi E_python, M_python = kepler.nu2anom(nu_true,ecc) np.testing.assert_allclose(E_python, E_true) np.testing.assert_allclose(M_python, M_true)
def test_nu2anom(): """ A matlab test case which is copied here """ M_matlab = np.deg2rad(110) ecc = 0.9 E_matlab = 2.475786297687611 nu_matlab = 2.983273149717047 E_python, M_python = kepler.nu2anom(nu_matlab,ecc) np.testing.assert_allclose(E_python, E_matlab) np.testing.assert_allclose(M_python, M_matlab)
def test_m(self): E_true, M_true = kepler.nu2anom(self.nu, self.ecc) np.testing.assert_allclose(self.m, M_true)
def test_m(self): E_true, M_true = kepler.nu2anom(self.nu, self.ecc) np.testing.assert_allclose(self.m, M_true)
def tle_update(self, jd_span, mu=398600.5): """Update the state of satellite given a JD time span This procedure uses the method of general perturbations to update classical elements from epoch to a future time for inclined elliptical orbits. It includes the effects due to first order secular rates (second order for mean motion) caused by drag and J2. Author: C2C Shankar Kulumani USAFA/CS-19 719-333-4741 Inputs: deltat - elapsed time since epoch (sec) n0 - mean motion at epoch (rad/sec) ndot2 - mean motion rate divided by 2 (rad/sec^2) ecc0 - eccentricity at epoch (unitless) eccdot - eccentricity rate (1/sec) raan0 - RAAN at epoch (rad) raandot - RAAN rate (rad/sec) argp0 - argument of periapsis at epoch (rad) argdot - argument of periapsis rate (rad/sec) mean0 - mean anomaly at epoch Outputs: n - mean motion at epoch + deltat (rad/sec) ecc - eccentricity at epoch + deltat (unitless) raan - RAAN at epoch + deltat (rad) argp - argument of periapsis at epoch + deltat (rad) nu - true anomaly at epoch + deltat (rad) Globals: None Constants: None Coupling: newton.m References: Astro 321 PREDICT LSN 24-25 """ deltat = (jd_span - self.epoch_jd) * day2sec # epoch orbit parameters n0 = self.n0 ecc0 = self.ecc0 ndot2 = self.ndot2 nddot6 = self.nddot6 raan0 = self.raan0 argp0 = self.argp0 mean0 = self.mean0 inc0 = self.inc0 adot = self.adot eccdot = self.eccdot raandot = self.raandot argpdot = self.argpdot _, nu0, _ = kepler.kepler_eq_E(mean0, ecc0) a0 = kepler.n2a(n0, mu) M0, E0 = kepler.nu2anom(nu0, ecc0) # propogated elements a1 = a0 + adot * deltat # either use this or compute a1 from n1 instead ecc1 = ecc0 + eccdot * deltat raan1 = raan0 + raandot * deltat argp1 = argp0 + argpdot * deltat inc1 = inc0 * np.ones_like(ecc1) n1 = n0 + ndot2 * 2 * deltat # a1 = kepler.n2a(n1, mu) p1 = kepler.semilatus_rectum(a1, ecc1) M1 = M0 + n0 * deltat+ ndot2 *deltat**2 + nddot6 *deltat**3 M1 = attitude.normalize(M1, 0, 2 * np.pi) E1, nu1, _ = kepler.kepler_eq_E(M1, ecc1) # convert to vectors r_eci, v_eci, _, _ = kepler.coe2rv(p1, ecc1, inc1, raan1, argp1, nu1, mu) # save all of the variables to the object self.jd_span = jd_span self.coe = COE(n=n1, ecc=ecc1, raan=raan1, argp=argp1, mean=M1, E=E1, nu=nu1, a=a1, p=p1, inc=inc1) self.r_eci = r_eci self.v_eci = v_eci return 0
def tle_update(self, jd_span, mu=398600.5): """Update the state of satellite given a JD time span This procedure uses the method of general perturbations to update classical elements from epoch to a future time for inclined elliptical orbits. It includes the effects due to first order secular rates (second order for mean motion) caused by drag and J2. Author: C2C Shankar Kulumani USAFA/CS-19 719-333-4741 Inputs: deltat - elapsed time since epoch (sec) n0 - mean motion at epoch (rad/sec) ndot2 - mean motion rate divided by 2 (rad/sec^2) ecc0 - eccentricity at epoch (unitless) eccdot - eccentricity rate (1/sec) raan0 - RAAN at epoch (rad) raandot - RAAN rate (rad/sec) argp0 - argument of periapsis at epoch (rad) argdot - argument of periapsis rate (rad/sec) mean0 - mean anomaly at epoch Outputs: n - mean motion at epoch + deltat (rad/sec) ecc - eccentricity at epoch + deltat (unitless) raan - RAAN at epoch + deltat (rad) argp - argument of periapsis at epoch + deltat (rad) nu - true anomaly at epoch + deltat (rad) Globals: None Constants: None Coupling: newton.m References: Astro 321 PREDICT LSN 24-25 """ deltat = (jd_span - self.epoch_jd) * day2sec # epoch orbit parameters n0 = self.n0 ecc0 = self.ecc0 ndot2 = self.ndot2 nddot6 = self.nddot6 raan0 = self.raan0 argp0 = self.argp0 mean0 = self.mean0 inc0 = self.inc0 adot = self.adot eccdot = self.eccdot raandot = self.raandot argpdot = self.argpdot _, nu0, _ = kepler.kepler_eq_E(mean0, ecc0) a0 = kepler.n2a(n0, mu) M0, E0 = kepler.nu2anom(nu0, ecc0) # propogated elements a1 = a0 + adot * deltat # either use this or compute a1 from n1 instead ecc1 = ecc0 + eccdot * deltat raan1 = raan0 + raandot * deltat argp1 = argp0 + argpdot * deltat inc1 = inc0 * np.ones_like(ecc1) n1 = n0 + ndot2 * 2 * deltat # a1 = kepler.n2a(n1, mu) p1 = kepler.semilatus_rectum(a1, ecc1) M1 = M0 + n0 * deltat + ndot2 * deltat**2 + nddot6 * deltat**3 M1 = attitude.normalize(M1, 0, 2 * np.pi) E1, nu1, _ = kepler.kepler_eq_E(M1, ecc1) # convert to vectors r_eci, v_eci, _, _ = kepler.coe2rv(p1, ecc1, inc1, raan1, argp1, nu1, mu) # save all of the variables to the object self.jd_span = jd_span self.coe = COE(n=n1, ecc=ecc1, raan=raan1, argp=argp1, mean=M1, E=E1, nu=nu1, a=a1, p=p1, inc=inc1) self.r_eci = r_eci self.v_eci = v_eci return 0