How to use the poliastro.twobody.Orbit.from_classical function in poliastro

To help you get started, we’ve selected a few poliastro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poliastro / poliastro / tests / tests_twobody / test_perturbations.py View on Github external
def test_solar_pressure(t_days, deltas_expected, sun_r):
    # based on example 12.9 from Howard Curtis
    with solar_system_ephemeris.set("builtin"):
        j_date = 2_438_400.5 * u.day
        tof = 600 * u.day
        epoch = Time(j_date, format="jd", scale="tdb")

        initial = Orbit.from_classical(
            Earth,
            10085.44 * u.km,
            0.025422 * u.one,
            88.3924 * u.deg,
            45.38124 * u.deg,
            227.493 * u.deg,
            343.4268 * u.deg,
            epoch=epoch,
        )
        # in Curtis, the mean distance to Sun is used. In order to validate against it, we have to do the same thing
        sun_normalized = functools.partial(normalize_to_Curtis, sun_r=sun_r)

        rr, vv = cowell(
            Earth.k,
            initial.r,
            initial.v,
github poliastro / poliastro / tests / test_maneuver.py View on Github external
def test_hohmann_maneuver(nu):
    # Data from Vallado, example 6.1
    alt_i = 191.34411 * u.km
    alt_f = 35781.34857 * u.km
    _a = 0 * u.deg
    ss_i = Orbit.from_classical(
        Earth, Earth.R + alt_i, ecc=0 * u.one, inc=_a, raan=_a, argp=_a, nu=nu
    )

    # Expected output
    expected_dv = 3.935224 * u.km / u.s
    expected_t_pericenter = ss_i.time_to_anomaly(0 * u.deg)
    expected_t_trans = 5.256713 * u.h
    expected_total_time = expected_t_pericenter + expected_t_trans

    man = Maneuver.hohmann(ss_i, Earth.R + alt_f)
    assert_quantity_allclose(man.get_total_cost(), expected_dv, rtol=1e-5)
    assert_quantity_allclose(man.get_total_time(), expected_total_time, rtol=1e-5)

    assert_quantity_allclose(
        ss_i.apply_maneuver(man).ecc, 0 * u.one, atol=1e-14 * u.one
    )
github poliastro / poliastro / tests / test_maneuver.py View on Github external
def test_correct_pericenter_ecc_exception():
    ss0 = Orbit.from_classical(
        Earth, 1000 * u.km, 0.5 * u.one, 0 * u.deg, 0 * u.deg, 0 * u.deg, 0 * u.deg,
    )
    max_delta_r = 30 * u.km
    with pytest.raises(NotImplementedError) as excinfo:
        Maneuver.correct_pericenter(ss0, max_delta_r)
    assert excinfo.type == NotImplementedError
    assert (
        str(excinfo.value)
        == f"The correction maneuver is not yet supported with {ss0.ecc},it should be less than or equal to 0.001"
    )
github poliastro / poliastro / tests / tests_twobody / test_propagation.py View on Github external
def test_hyperbolic_near_parabolic(ecc, propagator):
    # Still not implemented. Refer to issue #714.
    if propagator in [pimienta, gooding]:
        pytest.skip()

    _a = 0.0 * u.rad
    tof = 1.0 * u.min
    ss0 = Orbit.from_classical(
        Earth, -10000 * u.km, ecc * u.one, _a, _a, _a, 1.0 * u.rad
    )

    ss_cowell = ss0.propagate(tof, method=cowell)
    ss_propagator = ss0.propagate(tof, method=propagator)

    assert_quantity_allclose(ss_propagator.r, ss_cowell.r)
    assert_quantity_allclose(ss_propagator.v, ss_cowell.v)
github poliastro / poliastro / tests / tests_twobody / test_propagation.py View on Github external
def test_propagation_hyperbolic_zero_time_returns_same_state():
    ss0 = Orbit.from_classical(
        Earth,
        -27112.5464 * u.km,
        1.25 * u.one,
        0 * u.deg,
        0 * u.deg,
        0 * u.deg,
        0 * u.deg,
    )
    r0, v0 = ss0.rv()
    tof = 0 * u.s

    ss1 = ss0.propagate(tof)

    r, v = ss1.rv()

    assert_quantity_allclose(r, r0)
github poliastro / poliastro / tests / tests_twobody / test_perturbations.py View on Github external
def test_J3_propagation_Earth(test_params):
    # Nai-ming Qi, Qilong Sun, Yong Yang, (2018) "Effect of J3 perturbation on satellite position in LEO",
    # Aircraft Engineering and  Aerospace Technology, Vol. 90 Issue: 1,
    # pp.74-86, https://doi.org/10.1108/AEAT-03-2015-0092
    a_ini = 8970.667 * u.km
    ecc_ini = 0.25 * u.one
    raan_ini = 1.047 * u.rad
    nu_ini = 0.0 * u.rad
    argp_ini = 1.0 * u.rad
    inc_ini = test_params["inc"]

    k = Earth.k.to(u.km ** 3 / u.s ** 2).value

    orbit = Orbit.from_classical(
        Earth, a_ini, ecc_ini, inc_ini, raan_ini, argp_ini, nu_ini
    )

    tofs = np.linspace(0, 10.0 * u.day, 1000)
    r_J2, v_J2 = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        ad=J2_perturbation,
        J2=Earth.J2.value,
        R=Earth.R.to(u.km).value,
        rtol=1e-8,
    )

    def a_J2J3(t0, u_, k_):
