Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"attractor,location_str", [(None, "@ssb"), (Earth, "500@399"), (Venus, "500@299")]
)
@pytest.mark.parametrize(
"plane,refplane_str",
[(Planes.EARTH_EQUATOR, "earth"), (Planes.EARTH_ECLIPTIC, "ecliptic")],
)
def test_ephem_from_horizons_calls_horizons_with_correct_parameters(
horizons_mock, attractor, location_str, plane, refplane_str
):
unused_name = "Strange Object"
unused_id_type = "id_type"
epochs = Time(["2020-03-01 12:00:00"], scale="tdb")
horizons_mock().vectors.return_value = {
"x": [1] * u.au,
"y": [0] * u.au,
"z": [0] * u.au,
def test_propagate_instance():
tof = 1.0 * u.min
ss0 = Orbit.from_classical(
Earth,
1000 * u.km,
0.75 * u.one,
63.4 * u.deg,
0 * u.deg,
270 * u.deg,
80 * u.deg,
)
C_D = 2.2 * u.one # dimentionless (any value would do)
A = ((np.pi / 4.0) * (u.m ** 2)).to(u.km ** 2)
m = 100 * u.kg
spacecraft = Spacecraft(A, C_D, m)
earth_satellite = EarthSatellite(ss0, spacecraft)
orbit_with_j2 = earth_satellite.propagate(tof=tof, gravity=EarthGravity.J2)
orbit_without_perturbation = earth_satellite.propagate(tof)
orbit_with_atmosphere_and_j2 = earth_satellite.propagate(
tof=tof, gravity=EarthGravity.J2, atmosphere=COESA76()
H0=H0,
rho0=rho0
)
else:
pass
print("")
print("Positions and velocity vectors are:")
#print(str(rr.x))
#print([float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.x))])
r=[[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.x))][0],[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.y))][0],[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.z))][0]]* u.km
v=[[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.v_x))][0],[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.v_y))][0],[float(s) for s in re.findall(r'-?\d+\.?\d*',str(rr.v_z))][0]]* u.km / u.s
f_orbit= Orbit.from_vectors(Earth, r, v)
print(r)
print(v)
#f_orbit.plot()
print("")
print("Orbital elements:")
print(f_orbit.classical())
print("")
#print("")
#print(f_orbit.ecc)
plotOrbit((f_orbit.a.value),(f_orbit.ecc.value),(f_orbit.inc.value),(f_orbit.raan.value),(f_orbit.argp.value),(f_orbit.nu.value))
"""Example data.
"""
from astropy import time, units as u
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 = Earth.R.to(u.km).value
k = Earth.k.to(u.km ** 3 / u.s ** 2).value
#s0 = Orbit.from_classical(Earth, x[0] * u.km, x[1] * u.one, x[4] * u.deg, * u.deg, x[3] * u.deg, 0 * u.deg, epoch=Time(0, format='jd', scale='tdb'))
#orbit = Orbit.circular(
# Earth, 250 * u.km, epoch=Time(0.0, format="jd", scale="tdb"))
# parameters of a body
C_D = 2.2 # dimentionless (any value would do)
A = ((np.pi / 4.0) * (u.m ** 2)).to(u.km ** 2).value # km^2
m = 100 # kg
B = C_D * A / m
# parameters of the atmosphere
rho0 = Earth.rho0.to(u.kg / u.km ** 3).value # kg/km^3
H0 = Earth.H0.to(u.km).value
print("Use default constants or you want to customize?\n1.Default.\n2.Custom.")
check=input()
if(check=='1'):
pass
else:
m=input("Enter mass of the body in kg:")
R=input("Enter radius of earth in km:")
C_D=input("Enter C_D(dimension):")
H0=input("Enter atmospheric parameter H0:")
#rho0=input("Enter atmospheric parameter rho0:")
R=R*u.km
H0=H0*u.km
#rho0=rho0*(u.kg / u.km ** 3)
datetimeFormat = '%Y-%m-%d %H:%M:%S.%f'
Parameters
----------
orbit : Orbit
Position and velocity of a body with respect to an attractor
at a given time (epoch).
spacecraft: Spacecraft
Raises
------
ValueError
If the orbit's attractor is not Earth
"""
if orbit.attractor is not Earth:
raise ValueError("The attractor must be Earth")
self._orbit = orbit # type: Orbit
self._spacecraft = spacecraft # type: Spacecraft
[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
"""
churi = Orbit.from_classical(
Sun,
3.46250 * u.AU,
0.64 * u.one,
7.04 * u.deg,
50.1350 * u.deg,