當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。