当前位置: 首页>>代码示例>>Python>>正文


Python orbit.Orbit类代码示例

本文整理汇总了Python中poliastro.twobody.orbit.Orbit的典型用法代码示例。如果您正苦于以下问题:Python Orbit类的具体用法?Python Orbit怎么用?Python Orbit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Orbit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_orbit_wrong_dimensions_fails

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()
开发者ID:poliastro,项目名称:poliastro,代码行数:7,代码来源:test_orbit.py

示例2: test_from_horizons_raise_valueerror

def test_from_horizons_raise_valueerror():
    with pytest.raises(ValueError) as exep:
        Orbit.from_horizons(name="Dummy")
    assert (
        "ValueError: Unknown target (Dummy). Maybe try different id_type?"
        in exep.exconly()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:7,代码来源:test_orbit.py

示例3: test_from_sbdb_raise_valueerror

def test_from_sbdb_raise_valueerror():
    with pytest.raises(ValueError) as excinfo:
        Orbit.from_sbdb(name="Halley")

    assert (
        str(excinfo.value)
        == "2 different objects found: \n2688 Halley (1982 HG1)\n1P/Halley\n"
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:8,代码来源:test_orbit.py

示例4: test_frozen_orbit_altitude

def test_frozen_orbit_altitude():
    with pytest.raises(ValueError) as excinfo:
        Orbit.frozen(Earth, -1 * u.m)
    assert excinfo.type == ValueError
    assert (
        str(excinfo.value)
        == "The semimajor axis may not be smaller that Earth's radius"
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:8,代码来源:test_orbit.py

示例5: test_frozen_orbit_non_spherical_arguments

def test_frozen_orbit_non_spherical_arguments():
    with pytest.raises(AttributeError) as excinfo:
        Orbit.frozen(Jupiter, 1 * u.m)
    assert excinfo.type == AttributeError
    assert (
        str(excinfo.value)
        == "Attractor Jupiter has not spherical harmonics implemented"
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:8,代码来源:test_orbit.py

示例6: test_geostationary_input

def test_geostationary_input(attractor):
    with pytest.raises(ValueError) as excinfo:
        Orbit.geostationary(attractor=attractor)

    assert (
        "ValueError: At least one among angular_velocity or period must be passed"
        in excinfo.exconly()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:8,代码来源:test_orbit.py

示例7: test_geostationary_non_existence_condition

def test_geostationary_non_existence_condition(attractor, period, hill_radius):
    with pytest.raises(ValueError) as excinfo:
        Orbit.geostationary(attractor=attractor, period=period, hill_radius=hill_radius)

    assert (
        "Geostationary orbit for the given parameters doesn't exist"
        in excinfo.exconly()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:8,代码来源:test_orbit.py

示例8: test_from_ephem_raises_warning_if_time_is_not_tdb_with_proper_time

def test_from_ephem_raises_warning_if_time_is_not_tdb_with_proper_time(recwarn):
    body = Earth
    epoch = Time("2017-09-29 07:31:26", scale="utc")
    expected_epoch_string = "2017-09-29 07:32:35.182"  # epoch.tdb.value

    Orbit.from_body_ephem(body, epoch)

    w = recwarn.pop(TimeScaleWarning)
    assert expected_epoch_string in str(w.message)
开发者ID:poliastro,项目名称:poliastro,代码行数:9,代码来源:test_orbit.py

示例9: test_bad_hyperbolic_raises_exception

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()
开发者ID:poliastro,项目名称:poliastro,代码行数:9,代码来源:test_orbit.py

示例10: test_state_raises_unitserror_if_rv_units_are_wrong

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()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:9,代码来源:test_orbit.py

示例11: test_plot_trajectory_sets_label

def test_plot_trajectory_sets_label():
    op = OrbitPlotter()
    earth = Orbit.from_body_ephem(Earth)
    mars = Orbit.from_body_ephem(Mars)
    trajectory = earth.sample()
    op.plot(mars, label="Mars")
    op.plot_trajectory(trajectory, label="Earth")
    legend = plt.gca().get_legend()
    assert legend.get_texts()[1].get_text() == "Earth"
开发者ID:aarribas,项目名称:poliastro,代码行数:9,代码来源:test_plotting.py

示例12: test_state_raises_unitserror_if_elements_units_are_wrong

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()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:11,代码来源:test_orbit.py

示例13: test_parabolic_elements_fail_early

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()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:11,代码来源:test_orbit.py

示例14: test_bad_inclination_raises_exception

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()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:11,代码来源:test_orbit.py

示例15: test_from_coord_fails_if_no_time_differential

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()
    )
开发者ID:poliastro,项目名称:poliastro,代码行数:12,代码来源:test_orbit.py


注:本文中的poliastro.twobody.orbit.Orbit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。