poliastro2.plotting

Description

This subpackage provides routines for visualizing orbital trajectories and related astrodynamics data using various plotting techniques.

Modules

  • gabbard: Functions to generate Gabbard diagrams.

  • misc: Miscellaneous plotting utilities.

  • porkchop: Porkchop plot routines for transfer analysis.

  • tisserand: Functions related to Tisserand’s figure.

  • util: Helper functions for plotting.

  • orbit: Subpackage for orbit-specific plotting routines.

class poliastro2.plotting.GabbardPlotter(ax=None, dark=False, altitude_unit=Unit('km'), period_unit=Unit('min'))

GabbardPlotter class.

_get_orbit_property_list(orbits)
_set_legend(epoch, label)
_static_gabbard_plot(orbits)

Plots a Static Gabbard Plot given a list of Orbits.

Parameters:

orbits (Orbit List) – The Orbits whose perigee and apogee will be plotted.

plot_orbits(orbits, label='')
class poliastro2.plotting.OrbitPlotter(backend=None, num_points=150, *, plane=None, length_scale_units=Unit('km'))

A base class containing common attributes and methods for plotters.

_add_trajectory(trajectory)

Add a new trajectory to the scene.

Parameters:

trajectory (Trajectory) – An object for modeling trajectories.

Returns:

  • trace_coordinates (object) – An object representing the trace of the coordinates in the scene.

  • trace_position (object) – An object representing the trace of the position in the scene.

_create_trajectory(coordinates, position, *, colors=None, dashed=False, label=None)

Create a new Trajectory instance.

Parameters:
  • coordinates (CartesianRepresentation) – Trajectory to plot.

  • position (ndarray, optional) – Position of the body along its orbit.

  • colors (str, optional) – A list of colors for the points of the trajectory.

  • dashed (bool, optional) – True to use a dashed line style. False otherwise.

  • label (str, optional) – Label of the orbit.

Returns:

An object for modeling trajectories.

Return type:

Trajectory

_plot_attractor()

Plot the scene attractor.

Notes

This method allows to select a sensible value for the radius of the attractor.

_project(vec)

Project the vector into the frame of the orbit plotter.

Parameters:

vec (ndarray) – The vector to be projected into the frame of the orbit plotter.

Returns:

A tuple containing the x, y, and z coordinates of the vector projected into the frame of the orbit plotter.

Return type:

tuple(float, float, float)

_redraw()

Redraw the the whole scene.

_unplot_attractor()

Remove the attractor from the scene.

property backend

Backend instance used by the plotter.

Returns:

An instance of OrbitPlotterBackend used for rendendering the scene.

Return type:

OrbitPlotterBackend

property length_scale_units

Units of length used for representing distances.

Returns:

length_units – Desired length units to be used when representing distances.

Return type:

Unit

property plane

Reference plane to be used when drawing the scene.

Returns:

Reference plane to be used when drawing the scene. Default to

Return type:

Plane, optional

plot(orbit, *, color=None, label=None, trail=False, dashed=True)

Plot state and osculating orbit in their plane.

Parameters:
  • orbit (Orbit) – Orbit to plot.

  • color (str, optional) – Color of the line and the position.

  • label (str, optional) – Label of the orbit.

  • trail (bool, optional) – Fade the orbit trail, default to False.

  • dashed (bool, optional) – True to use a dashed line style. False otherwise.

plot_body_orbit(body, epoch, *, label=None, color=None, trail=False)

Plot complete revolution of body and current position.

Parameters:
  • body (poliastro.bodies.SolarSystemPlanet) – Body.

  • epoch (astropy.time.Time) – Epoch of current position.

  • label (str, optional) – Label of the orbit, default to the name of the body.

  • color (str, optional) – Color of the line and the position.

  • trail (bool, optional) – Fade the orbit trail, default to False.

plot_coordinates(coordinates, *, position=None, label=None, color=None, trail=False, dashed=False)

Plot a precomputed trajectory.

Parameters:
  • coordinates (CartesianRepresentation) – Trajectory to plot.

  • label (str, optional) – Label of the trajectory.

  • color (str, optional) – Color of the trajectory.

  • trail (bool, optional) – Fade the orbit trail, default to False.

  • dashed (bool, optional) – True to use a dashed line style. False otherwise.

Raises:

ValueError – An attractor must be set first.

plot_ephem(ephem, epoch=None, *, label=None, color=None, trail=False)

Plot Ephem object over its sampling period.

Parameters:
  • ephem (Ephem) – Ephemerides to plot.

  • epoch (astropy.time.Time, optional) – Epoch of the current position, None is used if not given.

  • label (str, optional) – Label of the orbit, default to the name of the body.

  • color (str, optional) – Color of the line and the position.

  • trail (bool, optional) – Fade the orbit trail, default to False.

plot_maneuver(initial_orbit, maneuver, label=None, color=None, trail=False)

Plot the maneuver trajectory applied to the provided initial orbit.

Parameters:
  • initial_orbit (Orbit) – The base orbit for which the maneuver will be applied.

  • maneuver (Maneuver) – The maneuver to be plotted.

  • label (str, optional) – Label of the trajectory.

  • color (str, optional) – Color of the trajectory.

  • trail (bool, optional) – Fade the orbit trail, default to False.

plot_trajectory(coordinates, *, label=None, color=None, trail=False, dashed=False)

Plot a precomputed trajectory.