github aerospaceresearch / orbitdeterminator / orbitdeterminator / kep_determination / custom_prop.py View on Github external
x0=np.asarray(x0)                      
                                 
            #x0[3:6] = np.deg2rad(x0[3:6])
            time_p=Time(x0[2], format='jd').iso
            time_obj=Time(time,format="iso",scale="utc")
            time_p_obj=Time(time_p,format="iso",scale="utc")
            #print("chk:")
            #print(time_obj.tdb.jd)
            nu=time2truean(x0[0],x0[1], mu,time_obj.tdb.jd,x0[2])
            eccentric_anomaly=truean2eccan(x0[1],nu)
 
            nu=np.rad2deg(nu)
            kep_i=(x0[0],x0[1],x0[4],x0[3],x0[5],nu)
            kep_i=np.asarray(kep_i)
            initial_state = kep_state(kep_i.reshape(-1, 1))
            initial = Orbit.from_classical(Earth, x0[0] * u.km, x0[1] * u.one, x0[4] * u.deg, x0[5]* u.deg, x0[3] * u.deg, nu* u.deg,epoch=Time(time, format='iso', scale='utc'))
           

        else:
            obs_arr = [int(item) for item in args.obs_array.split(',')]
            x0 = gauss_method_sat(args.file_path, obs_arr=obs_arr, bodyname=args.body_name,
                                  r2_root_ind_vec=args.root_index, refiters=args.iterations, plot=False)
            time=Time(x0[7], format='jd').iso

            x0=np.asarray(x0)                      
                                  
            #x0[3:6] = np.deg2rad(x0[3:6])
            time_p=Time(x0[2], format='jd').iso
            time_obj=Time(time,format="iso",scale="utc")
            time_p_obj=Time(time_p,format="iso",scale="utc")
            #print("chk:")
            #print(time_obj.tdb.jd)
github poliastro / poliastro / src / poliastro / examples.py View on Github external
from poliastro.bodies import Earth, Sun
from poliastro.twobody import Orbit

iss = Orbit.from_vectors(
    Earth,
    [8.59072560e2, -4.13720368e3, 5.29556871e3] * u.km,
    [7.37289205, 2.08223573, 4.39999794e-1] * u.km / u.s,
    time.Time("2013-03-18 12:00", scale="utc"),
)
"""ISS orbit example

Taken from Plyades (c) 2012 Helge Eichhorn (MIT License)

"""

molniya = Orbit.from_classical(
    Earth, 26600 * u.km, 0.75 * u.one, 63.4 * u.deg, 0 * u.deg, 270 * u.deg, 80 * u.deg
)
"""Molniya orbit example"""

_r_a = Earth.R + 35950 * u.km
_r_p = Earth.R + 250 * u.km
_a = (_r_a + _r_p) / 2
soyuz_gto = Orbit.from_classical(
    Earth, _a, _r_a / _a - 1, 6 * u.deg, 188.5 * u.deg, 178 * u.deg, 0 * u.deg
)
"""Soyuz geostationary transfer orbit (GTO) example

Taken from Soyuz User's Manual, issue 2 revision 0

"""
github aerospaceresearch / orbitdeterminator / orbitdeterminator / kep_determination / custom_prop.py View on Github external
r2_root_ind_vec=args.root_index, refiters=args.iterations, plot=False)
                 
                 time=Time(x0[7], format='jd').iso
                 x0=np.asarray(x0)                
                                       
                                
                 #x0[3:6] = np.deg2rad(x0[3:6])
                 mean_motion=meanmotion(mu_Sun,x0[0])
                 mean_anomaly=meananomaly(mean_motion,time.tdb.jd,x0[2])
                 eccentric_anomaly=eccentricanomaly(x0[1],mean_anomaly)
                 nu=trueanomaly(x0[1],eccentric_anomaly)
                 nu=np.rad2deg(nu)
                 

                 #initial = kep_2_cart(x0[0],x0[1],x0[4],x0[3],x0[5],x0[6],eccentric_anomaly)
                 initial = Orbit.from_classical(Sun, x0[0] * u.AU, x0[1] * u.one, x0[4] * u.deg, x0[5]* u.deg, x0[3] * u.deg, nu * u.deg,epoch=Time(time, format='iso', scale='utc'))
                 print("")
                 print(initial)
                 print(initial.rv())
                 print("\nPropagate to(Enter time in format='iso', scale='utc':")
                 p_t_s=input()    
                 p_t_o= Time(p_t_s, format='iso', scale='utc')
                 print("")
                 final=initial.propagate(p_t_o)
                 #final.plot()
                 print("Orbital elements:")    
                 print(final.classical())
                 print("")                 
                 print("Final co-ordinates:")
                 print(final.rv())                                 
                 print("")
                 f_orbit=final