datasetOrbit Class

Ability to plot orbits from Datasets. Like CSV files.

Class Initialization

datasetOrbit(FeaturesExtra):
    def __init__(self, plot_title, name, fps=30):
  • plot_title (str): The title of the plot.

  • name (str): The name of the celestial object or dataset.

  • fps (int, optional): Frames per second for animation (default is 30).

Plot Styling

def datasetPlotStyle(self, background_color):
  • background_color (str): The background color of the plot (e.g., "dark_background" or "#F3EEEA").

This method is used to customize the appearance of the plot, including background color, axis colors, grid color, text and label colors, and more.

Data Loading and Plotting

def datasetCalculateOrbit(self, plot_steps, n_orbits, data=None, 
                        color=None, trajectory=False, sun=True, random_color=False,
                        delimiter=","):
  • plot_steps (int): The number of data points to plot for each orbit.

  • n_orbits (int): The number of orbits to display.

  • data (str, optional): The path to a CSV file containing orbital data (default is None).

  • color (str, optional): The color of the celestial object's orbit (default is None).

  • trajectory (bool, optional): Whether to plot the trajectory of the object (default is False).

  • sun (bool, optional): Whether to display the Sun at the origin (default is True).

  • random_color (bool, optional): Generate random colors for objects if not specified (default is False).

  • delimiter (str, optional): Delimiter used in the CSV file (default is ",").

This method loads orbital data from a CSV file and plots the orbits of celestial objects. You can specify various parameters such as color, trajectory, and whether to include the Sun.

Animation

def datasetAnimateOrbit(self, dpi, save=False, export_zoom=None, 
                     font_size="xx-small", export_folder=None,
                     x_lim=None, y_lim=None, z_lim=None,
                     x_label="X-Axis", y_label="Y-Axis", z_label="Z-Axis", animation_interval=40):
  • dpi (int): Dots per inch for the exported animation.

  • save (bool, optional): Whether to save the animation (default is False).

  • export_zoom (float, optional): Zoom factor for the animation (default is None).

  • font_size (str, optional): Font size for the legend (default is "xx-small").

  • export_folder (str, optional): Folder to save the animation if save is True (default is None).

  • x_lim (list, optional): Limits for the X-axis (default is None).

  • y_lim (list, optional): Limits for the Y-axis (default is None).

  • z_lim (list, optional): Limits for the Z-axis (default is None).

  • x_label (str, optional): Label for the X-axis (default is "X-Axis").

  • y_label (str, optional): Label for the Y-axis (default is "Y-Axis").

  • z_label (str, optional): Label for the Z-axis (default is "Z-Axis").

  • animation_interval (int, optional): Interval between animation frames (default is 40).

This method generates and displays an animated 3D plot of the celestial object's orbit. You can customize the animation settings, labels, and limits. If save is True, it also saves the animation as a GIF.

Limiting the Plot

def xLim(self, x_lim):
def yLim(self, y_lim):
def zLim(self, z_lim):
  • x_lim (list): List of two values specifying X-axis limits.

  • y_lim (list): List of two values specifying Y-axis limits.

  • z_lim (list): List of two values specifying Z-axis limits.

These methods allow you to set limits for the X, Y, and Z axes of the plot.

Labeling the Plot

def xLabel(self, x_label):
def yLabel(self, y_label):
def zLabel(self, z_label):
  • x_label (str): Label for the X-axis.

  • y_label (str): Label for the Y-axis.

  • z_label (str): Label for the Z-axis.

These methods allow you to set labels for the X, Y, and Z axes of the plot.

Setting Columns in the Dataset

