本文整理汇总了Python中poliastro.twobody.orbit.Orbit.from_classical方法的典型用法代码示例。如果您正苦于以下问题:Python Orbit.from_classical方法的具体用法?Python Orbit.from_classical怎么用?Python Orbit.from_classical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poliastro.twobody.orbit.Orbit
的用法示例。
在下文中一共展示了Orbit.from_classical方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_hyperbolic_raises_exception
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_bad_hyperbolic_raises_exception():
bad_a = 1.0 * u.AU
ecc = 1.5 * u.one
_inc = 100 * u.deg # Unused inclination
_a = 1.0 * u.deg # Unused angle
_body = Sun # Unused body
with pytest.raises(ValueError) as excinfo:
Orbit.from_classical(_body, bad_a, ecc, _inc, _a, _a, _a)
assert "Hyperbolic orbits have negative semimajor axis" in excinfo.exconly()
示例2: test_parabolic_elements_fail_early
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_parabolic_elements_fail_early():
attractor = Earth
ecc = 1.0 * u.one
_d = 1.0 * u.AU # Unused distance
_a = 1.0 * u.deg # Unused angle
with pytest.raises(ValueError) as excinfo:
Orbit.from_classical(attractor, _d, ecc, _a, _a, _a, _a)
assert (
"ValueError: For parabolic orbits use Orbit.parabolic instead"
in excinfo.exconly()
)
示例3: test_state_raises_unitserror_if_elements_units_are_wrong
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_state_raises_unitserror_if_elements_units_are_wrong():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
wrong_angle = 1.0 * u.AU
with pytest.raises(u.UnitsError) as excinfo:
Orbit.from_classical(Sun, _d, _, _a, _a, _a, wrong_angle)
assert (
"UnitsError: Argument 'nu' to function 'from_classical' must be in units convertible to 'rad'."
in excinfo.exconly()
)
示例4: test_bad_inclination_raises_exception
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_bad_inclination_raises_exception():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
_body = Sun # Unused body
bad_inc = 200 * u.deg
with pytest.raises(ValueError) as excinfo:
Orbit.from_classical(_body, _d, _, bad_inc, _a, _a, _a)
assert (
"ValueError: Inclination must be between 0 and 180 degrees" in excinfo.exconly()
)
示例5: orbit_from_record
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def orbit_from_record(record):
"""Return :py:class:`~poliastro.twobody.orbit.Orbit` given a record.
Retrieve info from JPL DASTCOM5 database.
Parameters
----------
record : int
Object record.
Returns
-------
orbit : ~poliastro.twobody.orbit.Orbit
NEO orbit.
"""
body_data = read_record(record)
a = body_data['A'].item() * u.au
ecc = body_data['EC'].item() * u.one
inc = body_data['IN'].item() * u.deg
raan = body_data['OM'].item() * u.deg
argp = body_data['W'].item() * u.deg
m = body_data['MA'].item() * u.deg
nu = M_to_nu(m, ecc)
epoch = Time(body_data['EPOCH'].item(), format='jd', scale='tdb')
orbit = Orbit.from_classical(Sun, a, ecc, inc, raan, argp, nu, epoch)
orbit._frame = HeliocentricEclipticJ2000(obstime=epoch)
return orbit
示例6: test_perifocal_points_to_perigee
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_perifocal_points_to_perigee():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
ss = Orbit.from_classical(Sun, _d, _, _a, _a, _a, _a)
p, _, _ = ss.pqw()
assert_allclose(p, ss.e_vec / ss.ecc)
示例7: test_default_time_for_new_state
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_default_time_for_new_state():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
_body = Sun # Unused body
expected_epoch = J2000
ss = Orbit.from_classical(_body, _d, _, _a, _a, _a, _a)
assert ss.epoch == expected_epoch
示例8: test_sample_numpoints
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_sample_numpoints():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
_body = Sun # Unused body
ss = Orbit.from_classical(_body, _d, _, _a, _a, _a, _a)
positions = ss.sample(values=50)
assert len(positions) == 50
示例9: test_perigee_and_apogee
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_perigee_and_apogee():
expected_r_a = 500 * u.km
expected_r_p = 300 * u.km
a = (expected_r_a + expected_r_p) / 2
ecc = expected_r_a / a - 1
_a = 1.0 * u.deg # Unused angle
ss = Orbit.from_classical(Earth, a, ecc, _a, _a, _a, _a)
assert_allclose(ss.r_a.to(u.km).value, expected_r_a.to(u.km).value)
assert_allclose(ss.r_p.to(u.km).value, expected_r_p.to(u.km).value)
示例10: test_apply_maneuver_changes_epoch
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_apply_maneuver_changes_epoch():
_d = 1.0 * u.AU # Unused distance
_ = 0.5 * u.one # Unused dimensionless value
_a = 1.0 * u.deg # Unused angle
ss = Orbit.from_classical(Sun, _d, _, _a, _a, _a, _a)
dt = 1 * u.h
dv = [0, 0, 0] * u.km / u.s
orbit_new = ss.apply_maneuver([(dt, dv)])
assert orbit_new.epoch == ss.epoch + dt
示例11: test_convert_from_rv_to_coe
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_convert_from_rv_to_coe():
# Data from Vallado, example 2.6
attractor = Earth
p = 11067.790 * u.km
ecc = 0.83285 * u.one
inc = 87.87 * u.deg
raan = 227.89 * u.deg
argp = 53.38 * u.deg
nu = 92.335 * u.deg
expected_r = [6525.344, 6861.535, 6449.125] * u.km
expected_v = [4.902276, 5.533124, -1.975709] * u.km / u.s
r, v = Orbit.from_classical(
attractor, p / (1 - ecc ** 2), ecc, inc, raan, argp, nu
).rv()
assert_quantity_allclose(r, expected_r, rtol=1e-5)
assert_quantity_allclose(v, expected_v, rtol=1e-5)
示例12: test_orbits_are_same
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def test_orbits_are_same():
epoch = Time("2018-07-23")
# Orbit Parameters of Ceres
# Taken from https://ssd.jpl.nasa.gov/horizons.cgi
ss = Orbit.from_classical(
Sun,
2.767107584017257 * u.au,
0.07554802949294502 * u.one,
27.18502520750381 * u.deg,
23.36913256044832 * u.deg,
132.2919806192451 * u.deg,
21.28958091587153 * u.deg,
epoch,
)
ss1 = Orbit.from_horizons(name="Ceres", epoch=epoch)
assert ss.pqw()[0].value.all() == ss1.pqw()[0].value.all()
assert ss.r_a == ss1.r_a
assert ss.a == ss1.a
示例13: orbit_from_spk_id
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_classical [as 别名]
def orbit_from_spk_id(spk_id, api_key=None):
"""Return :py:class:`~poliastro.twobody.orbit.Orbit` given a SPK-ID.
Retrieve info from NASA NeoWS API, and therefore
it only works with NEAs (Near Earth Asteroids).
Parameters
----------
spk_id : str
SPK-ID number, which is given to each body by JPL.
api_key : str
NASA OPEN APIs key (default: `DEMO_KEY`)
Returns
-------
orbit : ~poliastro.twobody.orbit.Orbit
NEA orbit.
"""
payload = {'api_key': api_key or DEFAULT_API_KEY}
response = requests.get(NEOWS_URL + spk_id, params=payload)
response.raise_for_status()
orbital_data = response.json()['orbital_data']
attractor = Sun
a = float(orbital_data['semi_major_axis']) * u.AU
ecc = float(orbital_data['eccentricity']) * u.one
inc = float(orbital_data['inclination']) * u.deg
raan = float(orbital_data['ascending_node_longitude']) * u.deg
argp = float(orbital_data['perihelion_argument']) * u.deg
m = float(orbital_data['mean_anomaly']) * u.deg
nu = M_to_nu(m.to(u.rad), ecc)
epoch = Time(float(orbital_data['epoch_osculation']), format='jd', scale='tdb')
ss = Orbit.from_classical(attractor, a, ecc, inc,
raan, argp, nu, epoch, plane=Planes.EARTH_ECLIPTIC)
return ss