Plotting in 3D

[1]:
import numpy as np

from poliastro.examples import *
from poliastro.plotting import *

from plotly.offline import init_notebook_mode

init_notebook_mode(connected=True)
[2]:
frame = plot3d(churi)
[3]:
frame = OrbitPlotter3D()

frame.plot(churi)
frame.plot(Orbit.from_body_ephem(Earth))

frame.show()
/home/juanlu/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py:502: UserWarning:

Frame <class 'astropy.coordinates.builtin_frames.icrs.ICRS'> does not support 'obstime', time values were not returned

[4]:
frame = OrbitPlotter3D()

frame.plot(molniya)
frame.plot(Orbit.from_body_ephem(Earth))

frame.show()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-4-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)
    319             color = next(self._color_cycle)
    320
--> 321         self.set_attractor(orbit.attractor)
    322         self._redraw_attractor(orbit.r_p * 0.15)  # Arbitrary threshold
    323

~/Development/poliastro/poliastro-library/src/poliastro/plotting.py in set_attractor(self, attractor)
    270
    271         elif attractor is not self._attractor:
--> 272             raise NotImplementedError("Attractor has already been set to {}.".format(self._attractor.name))
    273
    274     def _redraw_attractor(self, min_radius=0 * u.km):

NotImplementedError: Attractor has already been set to Earth.
[5]:
frame = OrbitPlotter3D()

frame.plot(molniya)
frame.plot(iss)

frame.show()
[6]:
frame = OrbitPlotter3D()

#frame.plot(molniya)
frame.plot(iss)

frame.show()
[7]:
frame = OrbitPlotter3D()

frame.set_attractor(Earth)

frame.show()
[8]:
from poliastro.neos import neows
from poliastro.examples import iss

eros = neows.orbit_from_name('eros')
[9]:
frame = OrbitPlotter3D()

frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot(eros, label='eros')

frame.show()
/home/juanlu/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py:502: UserWarning:

Frame <class 'astropy.coordinates.builtin_frames.icrs.ICRS'> does not support 'obstime', time values were not returned

[10]:
from astropy.coordinates import get_body_barycentric_posvel
from poliastro.util import time_range
[11]:
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))
[12]:
frame = OrbitPlotter3D()

frame.set_attractor(Sun)
frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot_trajectory(rr_earth, label=Earth)
frame.show()
[13]:
frame = OrbitPlotter3D()

frame.plot(eros, label='eros')
frame.plot_trajectory(rr_earth, label=Earth)

frame.show()