コード例 #1
0
def test_set_frame_plots_same_colors():
    # TODO: Review
    op = StaticOrbitPlotter()
    op.plot_body_orbit(Jupiter, J2000_TDB)
    colors1 = [orb[2] for orb in op.trajectories]
    op.set_body_frame(Jupiter)
    colors2 = [orb[2] for orb in op.trajectories]
    assert colors1 == colors2
コード例 #2
0
def test_redraw_keeps_trajectories():
    # See https://github.com/poliastro/poliastro/issues/518
    op = StaticOrbitPlotter()
    trajectory = churi.sample()
    op.plot_body_orbit(Mars, J2000_TDB, label="Mars")
    op.plot_trajectory(trajectory, label="67P")

    assert len(op.trajectories) == 2

    op.set_body_frame(Mars)

    assert len(op.trajectories) == 2
コード例 #3
0
def _plot_solar_system_2d(epoch, outer=True, interactive=False):
    if interactive:
        orbit_plotter = OrbitPlotter2D(
            plane=Planes.EARTH_ECLIPTIC
        )  # type: Union[OrbitPlotter2D, StaticOrbitPlotter]
    else:
        orbit_plotter = StaticOrbitPlotter(plane=Planes.EARTH_ECLIPTIC)

    orbit_plotter.set_body_frame(Earth, epoch)

    _plot_bodies(orbit_plotter, outer, epoch)

    return orbit_plotter
コード例 #4
0
def test_body_frame_raises_warning_if_time_is_not_tdb_with_proper_time(
        recwarn):
    from poliastro.warnings import TimeScaleWarning

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

    op = StaticOrbitPlotter()
    op.set_body_frame(body, epoch)

    w = recwarn.pop(TimeScaleWarning)

    assert expected_epoch_string in str(w.message)
コード例 #5
0
def test_plot_ephem_different_plane_raises_error():
    unused_epochs = Time.now().reshape(-1)
    unused_coordinates = CartesianRepresentation(
        [(1, 0, 0)] * u.au,
        xyz_axis=1,
        differentials=CartesianDifferential([(0, 1, 0)] * (u.au / u.day), xyz_axis=1),
    )

    op = StaticOrbitPlotter(plane=Planes.EARTH_ECLIPTIC)
    op.set_attractor(Sun)
    op.set_body_frame(Earth)
    with pytest.raises(ValueError) as excinfo:
        op.plot_ephem(Ephem(unused_epochs, unused_coordinates, Planes.EARTH_EQUATOR))

    assert (
        "sample the ephemerides using a different plane or create a new plotter"
        in excinfo.exconly()
    )
コード例 #6
0
ファイル: horizons.py プロジェクト: tomaszmrugalski/perylune
def dist_chart(asteroid, date, timespan):
    solar_system_ephemeris.set('jpl')

    EPOCH = Time(date, scale="tdb")

    epochs = time_range(EPOCH - TimeDelta(timespan),
                        end=EPOCH + TimeDelta(timespan))

    epochs_moon = time_range(EPOCH - TimeDelta(15 * u.day),
                             end=EPOCH + TimeDelta(15 * u.day))

    moon = Ephem.from_body(Moon, epochs_moon, attractor=Earth)
    aster = Ephem.from_horizons(asteroid, epochs, attractor=Earth)

    plotter = StaticOrbitPlotter()
    plotter.set_attractor(Earth)
    plotter.set_body_frame(Moon)
    plotter.plot_ephem(moon, EPOCH, label=Moon)
    plotter.plot_ephem(aster, EPOCH, label=asteroid)

    return plotter