Esempio n. 1
0
def test_plot_maneuver():
    # Data from Vallado, example 6.1
    alt_i = 191.34411 * u.km
    alt_f = 35781.34857 * u.km
    _a = 0 * u.deg
    ss_i = Orbit.from_classical(
        attractor=Earth,
        a=Earth.R + alt_i,
        ecc=0 * u.one,
        inc=_a,
        raan=_a,
        argp=_a,
        nu=_a,
    )

    # Create the maneuver
    man = Maneuver.hohmann(ss_i, Earth.R + alt_f)

    # Plot the maneuver
    fig, ax = plt.subplots()
    plotter = StaticOrbitPlotter(ax=ax)
    plotter.plot(ss_i, label="Initial orbit", color="blue")
    plotter.plot_maneuver(ss_i, man, label="Hohmann maneuver", color="red")

    return fig
Esempio n. 2
0
def test_plot_different_planes():
    fig, ax = plt.subplots()
    plotter = StaticOrbitPlotter(ax=ax)
    plotter.plot(iss)
    plotter.plot(molniya.change_plane(Planes.EARTH_ECLIPTIC))

    return fig
Esempio n. 3
0
def test_basic_orbit_and_trajectory_plotting():
    fig, ax = plt.subplots()
    plotter = StaticOrbitPlotter(ax=ax)
    plotter.plot(iss)
    plotter.plot_trajectory(molniya.sample(), label="Molniya")

    return fig
Esempio n. 4
0
def test_axes_labels_and_title():
    ax = plt.gca()
    op = StaticOrbitPlotter(ax)
    ss = iss
    op.plot(ss)

    assert ax.get_xlabel() == "$x$ (km)"
    assert ax.get_ylabel() == "$y$ (km)"
Esempio n. 5
0
def test_set_frame_plots_same_colors():
    # TODO: Review
    op = StaticOrbitPlotter()
    jupiter = Orbit.from_body_ephem(Jupiter)
    op.plot(jupiter)
    colors1 = [orb[2] for orb in op.trajectories]
    op.set_frame(*jupiter.pqw())
    colors2 = [orb[2] for orb in op.trajectories]
    assert colors1 == colors2
Esempio n. 6
0
def test_plot_trajectory_sets_label():
    op = StaticOrbitPlotter()
    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"
Esempio n. 7
0
def test_color():
    op = StaticOrbitPlotter()
    ss = iss
    c = "#FF0000"
    op.plot(ss, label="ISS", color=c)
    ax = plt.gca()

    assert ax.get_legend().get_lines()[0].get_c() == c
    for element in ax.get_lines():
        assert element.get_c() == c
Esempio n. 8
0
def test_legend():
    op = StaticOrbitPlotter()
    ss = iss
    op.plot(ss, label="ISS")
    legend = plt.gca().get_legend()

    ss.epoch.out_subfmt = "date_hm"
    label = f"{ss.epoch.iso} (ISS)"

    assert legend.get_texts()[0].get_text() == label
Esempio n. 9
0
def test_redraw_keeps_trajectories():
    # See https://github.com/poliastro/poliastro/issues/518
    op = StaticOrbitPlotter()
    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")

    assert len(op.trajectories) == 2

    op.set_frame(*mars.pqw())

    assert len(op.trajectories) == 2
Esempio n. 10
0
def test_number_of_lines_for_osculating_orbit():
    op1 = StaticOrbitPlotter()
    ss = iss

    l1 = op1.plot(ss)

    assert len(l1) == 2
