orbit_plot
- ssapy.plotUtils.orbit_plot(r, t=None, title='', figsize=(7, 7), save_path=False, frame='gcrf', show=False)[source][source]
Plots the trajectory of one or more orbits in various views and coordinate frames.
This function visualizes the position data of one or more orbits in 2D and 3D plots. It supports different reference frames (e.g., GCRF, ITRF, Lunar) and allows customization of plot appearance, including figure size, title, and saving the output.
The function generates the following plots: - XY plane scatter plot with Earth/Moon markers and optional Lagrange points. - XZ plane scatter plot with Earth/Moon markers. - YZ plane scatter plot with Earth/Moon markers. - 3D scatter plot of the orbit(s) with Earth/Moon represented as spheres.
- Parameters:
r (numpy.ndarray or list of numpy.ndarray) – The position data of the orbit(s). Can be a single NumPy array for one orbit or a list of arrays for multiple orbits.
t (numpy.ndarray or list, optional) – Time data corresponding to the position data. Must match the shape of r or be a list of arrays for multiple orbits. Defaults to None.
title (str, optional) – The title of the plot. Defaults to an empty string.
figsize (tuple, optional) – The size of the figure in inches (width, height). Defaults to (7, 7).
save_path (str or bool, optional) – Path to save the plot. If False, the plot is not saved. Defaults to False.
frame (str, optional) – The reference frame for the plot. Accepted values are “gcrf”, “itrf”, “lunar”, “lunar fixed”, or “lunar axis”. Defaults to “gcrf”.
show (bool, optional) – Whether to display the plot. Defaults to False.
- Returns:
- A tuple containing:
fig (matplotlib.figure.Figure): The figure object.
axes (list): A list of subplot axes [ax1, ax2, ax3, ax4].
- Return type:
- Raises:
ValueError – If the input r or t is not in a valid format or if the specified frame is not recognized.
Notes
The function supports transformations between coordinate frames and adjusts the plot accordingly.
Orbital bodies (Earth, Moon) are represented as spheres, scaled appropriately.
Lagrange points are plotted for Lunar frames, with markers and labels.
The bounds of the plots are dynamically adjusted based on the input data.
The function allows saving the plot to a specified path and optionally displaying it.
The axes are styled with a black background and white labels/ticks for better visibility.