本文整理汇总了Python中poliastro.twobody.orbit.Orbit.from_vectors方法的典型用法代码示例。如果您正苦于以下问题:Python Orbit.from_vectors方法的具体用法?Python Orbit.from_vectors怎么用?Python Orbit.from_vectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poliastro.twobody.orbit.Orbit
的用法示例。
在下文中一共展示了Orbit.from_vectors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_orbit_wrong_dimensions_fails
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_wrong_dimensions_fails():
bad_r = [[1000, 0, 0]] * u.km
bad_v = [[[0, 10, 0]]] * u.km / u.s
with pytest.raises(ValueError) as excinfo:
Orbit.from_vectors(Earth, bad_r, bad_v)
assert "ValueError: Vectors must have dimension 1, got 2 and 3" in excinfo.exconly()
示例2: test_state_raises_unitserror_if_rv_units_are_wrong
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_state_raises_unitserror_if_rv_units_are_wrong():
_d = [1.0, 0.0, 0.0] * u.AU
wrong_v = [0.0, 1.0e-6, 0.0] * u.AU
with pytest.raises(u.UnitsError) as excinfo:
Orbit.from_vectors(Sun, _d, wrong_v)
assert (
"UnitsError: Argument 'v' to function 'from_vectors' must be in units convertible to 'm / s'."
in excinfo.exconly()
)
示例3: test_orbit_accepts_ecliptic_plane
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_accepts_ecliptic_plane():
r = [1e09, -4e09, -1e09] * u.km
v = [5e00, -1e01, -4e00] * u.km / u.s
ss = Orbit.from_vectors(Sun, r, v, plane=Planes.EARTH_ECLIPTIC)
assert ss.frame.is_equivalent_frame(HeliocentricEclipticJ2000(obstime=J2000))
示例4: transform
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def transform(orbit, frame_orig, frame_dest):
"""Transforms Orbit from one frame to another.
Parameters
----------
orbit : ~poliastro.bodies.Orbit
Orbit to transform
frame_orig : ~astropy.coordinates.BaseCoordinateFrame
Initial frame
frame_dest : ~astropy.coordinates.BaseCoordinateFrame
Final frame
Returns
-------
orbit: ~poliastro.bodies.Orbit
Orbit in the new frame
"""
orbit_orig = frame_orig(x=orbit.r[0], y=orbit.r[1], z=orbit.r[2],
v_x=orbit.v[0], v_y=orbit.v[1], v_z=orbit.v[2],
representation=CartesianRepresentation,
differential_type=CartesianDifferential)
orbit_dest = orbit_orig.transform_to(frame_dest(obstime=orbit.epoch))
orbit_dest.representation = CartesianRepresentation
return Orbit.from_vectors(orbit.attractor,
orbit_dest.data.xyz,
orbit_dest.data.differentials['s'].d_xyz,
epoch=orbit.epoch)
示例5: test_inertial_body_centered_to_pqw
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_inertial_body_centered_to_pqw():
molniya_r_peri, molniya_v_peri = coordinates.inertial_body_centered_to_pqw(molniya.r, molniya.v, bodies.Earth)
molniya_peri = Orbit.from_vectors(bodies.Earth, molniya_r_peri, molniya_v_peri, molniya.epoch)
assert_quantity_allclose(molniya_peri.e_vec[-2:], [0, 0], atol=1e-12)
assert_quantity_allclose(norm(molniya_peri.e_vec), norm(molniya.e_vec))
示例6: test_orbit_plot_static_3d
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_plot_static_3d():
# Data from Curtis, example 4.3
r = [-6045, -3490, 2500] * u.km
v = [-3.457, 6.618, 2.533] * u.km / u.s
ss = Orbit.from_vectors(Earth, r, v)
with pytest.raises(ValueError, match="static and use_3d cannot be true"):
ss.plot(static=True, use_3d=True)
示例7: test_orbit_no_frame_representation
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_no_frame_representation():
date_launch = Time("2011-11-26 15:02", scale="utc")
r = [61445.76498656, 24827.93010168, 0.0] * u.km
v = [-0.42581645, -0.18867869, 0.0] * u.km / u.s
ss = Orbit.from_vectors(Moon, r, v, date_launch)
expected_str = "106 x -142299 km x 180.0 deg orbit around Moon (\u263E) at epoch 2011-11-26 15:02:00.000 (UTC)"
assert str(ss) == repr(ss) == expected_str
示例8: test_sample_big_orbits
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_sample_big_orbits(method):
# See https://github.com/poliastro/poliastro/issues/265
ss = Orbit.from_vectors(
Sun,
[-9018878.6, -94116055, 22619059] * u.km,
[-49.950923, -12.948431, -4.2925158] * u.km / u.s,
)
positions = ss.sample(15, method=method)
assert len(positions) == 15
示例9: hyperbolic
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def hyperbolic():
r = [1.197659243752796e09, -4.443716685978071e09, -1.747610548576734e09] * u.km
v = (
[5.540549267188614e00, -1.251544669134140e01, -4.848892572767733e00]
* u.km
/ u.s
)
epoch = Time("2015-07-14 07:59", scale="tdb")
return Orbit.from_vectors(Sun, r, v, epoch)
示例10: test_orbit_plot_is_not_static
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_plot_is_not_static(use_3d):
from plotly.graph_objs import FigureWidget
# Data from Curtis, example 4.3
r = [-6045, -3490, 2500] * u.km
v = [-3.457, 6.618, 2.533] * u.km / u.s
ss = Orbit.from_vectors(Earth, r, v)
plot = ss.plot(static=False, use_3d=use_3d)
assert isinstance(plot, FigureWidget)
示例11: test_orbit_plot_is_static
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_plot_is_static():
# Data from Curtis, example 4.3
r = [-6045, -3490, 2500] * u.km
v = [-3.457, 6.618, 2.533] * u.km / u.s
ss = Orbit.from_vectors(Earth, r, v)
plot = ss.plot(static=True)
assert isinstance(plot[0], matplotlib.lines.Line2D)
assert isinstance(plot[1], matplotlib.lines.Line2D)
示例12: test_pqw_returns_dimensionless
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_pqw_returns_dimensionless():
r_0 = ([1, 0, 0] * u.au).to(u.km)
v_0 = ([0, 6, 0] * u.au / u.year).to(u.km / u.day)
ss = Orbit.from_vectors(Sun, r_0, v_0)
p, q, w = ss.pqw()
assert p.unit == u.one
assert q.unit == u.one
assert w.unit == u.one
示例13: test_orbit_has_proper_frame
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_orbit_has_proper_frame(attractor, expected_frame_class):
# Dummy data
r = [1e09, -4e09, -1e09] * u.km
v = [5e00, -1e01, -4e00] * u.km / u.s
epoch = Time("2015-07-14 07:59", scale="tdb")
ss = Orbit.from_vectors(attractor, r, v, epoch)
assert ss.frame.is_equivalent_frame(expected_frame_class(obstime=epoch))
assert ss.frame.obstime == epoch
示例14: test_hyperbolic_modulus_wrapped_nu
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_hyperbolic_modulus_wrapped_nu():
ss = Orbit.from_vectors(
Sun,
[-9.77441841e07, 1.01000539e08, 4.37584668e07] * u.km,
[23.75936985, -43.09599568, -8.7084724] * u.km / u.s,
)
num_values = 3
positions = ss.sample(num_values)
assert_quantity_allclose(positions[0].data.xyz, ss.r)
示例15: test_sample_num_points
# 需要导入模块: from poliastro.twobody.orbit import Orbit [as 别名]
# 或者: from poliastro.twobody.orbit.Orbit import from_vectors [as 别名]
def test_sample_num_points(num_points):
# Data from Vallado, example 2.4
r0 = [1131.340, -2282.343, 6672.423] * u.km
v0 = [-5.64305, 4.30333, 2.42879] * u.km / u.s
ss0 = Orbit.from_vectors(Earth, r0, v0)
# TODO: Test against the perigee and apogee
# expected_ss = ss0.propagate(ss0.period / 2)
rr = ss0.sample(num_points)
assert len(rr) == num_points