ast2000tools.solar_system.SolarSystem

class ast2000tools.solar_system.SolarSystem(seed, data_path=None, has_moons=True, verbose=True)

Bases: object

Represents a random solar system.

Given an integer seed, a randomized solar system containing a star and multiple planets is generated.

Parameters
  • seed (int) – The seed to use when generating random solar system properties.

  • data_path (str, optional) – Specifies the path to the directory where output XML files should be stored (e.g. the MCAst data folder). By default, a folder called “XMLs” is created in the working directory.

  • has_moons (bool, optional) – Whether the generated planets should be visualized with moons. Setting to False increases performance. Default is True.

  • verbose (bool, optional) – Whether to print non-essential status messages. Default is True.

Illustration of orbital parameters

../_images/orbital_parameters.png

Methods

generate_binary_star_orbit_video(times, …)

Generates a video of the given trajectories of a planet and two stars that can be played in SSView.

generate_landing_video(times, …[, …])

Generates a video of the given lander trajectory that can be played in SSView.

generate_orbit_video(times, planet_positions)

Generates a video of the given planet trajectories that can be played in SSView.

generate_system_snapshot([filename])

Generates a snapshot of the initial state of the solar system that can be viewed in SSView.

print_info()

Prints out info about the solar system.

verify_planet_positions(simulation_duration, …)

Verifies that your simulation of the planet trajectories around the star gives a reasonable result.

Attributes

aphelion_angles

Array of shape (number_of_planets,) containing the angle between the x-axis and the aphelion direction of each planet, in radians.

atmospheric_densities

Array of shape (number_of_planets,) containing the atmospheric density at the surface of each planet, in kilograms per cubic meter.

data_path

The path to the directory where output XML files will be stored.

eccentricities

Array of shape (number_of_planets,) containing the eccentricity of each planet.

has_moons

Whether the generated planets will be visualized with moons.

initial_orbital_angles

Array of shape (number_of_planets,) containing the angle between the x-axis and the initial position of each planet, in radians.

initial_positions

Array of shape (2, number_of_planets) containing the initial x and y-position of each planet relative to the star, in astronomical units.

initial_velocities

Array of shape (2, number_of_planets) containing the initial x and y-velocity of each planet relative to the star, in astronomical units per year.

masses

Array of shape (number_of_planets,) containing the mass of each planet in solar masses.

number_of_planets

The number of planets in the solar system.

radii

Array of shape (number_of_planets,) containing the radius of each planet in kilometers.

rotational_periods

Array of shape (number_of_planets,) containing the rotational period of each planet in days.

seed

The seed used to generate random solar system properties.

semi_major_axes

Array of shape (number_of_planets,) containing the semi-major axis of each planet in astronomical units.

star_color

The RGB color of the star.

star_mass

The mass of the star in solar masses.

star_radius

The radius of the star in kilometers.

star_temperature

The surface temperature of the star in kelvin.

types

Tuple of length number_of_planets containing strings denoting the type of each planet.

verbose

Whether non-essential status messages will be printed.

property seed

The seed used to generate random solar system properties.

Type

int

property data_path

The path to the directory where output XML files will be stored.

Type

str

property has_moons

Whether the generated planets will be visualized with moons.

Type

bool

property verbose

Whether non-essential status messages will be printed.

Type

bool

property star_temperature

The surface temperature of the star in kelvin.

Type

float

property star_mass

The mass of the star in solar masses.

Type

float

property star_radius

The radius of the star in kilometers.

Type

float

property star_color

The RGB color of the star.

Type

tuple(float)

property number_of_planets

The number of planets in the solar system.

Type

int

property semi_major_axes

Array of shape (number_of_planets,) containing the semi-major axis of each planet in astronomical units.

Type

1-D numpy.ndarray

property eccentricities

Array of shape (number_of_planets,) containing the eccentricity of each planet.

Type

1-D numpy.ndarray

property masses

Array of shape (number_of_planets,) containing the mass of each planet in solar masses.

Type

1-D numpy.ndarray

property radii

Array of shape (number_of_planets,) containing the radius of each planet in kilometers.

Type

1-D numpy.ndarray

property initial_orbital_angles

Array of shape (number_of_planets,) containing the angle between the x-axis and the initial position of each planet, in radians.

Type

1-D numpy.ndarray

property aphelion_angles

Array of shape (number_of_planets,) containing the angle between the x-axis and the aphelion direction of each planet, in radians.

Type

1-D numpy.ndarray

property rotational_periods

Array of shape (number_of_planets,) containing the rotational period of each planet in days.

Type

1-D numpy.ndarray

property initial_positions

Array of shape (2, number_of_planets) containing the initial x and y-position of each planet relative to the star, in astronomical units.

Type

2-D numpy.ndarray

property initial_velocities

Array of shape (2, number_of_planets) containing the initial x and y-velocity of each planet relative to the star, in astronomical units per year.

Type

2-D numpy.ndarray

property atmospheric_densities