def columnSemiMajorAxis(self, column_semi_major_axis):
def columnPerihelion(self, column_perihelion):
def columnEccentricity(self, column_eccentricity):
def columnInclination(self, column_inclination):
def columnLongitudeOfAscendingNode(self, column_longitude_of_ascending_node):
def columnArgumentOfPerihelion(self, column_argument_of_perihelion):
def columnColor(self, column_color):
def columnName(self, column_name):
  • column_semi_major_axis (str): The column name for semi-major axis data.

  • column_perihelion (str): The column name for perihelion data.

  • column_eccentricity (str): The column name for eccentricity data.

  • column_inclination (str): The column name for inclination data.

  • column_longitude_of_ascending_node (str): The column name for longitude of ascending node data.

  • column_argument_of_perihelion (str): The column name for argument of perihelion data.

  • column_color (str): The column name for object color data.

  • column_name (str): The column name for object name data.

These methods allow you to specify the names of columns in the CSV file that contain relevant orbital data.

Setting the Filename

def fileName(self, file_name):
  • file_name (str): The path to the CSV file containing orbital data.

Use this method to specify the filename of the dataset to be loaded.

Styling Parameters

def faceColor(self, face_color):
def paneColor(self, pane_color):
def gridColor(self, grid_color):
def orbitTransparency(self, orbit_transparency):
def labelColor(self, label_color):
def tickColor(self, tick_color):
  • face_color (str): Background color of the 3D plot.

  • pane_color (str): Color of the axes planes.

  • grid_color (str): Color of grid lines.

  • orbit_transparency (float): Transparency of orbit lines (0.0 to 1.0).

  • label_color (str): Color of axis labels.

  • tick_color (str): Color of axis ticks.

These methods allow you to customize various styling parameters for the plot.

Setting the Number of Rows Allowed

def numRowsAllowed(self, num_rows_allowed):
  • num_rows_allowed (int or list): The number of rows allowed to be loaded from the dataset. It can be an integer or a list of two integers to specify a range of rows.

Use this method to limit the number of rows loaded from the dataset.

Setting the Sun and Planet Size

def sunSize(self, sun_size):
def planetSize(self, planet_size):
  • sun_size (int): Size of the Sun marker in the plot.

  • planet_size (int): Size of the celestial object markers in the plot.

These methods allow you to set the size of the Sun and celestial objects 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

from orbitronomy import DatasetOrbit

test = datasetOrbit(plot_title="Test", name="Earth", fps=30)

# Styling
test.faceColor("#F3EEEA")
test.paneColor("#F3EEEA")
test.gridColor("#222831")
test.orbitTransparency(0.5)
test.labelColor("white")
test.tickColor("white")

test.datasetPlotStyle(background_color="dark_background")

# Name of the dataset file
test.fileName("datasets/Planetary-Satellite-Data.csv")

# Set columns in the dataset
test.columnSemiMajorAxis("semi_major_axis")
test.columnPerihelion("perihelion")
test.columnEccentricity("eccentricity")
test.columnInclination("inclination")
test.columnLongitudeOfAscendingNode("longitude_of_ascending_node")
test.columnArgumentOfPerihelion("argument_of_perihelion")
test.columnColor("color")
test.columnName("name")

test.sunSize(1000)
test.planetSize(100)

# Enable inclination observation plot with red color
test.inclinationPlot(color="red")

# Calculate and plot orbits
test.datasetCalculateOrbit(plot_steps=1000, n_orbits=12, color="yellow", 
                            random_color=True, trajectory=True, sun=True,
                            inclinationObserver=True, 
                            display_name=True, fontsize=12, 
                            fontweight="normal", fontcolor="black"
                            delimiter=";")

# Set plot limits and labels
test.xLim([40, 40])
test.yLim([40, 40])
test.zLim([0.1, 0.1])

test.xLabel("X-Axis")
test.yLabel("Y-Axis")
test.zLabel("Z-Axis")

# Create and display the animation
test.datasetAnimateOrbit(dpi=250, save=False, export_zoom=3, font_size="xx-small", animation_interval=40)

This example demonstrates how to use the datasetOrbit class to create and customize 3D orbital plots for celestial objects. You can customize various aspects of the plot, load data from a CSV file, and create an animated orbit plot with specific styling and parameters.

Last updated