Plotting in 3D¶
In [1]:
# Temporary hack, see https://github.com/poliastro/poliastro/issues/281
from IPython.display import HTML
HTML('<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>')
Out[1]:
In [2]:
import numpy as np
from poliastro.examples import *
from poliastro.plotting import *
from plotly.offline import init_notebook_mode
init_notebook_mode(connected=True)
In [3]:
frame = plot3d(churi)
In [4]:
frame = OrbitPlotter3D()
frame.plot(churi)
frame.plot(Orbit.from_body_ephem(Earth))
frame.show()
In [5]:
frame = OrbitPlotter3D()
frame.plot(molniya)
frame.plot(Orbit.from_body_ephem(Earth))
frame.show()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-5-74067206d9af> in <module>()
2
3 frame.plot(molniya)
----> 4 frame.plot(Orbit.from_body_ephem(Earth))
5
6 frame.show()
~/Development/poliastro/poliastro-library/src/poliastro/plotting.py in plot(self, orbit, label, color)
305 color = next(self._color_cycle)
306
--> 307 self.set_attractor(orbit.attractor)
308
309 self._redraw_attractor(orbit.r_p * 0.15) # Arbitrary threshold
~/Development/poliastro/poliastro-library/src/poliastro/plotting.py in set_attractor(self, attractor)
283
284 elif attractor is not self._attractor:
--> 285 raise NotImplementedError("Attractor has already been set to {}.".format(self._attractor.name))
286
287 @u.quantity_input(elev=u.rad, azim=u.rad)
NotImplementedError: Attractor has already been set to Earth.
In [6]:
frame = OrbitPlotter3D()
frame.plot(molniya)
frame.plot(iss)
frame.show()
In [7]:
frame = OrbitPlotter3D()
#frame.plot(molniya)
frame.plot(iss)
frame.show()
In [8]:
frame = OrbitPlotter3D()
frame.set_attractor(Earth)
frame.show()
In [9]:
from poliastro.neos import neows
from poliastro.examples import iss
eros = neows.orbit_from_name('eros')
In [10]:
frame = OrbitPlotter3D()
frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot(eros, label='eros')
frame.show()
In [11]:
from astropy.coordinates import get_body_barycentric_posvel
from poliastro.util import time_range
In [12]:
date_launch = time.Time('2011-11-26 15:02', scale='utc')
date_arrival = time.Time('2012-08-06 05:17', scale='utc')
rr_earth, _ = get_body_barycentric_posvel("earth", time_range(date_launch, end=date_arrival, periods=50))
In [13]:
frame = OrbitPlotter3D()
frame.set_attractor(Sun)
frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot_trajectory(rr_earth, label=Earth)
frame.show()
In [14]:
frame = OrbitPlotter3D()
frame.plot(eros, label='eros')
frame.plot_trajectory(rr_earth, label=Earth)
frame.show()