Esempio n. 11
0
    def render(self, mode='live'):
        # Render the environment to the screen
        #plt.clf()
        if mode == 'live':

            if self.i <= self.n:
                plt.figure()

                op = StaticOrbitPlotter()


                orb = [Orbit.from_vectors(Earth, r=(x[:3] / 1000) * u.km, v=(x[3:] / 1000) * u.km / u.s) for x in
                       self.x_true[self.i]]
                orb1 = [Orbit.from_vectors(Earth, r=(x[:3] / 1000) * u.km, v=(x[3:] / 1000) * u.km / u.s) for x in
                        self.x_filter[self.i]]
                palette = sns.color_palette("hls", len(orb))

                for i, c in enumerate(orb):
                    new = op.plot(c, label="true", color=palette[i])
                    new[0].set_linestyle("-")
                for j, d in enumerate(orb1):
                    op.plot(d, label="filtered", color=palette[j])
                plt.pause(0.001)
                plt.savefig('fig'+str(self.i)+'.png')
Esempio n. 12
0
def test_trail_plotting():
    fig, ax = plt.subplots()
    plotter = StaticOrbitPlotter(ax=ax)
    plotter.plot(iss, trail=True)

    return fig
Esempio n. 13
0
def test_basic_plotting():
    fig, ax = plt.subplots()
    plotter = StaticOrbitPlotter(ax=ax)
    plotter.plot(iss)

    return fig
# In[4]:

# Solving for direct (M=0) transfer long and short arcs
ss_short0, ss_long0 = lambert_transfer(earth_departure, mars_arrival, revs=0)

fig, ax = plt.subplots(figsize=(5, 10))
op = StaticOrbitPlotter(ax=ax)
ax.set_title("Direct arc transfer ($M=0$)")

orbit_set = {ss_short0: ["Short0", "black"], ss_long0: ["Long0", "grey"]}

op.plot_body_orbit(Earth, EPOCH_DPT)
op.plot_body_orbit(Mars, EPOCH_ARR)

for ss in orbit_set:
    op.plot(ss, label=orbit_set[ss][0], color=orbit_set[ss][-1], trail=True)

# ### Solutions for M=1

# In[5]:

# Solving for M=1 long and short arc transfers
ss_short1, ss_long1 = lambert_transfer(earth_departure, mars_arrival, revs=1)

fig, ax = plt.subplots(figsize=(5, 10))
op = StaticOrbitPlotter(ax=ax)
ax.set_title("Direct arc transfer ($M=1$)")

orbit_set = {ss_short1: ["Short1", "black"], ss_long1: ["Long1", "grey"]}

op.plot_body_orbit(Earth, EPOCH_DPT)
Esempio n. 15
0
    """
    tru_anom = mean_anomaly + (2*eccentricity - (1/4)*eccentricity**3)*np.sin(mean_anomaly) +  (5/4)*np.sin(2*mean_anomaly)*eccentricity**(2) + (13/12)*np.sin(3*mean_anomaly)*eccentricity**3 *3
    return tru_anom


def dateUnpack(self, packed):
        """A package from mpcorgbet"""
        yearcode = {"I":"18","J":"19","K":"20"}
        daycode = "123456789ABCDEFGHIJKLMNOPQRSTUV"
        year = yearcode[packed[0]]+packed[1:3]
        month = daycode.index(packed[3])+1
        day = daycode.index(packed[4])+1
        return "%s/%s/%s" % (month, day, year)
###############################
#Main Execution

#Commands for getting mpcorgbet data
#first = mpcorbget.MPCORB("162269")
#epoch, mean_anomaly, argument_of_perihelion, longitude_of_ascendingnode, inclination, eccentricity, semimajor_axis,mean_daily_motion = returnOrbitalElements(first)

#Commands for getting eros data from txt file
i, e, a, ME, long, peri = ImportFromTxt('/home/alli/NugentResearch/eros.txt')
tru_anom = calculateTrueAnomaly(ME, e)
print(i, e, a, ME, long, peri)
#Creating poliastro orbit object
ss = Orbit.from_classical(Earth, a* u.AU, e* u.one, i* u.deg, long * u.deg, peri * u.deg, tru_anom * u.deg)
#Plotting Eros
plotter = StaticOrbitPlotter() #creating plotter class
plotter.plot(ss, label="Eros") #plotting Eros
plt.show()