This repository was archived by the owner on Oct 14, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 14, 2023. It is now read-only.
Uncaught error in plotting #1021
Copy link
Copy link
Closed
Labels
Description
This code:
from poliastro.bodies import Sun
from poliastro.ephem import Ephem
from poliastro.plotting import OrbitPlotter2D
epochs = time_range(..., end=...) # TBC
earth = Ephem.from_body(Earth, epochs)
plotter = OrbitPlotter2D()
plotter.set_attractor(Sun)
plotter.plot_ephem(earth)Causes this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-130-a5728741413f> in <module>
2
3 plotter.set_attractor(Sun)
----> 4 plotter.plot_ephem(earth)
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/core.py in plot_ephem(self, ephem, epoch, label, color, trail)
118
119 """
--> 120 super().plot_ephem(ephem, epoch, label=label, color=color, trail=trail)
121
122 if not self._figure._in_batch_mode:
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/_base.py in plot_ephem(self, ephem, epoch, label, color, trail)
286 # Do not return the result of self._plot
287 # This behavior might be overriden by subclasses
--> 288 self._plot_ephem(ephem, epoch, label=label, color=color, trail=trail)
289
290
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/_base.py in _plot_ephem(self, ephem, epoch, label, color, trail)
200 r0 = None
201
--> 202 return self.__add_trajectory(
203 coordinates, r0, label=str(label), colors=colors, dashed=False
204 )
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/_base.py in __add_trajectory(self, coordinates, position, label, colors, dashed)
119 self._trajectories.append(trajectory)
120
--> 121 self._redraw_attractor()
122
123 trace_coordinates, trace_position = self.__plot_coordinates_and_position(
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/_base.py in _redraw_attractor(self)
77 self._clear_attractor()
78
---> 79 self._draw_sphere(
80 self._attractor_radius, color, self._attractor.name,
81 )
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/core.py in _draw_sphere(self, radius, color, name, center)
275
276 def _draw_sphere(self, radius, color, name, center=[0, 0, 0] * u.km):
--> 277 x_center, y_center = self._project(
278 center[None]
279 ) # Indexing trick to add one extra dimension
~/.pyenv/versions/seminar38/lib/python3.8/site-packages/poliastro/plotting/_base.py in _project(self, rr)
296
297 def _project(self, rr):
--> 298 rr_proj = rr - rr.dot(self._frame[2])[:, None] * self._frame[2]
299 x = rr_proj.dot(self._frame[0])
300 y = rr_proj.dot(self._frame[1])
TypeError: 'NoneType' object is not subscriptable
Activity
astrojuanlu commentedon Oct 4, 2020
Prospective contributors:
StaticOrbitPlotteravoids this uncaught error by doing this:poliastro/src/poliastro/plotting/static.py
Lines 106 to 110 in 6ee8e93
We should do the same in
OrbitPlotter2D, and add a test.clacri commentedon Oct 4, 2020
I would like to take care of this issue :) I'm one of the participants of HacktoberfestES and arrived here thanks to @astrojuanlu
astrojuanlu commentedon Oct 4, 2020
Awesome! All yours @clacri :)
my attempt to solve issue poliastro#1021
my attempt to solve issue poliastro#1021
Merge pull request #1028 from clacri/claudia_dev_poli