Parameters:
  • coordinates (CartesianRepresentation) – Trajectory to plot.

  • label (str, optional) – Label of the trajectory.

  • color (str, optional) – Color of the trajectory.

  • trail (bool, optional) – Fade the orbit trail, default to False.

  • dashed (bool, optional) – True to use a dashed line style. False otherwise.

Raises:

ValueError – An attractor must be set first.

set_attractor(attractor)

Set the desired plotting attractor.

Parameters:

attractor (Body) – Central body.

Raises:

NotImplementedError – Raised if attractor is already set.

set_body_frame(body, epoch=None)

Set perifocal frame based on the orbit of a body at a particular epoch if given.

Parameters:
  • body (poliastro.bodies.SolarSystemPlanet) – Body.

  • epoch (astropy.time.Time, optional) – Epoch of current position.

set_orbit_frame(orbit)

Set the perifocal frame based on an orbit.

Parameters:

orbit (Orbit) – Orbit to use as frame.

set_view(elevation_angle, azimuth_angle, distance=<Quantity 5. km>)

Change 3D view by setting the elevation, azimuth and distance.

Parameters:
  • elevation_angle (Quantity) – Desired elevation angle of the camera.

  • azimuth_angle (Quantity) – Desired azimuth angle of the camera.

  • distance (optional, Quantity) – Desired distance of the camera to the scene.

show()

Render the plot.

property trajectories

List with all the Trajectory instances used in the plotter.

Returns:

A list containing all the trajectories rendered in the scene.

Return type:

List[Trajectory]

class poliastro2.plotting.PorkchopPlotter(departure_body, target_body, launch_span, arrival_span, ax=None, tfl=True, vhp=True, max_c3=<Quantity 45. km2 / s2>, max_vhp=<Quantity 5. km / s>)

Class Implementation for Porkchop Plot.

Parameters:
  • departure_body (poliastro.bodies.Body) – Body from which departure is done

  • target_body (poliastro.bodies.Body) – Body for targetting

  • launch_span (astropy.time.Time) – Time span for launch

  • arrival_span (astropy.time.Time) – Time span for arrival

  • ax (matplotlib.axes.Axes) – For custom figures

  • tfl (bool) – For plotting time flight contour lines

  • vhp (bool) – For plotting arrival velocity contour lines

  • max_c3 (float) – Sets the maximum C3 value for porkchop

  • max_vhp (float) – Sets the maximum arrival velocity for porkchop

porkchop()

Plots porkchop between two bodies.

Returns:

  • dv_launch (numpy.ndarray) – Launch delta v

  • dv_arrival (numpy.ndarray) – Arrival delta v

  • c3_launch (numpy.ndarray) – Characteristic launch energy

  • c3_arrrival (numpy.ndarray) – Characteristic arrival energy

  • tof (numpy.ndarray) – Time of flight for each transfer

Examples

>>> from poliastro.plotting.porkchop import PorkchopPlotter
>>> from poliastro.bodies import Earth, Mars
>>> from poliastro.util import time_range
>>> launch_span = time_range("2005-04-30", end="2005-10-07")
>>> arrival_span = time_range("2005-11-16", end="2006-12-21")
>>> porkchop_plot = PorkchopPlotter(Earth, Mars, launch_span, arrival_span)
>>> dv_launch, dev_dpt, c3dpt, c3arr, tof = porkchop_plot.porkchop()
class poliastro2.plotting.TisserandPlotter(kind=TisserandKind.APSIS, axes=None)

Generates Tisserand figures.

_build_lines(RR_P, RR_A, EE, TT, color)

Collect lines and append them to internal data.

Parameters:

data (list) – Array containing [RR_P, RR_A, EE, TT, color]

Returns:

lines – Plotting lines for the Tisserand

Return type:

list

_solve_tisserand(body, vinf_span, num_contours, alpha_lim=(0, 3.141592653589793), N=100)

Solves all possible Tisserand lines with a meshgrid workflow.

Parameters:
  • body (Body) – Body to be plotted Tisserand

  • vinf_array (Quantity) – Desired Vinf for the flyby

  • num_contours (int) – Number of contour lines for flyby speed

  • alpha_lim (tuple) – Minimum and maximum flyby angles.

  • N (int) – Number of points for flyby angle.

Notes

The algorithm for generating Tisserand plots is the one depicted in “Preliminary Trajectory Design of a Mission to Enceladus” by David Falcato Fialho Palma, section 3.6

plot(body, vinf_span, num_contours=10, color=None)

Plots body Tisserand for given amount of solutions within Vinf span.

Parameters:
  • body (Body) – Body to be plotted Tisserand

  • vinf_span (tuple) – Minimum and maximum Vinf velocities

  • num_contours (int) – Number of points to iterate over previously defined velocities

  • color (str) – String representing for the color lines

Returns:

self.ax – Apsis tisserand is the default plotting option

Return type:

Axes

plot_line(body, vinf, alpha_lim=(0, 3.141592653589793), color=None)

Plots body Tisserand line within flyby angle.

Parameters:
  • body (Body) – Body to be plotted Tisserand

  • vinf (Quantity) – Vinf velocity line

  • alpha_lim (tuple) – Minimum and maximum flyby angles

  • color (str) – String representing for the color lines

Returns:

self.ax – Apsis tisserand is the default plotting option

Return type:

Axes

Modules

gabbard

misc

orbit

Description This subpackage focuses on plotting routines specifically for orbital data. It provides utilities to visualize orbits and related parameters.

porkchop

This is the implementation of porkchop plot.

tisserand

Generates Tisserand plots.

util