Array of shape (number_of_planets,) containing the atmospheric density at the surface of each planet, in kilograms per cubic meter.

Type

1-D numpy.ndarray

property types

Tuple of length number_of_planets containing strings denoting the type of each planet.

Type

tuple(str)

print_info()

Prints out info about the solar system.

verify_planet_positions(simulation_duration, planet_positions, filename=None, number_of_output_points=None)

Verifies that your simulation of the planet trajectories around the star gives a reasonable result.

Note

If you get an OSError when the output file is being saved after successful verification, reduce the number of output points by specifying the number_of_output_points argument.

Parameters
  • simulation_duration (float) – The total duration of the simulation (starting from time zero), in years. Must be at least 20 orbital periods of your home planet.

  • planet_positions (3-D array_like) – Array of shape (2, number_of_planets, number_of_times) containing the x and y-position of each planet at each time, in astronomical units relative to the star. The positions are assumed to be specified at uniformly spaced times over the simulation duration. The number of times has to be at least 1000.

  • filename (str, optional) – Specifies the filename/path to save the exact trajectories of the planets to after your trajectories have been verified. They are stored in the binary NumPy .npz format as a dictionary-like object with keys ‘times’ and ‘planet_positions’, The ‘times’ entry is a 1D array of times with length number_of_output_points if this argument was specified, otherwise number_of_times. The ‘planet_positions’ entry is an array of positions with shape (2, number_of_planets, len(times)). By default, no file is generated.

  • number_of_output_points (int, optional) – The number of exact trajectory points to include in the output .npz file (if applicable). By default, the number of output points will be the same as the number of input points. If your trajectories contain a very large number of points, consider modifying this argument to reduce the output size.

Raises

RuntimeError – When the input positions are too far from the correct positions.

generate_system_snapshot(filename='system_snapshot.xml')

Generates a snapshot of the initial state of the solar system that can be viewed in SSView.

Parameters

filename (str, optional) – Name of the XML file to generate inside the data directory. Default is “system_snapshot.xml”.

generate_orbit_video(times, planet_positions, number_of_frames=None, reduce_other_periods=True, filename='orbit_video.xml')

Generates a video of the given planet trajectories that can be played in SSView.

Note

The times and positions for the output frames will be sampled uniformly from times and planet_positions.

Parameters
  • times (1-D array_like) – Array containing the time of each frame in years. Must have a size of at least 100.

  • planet_positions (3-D array_like) – Array of shape (2, number_of_planets, len(times)) containing the x and y-position of each planet at each time, in astronomical units relative to the star.

  • number_of_frames (int, optional) – The number of video frames to generate. By default, a suitable number is determined automatically. Must be at least 100 if specified.

  • reduce_other_periods (bool, optional) – Whether to slow down the rotation of planets that are rotating too fast to be animated properly, and also do the same for the orbits and rotations of moons. Note that the orbital speeds of the planets are not touched. Default is True.

  • filename (str, optional) – Name of the XML file to generate inside the data directory. Default is “orbit_video.xml”.

generate_binary_star_orbit_video(times, planet_positions, star_1_positions, star_2_positions, number_of_frames=1000, filename='binary_star_video.xml')

Generates a video of the given trajectories of a planet and two stars that can be played in SSView.

Note

The times and positions for the output frames will be sampled uniformly from times and the inputted position arrays.

Parameters
  • times (1-D array_like) – Array containing the time of each frame in years. Must have a size of at least 100.

  • planet_positions (2-D array_like) – Array of shape (2, len(times)) containing the x and y-position of the planet at each time, in astronomical units relative to the system center.

  • star_1_positions (2-D array_like) – Array of shape (2, len(times)) containing the x and y-position of star 1 at each time, in astronomical units relative to the system center.

  • star_2_positions (2-D array_like) – Array of shape (2, len(times)) containing the x and y-position of star 2 at each time, in astronomical units relative to the system center.

  • number_of_frames (int, optional) – The number of video frames to generate. Default is 1000, but must be at least 100.

  • filename (str, optional) – Name of the XML file to generate inside the data directory. Default is “binary_star_video.xml”.

generate_landing_video(times, lander_positions, planet_idx, initial_system_time=0, number_of_frames=1000, filename='landing_video.xml')

Generates a video of the given lander trajectory that can be played in SSView.

Note

The times and positions for the output frames will be sampled uniformly from times and lander_positions.

Parameters
  • times (1-D array_like) – Array containing the time of each frame, in seconds since the initial time of the landing sequence. Must have a size of at least 100.

  • lander_positions (2-D array_like) – Array of shape (2, len(times)) containing the x and y-position of the lander at each time, in meters relative to the destination planet center.

  • planet_idx (int) – The index of the destination planet.

  • initial_system_time (float, optional) – The system time when the landing sequence began in years. Default is 0.

  • number_of_frames (int, optional) – The number of video frames to generate. Default is 1000, but must be at least 100.

  • filename (str, optional) – Name of the XML file to generate inside the data directory. Default is “landing_video.xml”.