SimpleOrbit Class
This class gives you the ability to plot orbits in singles, or using an array/list.
Class Initialization
class SimpleOrbit(FeaturesExtra):
def __init__(self, plot_title, name, fps=30):
plot_title
(str): The title of the orbital plot.name
(str): The name of the celestial object you want to plot.fps
(int): Frames per second for the animation (default is 30).
This class is initialized with a plot title, object name, and an optional frames per second value for the animation.
Plot Styling
Setting Background Color
def faceColor(self, face_color):
face_color
(str): Background color of the 3D plot.
Set the background color of the plot using this method. You can specify the color as a name (e.g., "white") or a hexadecimal code (e.g., "#F3EEEA").
Setting Axes Plane Color
def paneColor(self, pane_color):
pane_color
(str): Color of the axes planes.
Change the color of the planes representing the X, Y, and Z axes using this method.
Setting Grid Color
def gridColor(self, grid_color):
grid_color
(str): Color of grid lines.
Customize the color of the grid lines in the 3D plot to provide reference points.
Setting Orbit Transparency
def orbitTransparency(self, orbit_transparency):
orbit_transparency
(float): Transparency of orbit lines (0.0 to 1.0).
Control the transparency of the plotted orbit lines. A value of 0.0 means fully transparent, while 1.0 means fully opaque.
Setting Label Color
def labelColor(self, label_color):
label_color
(str): Color of axis labels.
Customize the color of the X, Y, and Z axis labels for better visibility or style matching.
Setting Tick Color
def tickColor(self, tick_color):
tick_color
(str): Color of axis ticks.
Specify the color of the ticks on the X, Y, and Z axes to align them with the plot's style.
Data Input and Plot Generation
Generating Orbital Plot
def calculateOrbit(self, plot_steps, n_orbits, data=None, color=None, trajectory=False, sun=True):
plot_steps
(int): Number of steps for plotting the orbit.n_orbits
(int): Number of orbital periods to plot.data
(list of lists): List of celestial objects' data. Each sublist should contain the name, semi-major axis, perihelion, eccentricity, inclination, longitude of ascending node, argument of perihelion, and color (optional).color
(str): Default color for celestial objects (optional).trajectory
(bool): Whether to plot the object's trajectory (default is False).sun
(bool): Whether to plot the Sun at the center (default is True).inclinationObserver
(bool): Visualize the inclination of the orbitsdisplay_name
(bool): Enable the names/IDs of the objects you are plotting.
Use this method to generate 3D orbital plots. You can either provide a list of celestial object data or specify the orbital parameters individually for a single object.
Animating the Orbit
def animateOrbit(self, dpi, save=False, export_zoom=None, font_size="xx-small", export_folder=None, animation_interval=40, x_lim=None, y_lim=None, z_lim=None, x_label="X-Axis", y_label="Y-Axis", z_label="Z-Axis"):
dpi
(int): Dots per inch for the animation.save
(bool): Whether to save the animation as a GIF (default is False).export_zoom
(int): Zoom level for the exported GIF (optional).font_size
(str): Font size for the legend (optional).export_folder
(str): Folder to save the GIF (optional).animation_interval
(int): Interval between animation frames (default is 40).x_lim
(list): List containing the X-axis limits (optional).y_lim
(list): List containing the Y-axis limits (optional).z_lim
(list): List containing the Z-axis limits (optional).x_label
(str): Label for the X-axis (optional).y_label
(str): Label for the Y-axis (optional).z_label
(str): Label for the Z-axis (optional).
This method animates the generated orbital plot. You can specify various parameters like export settings, axis labels, and animation interval.
Setting Axis Limits
def xLim(self, x_lim):
def yLim(self, y_lim):
def zLim(self, z_lim):
x_lim
,y_lim
,z_lim
(list): Lists containing axis limits.
You can use these methods to set custom limits for the X, Y, and Z axes to focus on specific regions of the plot.
Setting Axis Labels
def xLabel(self, x_label):
def yLabel(self, y_label):
def zLabel(self, z_label):
x_label
,y_label
,z_label
(str): Labels for the X, Y, and Z axes.
Use these methods to label the axes in the plot with the desired text.
Individual Object Details
You can set individual orbital parameters for a single object using the following methods:
def semiMajorAxis(self, semi_major_axis):
def perihelion(self, perihelion):
def eccentricity(self, eccentricity):
def inclination(self, inclination):
def longitudeOfAscendingNode(self, longitude_of_ascending_node):
def argumentOfPerihelion(self, argument_of_perihelion):
def sunSize(self, sun_size):
def planetSize(self, planet_size):
semi_major_axis
: Semi-major axis of the object's orbit.perihelion
: Perihelion distance of the object's orbit.eccentricity
: Eccentricity of the object's orbit.inclination
: Inclination of the object's orbit.longitude_of_ascending_node
: Longitude of the ascending node of the object's orbit.argument_of_perihelion
: Argument of perihelion of the object's orbit.sun_size
: Size of the Sun in the plot.planet_size
: Size of the celestial object in the plot.
Inclination Plot
def inclinationPlot(self, color):
color
(str): Color of the inclination plot.
Use this method to enable plotting of inclination and specify the color for the inclination plot.
Example Usage
# Import the SimpleOrbit class and other required libraries
from orbitronomy import SimpleOrbit
# Create a SimpleOrbit object with a plot title and object name
test = SimpleOrbit(plot_title="Test", name="Earth", fps=30)
# Styling the plot
test.faceColor("black")
test.paneColor("black")
test.gridColor("#222831")
test.orbitTransparency(0.5)
test.labelColor("white")
test.tickColor("white")
test.plotStyle(background_color="dark_background")
# Define data for multiple celestial objects or set parameters individually for a single object
data = [
["object1", 1, 0.983289891, 0.01671123, 15, 0, 0, "green"],
["object2", 1.5, 0.483289891, 0.02671123, 6, 0, 0, "yellow"],
["object3", 1.3, 0.683289891, 0.01671123, 2, 0, 0, "red"]
]
# cool atom shape
# data = [
# ['electron1', 1.0, 0.8, 0.2, 0.0, 0, 0, 'red'],
# ['electron2', 1.0, 0.8, 0.2, 30.0, 0, 0, 'red'],
# ['electron3', 1.0, 0.8, 0.2, 60.0, 0, 0, 'red'],
# ['electron4', 1.0, 0.8, 0.2, 90.0, 0, 0, 'red'],
# ['electron5', 1.0, 0.8, 0.2, 120.0, 0, 0, 'red'],
# ['electron6', 1.0, 0.8, 0.2, 150.0, 0, 0, 'red']]
# cool atom shape 2x less
# data = [
# ['electron1', 1.0, 0.2, 0.6, 0.0, 0, 0, 'red'],
# ['electron2', 1.0, 0.2, 0.6, 60.0, 0, 0, 'red'],
# ['electron3', 1.0, 0.2, 0.6, 120.0, 0, 0, 'red'],
# ]
# you can also use the following instead of data if you want to plot a single object
# test.semiMajorAxis(1)
# test.perihelion(0.983289891)
# test.eccentricity(0.01671123)
# test.inclination(0)
# test.longitudeOfAscendingNode(0)
# test.argumentOfPerihelion(0)
# Calculate and plot the orbits
test.sunSize(1000)
test.planetSize(100)
# Enable inclination observation plot with red color
test.inclinationPlot(color="red")
test.calculateOrbit(plot_steps=1000, n_orbits=4, data=data,
# color="blue",
trajectory=True, sun=True,
inclinationObserver=False,
display_name=True, fontsize=12, fontweight="normal")
# Set axis labels and limits
test.xLabel("X-Axis")
test.yLabel("Y-Axis")
test.zLabel("Z-Axis")
test.xLim([20, 20])
test.yLim([20, 20])
test.zLim([1, 1])
# Animate and save the orbit plot as a GIF
test.animateOrbit(dpi=250, save=False, export_zoom=3, font_size="xx-small", export_folder="results", animation_interval=10)
This example demonstrates how to create and customize orbital plots using the SimpleOrbit
class. You can define data for multiple celestial objects or set parameters individually for a single object, style the plot, and generate an animated orbit visualization.
Last updated
Was this helpful?