本文整理汇总了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)