本文整理匯總了Python中poliastro.twobody.orbit.Orbit.from_coords方法的典型用法代碼示例。如果您正苦於以下問題:Python Orbit.from_coords方法的具體用法?Python Orbit.from_coords怎麽用?Python Orbit.from_coords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類poliastro.twobody.orbit.Orbit
的用法示例。
在下文中一共展示了Orbit.from_coords方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_from_coord_fails_if_no_time_differential
# 需要導入模塊: from poliastro.twobody.orbit import Orbit [as 別名]
# 或者: from poliastro.twobody.orbit.Orbit import from_coords [as 別名]
def test_from_coord_fails_if_no_time_differential():
pos = [30000, 0, 0] * u.km
cartrep = CartesianRepresentation(*pos)
# Method fails if coordinate instance doesn't contain a differential with
# respect to time
with pytest.raises(ValueError) as excinfo:
Orbit.from_coords(Earth, SkyCoord(cartrep))
assert (
"ValueError: Coordinate instance doesn't have a differential with respect to time"
in excinfo.exconly()
)
示例2: test_from_coord_fails_for_multiple_positions
# 需要導入模塊: from poliastro.twobody.orbit import Orbit [as 別名]
# 或者: from poliastro.twobody.orbit.Orbit import from_coords [as 別名]
def test_from_coord_fails_for_multiple_positions(obstime):
cartdiff = CartesianDifferential(
[[0, 1, 0], [-0.1, 0.9, 0]] * u.km / u.s, xyz_axis=1
)
cartrep = CartesianRepresentation(
[[1, 0, 0], [0.9, 0.1, 0]] * u.km, differentials=cartdiff, xyz_axis=1
)
coords = GCRS(cartrep, representation_type=CartesianRepresentation, obstime=obstime)
with pytest.raises(ValueError) as excinfo:
Orbit.from_coords(Earth, coords)
assert (
"ValueError: Coordinate instance must represents exactly 1 position, found: 2"
in excinfo.exconly()
)
示例3: test_from_coord_if_coord_is_not_of_shape_zero
# 需要導入模塊: from poliastro.twobody.orbit import Orbit [as 別名]
# 或者: from poliastro.twobody.orbit.Orbit import from_coords [as 別名]
def test_from_coord_if_coord_is_not_of_shape_zero():
pos = [0, 1, 0]
vel = [1, 0, 0]
cartdiff = CartesianDifferential([vel] * u.km / u.s, xyz_axis=1)
cartrep = CartesianRepresentation([pos] * u.km, differentials=cartdiff, xyz_axis=1)
coords = GCRS(cartrep, representation_type=CartesianRepresentation, obstime=J2000)
ss = Orbit.from_coords(Earth, coords)
assert_quantity_allclose(ss.r, pos * u.km, rtol=1e-5)
assert_quantity_allclose(ss.v, vel * u.km / u.s, rtol=1e-5)
示例4: test_orbit_creation_using_skycoord
# 需要導入模塊: from poliastro.twobody.orbit import Orbit [as 別名]
# 或者: from poliastro.twobody.orbit.Orbit import from_coords [as 別名]
def test_orbit_creation_using_skycoord(attractor):
vel = [0, 2, 0] * u.km / u.s
cartdiff = CartesianDifferential(*vel)
pos = [30000, 0, 0] * u.km
cartrep = CartesianRepresentation(*pos, differentials=cartdiff)
coord = SkyCoord(cartrep, frame="icrs")
o = Orbit.from_coords(attractor, coord)
inertial_frame_at_body_centre = get_frame(
attractor, Planes.EARTH_EQUATOR, obstime=coord.obstime
)
coord_transformed_to_irf = coord.transform_to(inertial_frame_at_body_centre)
pos_transformed_to_irf = coord_transformed_to_irf.cartesian.xyz
vel_transformed_to_irf = coord_transformed_to_irf.cartesian.differentials["s"].d_xyz
assert (o.r == pos_transformed_to_irf).all()
assert (o.v == vel_transformed_to_irf).all()
示例5: test_orbit_creation_using_frame_obj
# 需要導入模塊: from poliastro.twobody.orbit import Orbit [as 別名]
# 或者: from poliastro.twobody.orbit.Orbit import from_coords [as 別名]
def test_orbit_creation_using_frame_obj(attractor, frame, obstime):
vel = [0, 2, 0] * u.km / u.s
cartdiff = CartesianDifferential(*vel)
pos = [30000, 0, 0] * u.km
cartrep = CartesianRepresentation(*pos, differentials=cartdiff)
coord = frame(cartrep, obstime=obstime)
o = Orbit.from_coords(attractor, coord)
inertial_frame_at_body_centre = get_frame(
attractor, Planes.EARTH_EQUATOR, obstime=coord.obstime
)
coord_transformed_to_irf = coord.transform_to(inertial_frame_at_body_centre)
pos_transformed_to_irf = coord_transformed_to_irf.cartesian.xyz
vel_transformed_to_irf = coord_transformed_to_irf.cartesian.differentials["s"].d_xyz
assert_quantity_allclose(o.r, pos_transformed_to_irf, atol=1e-5 * u.km)
assert_quantity_allclose(o.v, vel_transformed_to_irf, atol=1e-5 * u.km / u.s)