ast2000tools.space_mission.SpaceMission

class ast2000tools.space_mission.SpaceMission(seed, data_path=None, has_moons=True, verbose=True)

Bases: object

Represents a mission to launch a rocket from your home planet and land it safely on another planet.

This class is used to keep track of your mission’s progress and verify your results.

Parameters
  • seed (int) – The seed to use when generating random solar system and mission 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.

Methods

begin_interplanetary_travel()

Initiates an interplanetary travel process allowing you to guide your spacecraft to a different planet.

begin_landing_sequence([…])

Initiates a landing sequence process allowing you to land on a planet.

generate_orbit_video(times, planet_positions)

Calls generate_orbit_video() for the ast2000tools.solar_system.SolarSystem instance associated with the mission.

get_sky_image_pixel(polar_angle, azimuth_angle)

Finds the index of the pixel in the full-sky image correspnding to the given spherical coordinates.

launch_rocket([time_step])

Simulates a rocket launch based on the previously specified launch parameters.

load(filename[, verbose])

Loads an instance of SpaceMission from the specified binary file.

measure_distances()

Returns the distances to the bodies of the solar system as measured by your spacecraft directly after launch.

measure_star_doppler_shifts()

Returns the Doppler shifts of the two reference stars as measured by your spacecraft directly after launch.

save(filename, mission[, verbose])

Saves the given instance of SpaceMission as a binary file.

set_launch_parameters(thrust, …)

Used to specify various parameters required to perform a launch.

take_picture([filename, full_sky_image_path])

Generates a picture of the sky in the direction that the spacecraft is pointing directly after launch.

verify_launch_result(position_after_launch)

Verifies that your computation of the final spacecraft position after launch gives a resonable result.

verify_manual_orientation(…)

Verifies that your manually inferred values of the position, velocity and pointing angle of the spacecraft directly after launch are reasonable.

verify_planet_positions(simulation_duration, …)

Calls verify_planet_positions() for the ast2000tools.solar_system.SolarSystem instance associated with the mission.

Attributes

data_path

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

destination_planet_idx

The index of the planet to land on after the interplanetary travel.

destination_recorded

Whether the destination state after the interplanetary travel has been recorded.

estimated_launch_duration

The estimated duration of the launch (the time required to reach escape velocity) in seconds.

initial_fuel_mass

The initial mass of fuel contained in the rocket in kilograms.

initial_landing_position

Array of shape (2,) containing the initial x and y-position for the landing sequence, in astronomical units relative to the star.

initial_landing_time

The initial time for the landing sequence, in years.

initial_landing_velocity

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

lander_area

The cross-sectional area of the lander in square meters.

lander_mass

The mass of the lander in kilograms.

landing_completed

Whether the landing sequence has been successfully completed.

landing_site_azimuth_angle

The azimuthal angle of the landing site in degrees.

landing_site_polar_angle

The polar angle of the landing site in degrees.

launch_parameters_set

Whether the launch parameters have been specified.

launch_position

Array of shape (2,) containing the x and y-position of the launch site, in astronomical units relative to the star.

launch_result_verified

Whether the launch result has been successfully verified.

manual_orientation_verified

Whether the manually inferred orientation data has been successfully verified.

ongoing_interplanetary_travel

The object representing the ongoing interplanetary travel.

ongoing_landing_sequence

The object representing the ongoing landing sequence.

reference_wavelength

The central wavelength of the spectral line (H-alpha) used to measure Doppler shifts, in nanometers.

rocket_launched

Whether the rocket has been successfully launched.

rocket_mass_loss_rate

The mass loss rate of the rocket engine in kilograms per second.

rocket_thrust

The thrust of the rocket engine in Newtons.

seed

The seed used to generate random solar system and mission properties.

spacecraft_area

The cross-sectional area of the spacecraft in square meters.

spacecraft_mass

The mass of the spacecraft in kilograms.

star_direction_angles

Tuple (\(\phi_0\), \(\phi_1\)) containing the azimuthal angles of the reference stars relative to the solar system x-axis, in degrees.

star_doppler_shifts_at_sun

Tuple (\(\Delta\lambda_0\), \(\Delta\lambda_1\)) containing the Doppler shifts of the stars relative to your sun, in nanometers.

system

The randomized solar system where the space mission takes place.

time_after_launch

The time of the end of the launch in years.

time_of_launch

The time of the start of the launch in years.

verbose

Whether non-essential status messages will be printed.

property seed

The seed used to generate random solar system and mission properties.

Type

int

property data_path

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

Type

str

property verbose

Whether non-essential status messages will be printed.

Type

bool

property system

The randomized solar system where the space mission takes place.

Type

ast2000tools.solar_system.SolarSystem

property spacecraft_mass

The mass of the spacecraft in kilograms.

Type

float

property spacecraft_area

The cross-sectional area of the spacecraft in square meters.

Type

float

property lander_mass

The mass of the lander in kilograms.

Type

float

property lander_area

The cross-sectional area of the lander in square meters.

Type

float

property rocket_thrust

The thrust of the rocket engine in Newtons. Only available after calling set_launch_parameters().

Type

float

property rocket_mass_loss_rate

The mass loss rate of the rocket engine in kilograms per second. Only available after calling set_launch_parameters().

Type

float

property initial_fuel_mass

The initial mass of fuel contained in the rocket in kilograms. Only available after calling set_launch_parameters().

Type

float

property estimated_launch_duration

The estimated duration of the launch (the time required to reach escape velocity) in seconds. Only available after calling set_launch_parameters().

Type

float

property launch_position

Array of shape (2,) containing the x and y-position of the launch site, in astronomical units relative to the star. Only available after calling set_launch_parameters().

Type

1-D numpy.ndarray

property time_of_launch

The time of the start of the launch in years. Only available after calling set_launch_parameters().

Type

float

property time_after_launch

The time of the end of the launch in years. Only available after calling launch_rocket().

Type

float

property reference_wavelength

The central wavelength of the spectral line (H-alpha) used to measure Doppler shifts, in nanometers.

Type

float

property star_direction_angles

Tuple (\(\phi_0\), \(\phi_1\)) containing the azimuthal angles of the reference stars relative to the solar system x-axis, in degrees.

Type

tuple

property star_doppler_shifts_at_sun

Tuple (\(\Delta\lambda_0\), \(\Delta\lambda_1\)) containing the Doppler shifts of the stars relative to your sun, in nanometers.

Type

tuple

property ongoing_interplanetary_travel

The object representing the ongoing interplanetary travel. Only available after calling begin_interplanetary_travel().

Type

InterplanetaryTravel

property ongoing_landing_sequence

The object representing the ongoing landing sequence. Only available after calling begin_landing_sequence().

Type

LandingSequence

property destination_planet_idx

The index of the planet to land on after the interplanetary travel. Only available after calling record_destination().

Type

int

property initial_landing_time

The initial time for the landing sequence, in years. Only available after calling record_destination().

Type

float

property initial_landing_position

Array of shape (2,) containing the initial x and y-position for the landing sequence, in astronomical units relative to the star. Only available after calling record_destination().

Type

1-D numpy.ndarray

property initial_landing_velocity

Array of shape (2,) containing the initial x and y-velocity for the landing sequence, in astronomical units per year relative to the star. Only available after calling record_destination().

Type

1-D numpy.ndarray

property landing_site_polar_angle

The polar angle of the landing site in degrees. Only available after completing a successful landing with LandingSequence.

Type

float

property landing_site_azimuth_angle

The azimuthal angle of the landing site in degrees. Only available after completing a successful landing with LandingSequence.

Type

float

property launch_parameters_set

Whether the launch parameters have been specified.

Type

bool

property rocket_launched

Whether the rocket has been successfully launched.

Type

bool

property launch_result_verified

Whether the launch result has been successfully verified.

Type

bool

property manual_orientation_verified

Whether the manually inferred orientation data has been successfully verified.

Type

bool

property destination_recorded

Whether the destination state after the interplanetary travel has been recorded.

Type

bool

property landing_completed

Whether the landing sequence has been successfully completed.

Type

bool

static save(filename, mission, verbose=True)

Saves the given instance of SpaceMission as a binary file.

Parameters
  • filename (str) – The name/path to use for the written binary file. Warning: If there exists a file with the same name it will be overwritten.

  • mission (SpaceMission) – The instance of SpaceMission to save.

  • verbose (bool, optional) – Set to False to mute the message saying that the file was successfully saved.

static load(filename, verbose=True)

Loads an instance of SpaceMission from the specified binary file.

Parameters
  • filename (str) – The name/path of the binary file to read.

  • verbose (bool, optional) – Set to False to mute the message saying that the file was successfully loaded.

Returns

The loaded SpaceMission instance.

Return type

SpaceMission

Raises

ValueError – When filename does not point to a valid file.

set_launch_parameters(thrust, mass_loss_rate, initial_fuel_mass, estimated_launch_duration, launch_position, time_of_launch)

Used to specify various parameters required to perform a launch.

Note

Any existing launch results will be cleared.

Parameters
  • thrust (float) – The total thrust of the rocket engine in Newtons.

  • mass_loss_rate (float) – The total rate of mass loss of the rocket engine in kilograms per second.

  • initial_fuel_mass (float) – The total mass of rocket fuel contained in the rocket before launch, in kilograms.

  • estimated_launch_duration (float) – The estimated duration of the launch, i.e. the time required to reach escape velocity, in seconds.

  • launch_position (1-D array_like) – Array of shape (2,) containing the x and y-position of the launch site, in astronomical units relative to the star. Must be close to the surface of your home planet (maximum 1% deviation).

  • time_of_launch (float) – The time of the start of the launch in years.

launch_rocket(time_step=0.01)

Simulates a rocket launch based on the previously specified launch parameters.

Note

Any existing launch result verification will be cleared.

Parameters

time_step (float, optional) – The time step duration to use for the simulation, in seconds. Not allowed to exceed the default of 0.01. Decrease if you suspect that higher accuracy is needed.

Raises
verify_launch_result(position_after_launch)

Verifies that your computation of the final spacecraft position after launch gives a resonable result.

Parameters

position_after_launch (1-D array_like) – Array of shape (2,) containing your values for the x and y-position of the spacecraft after launch, in astronomical units relative to the star.

Raises
verify_planet_positions(simulation_duration, planet_positions, filename='planet_trajectories.npz')

Calls verify_planet_positions() for the ast2000tools.solar_system.SolarSystem instance associated with the mission.

Note

The exact trajectories will be needed in later stages of the mission. By default, this wrapper causes the trajectories to be stored in the file “planet_trajectories.npz” in the working directory. The syntax for loading the data is:

with np.load('planet_trajectories.npz') as f:
    times = f['times']
    exact_planet_positions = f['planet_positions']
generate_orbit_video(times, planet_positions, number_of_frames=None, reduce_other_periods=True, filename='orbit_video.xml')

Calls generate_orbit_video() for the ast2000tools.solar_system.SolarSystem instance associated with the mission.

static get_sky_image_pixel(polar_angle, azimuth_angle)

Finds the index of the pixel in the full-sky image correspnding to the given spherical coordinates.

Parameters
  • polar_angle (float) – The polar angle of the point in radians. Must be in the range [0, pi].

  • azimuth_angle (float) – The azimuthal angle of the point in radians.

Returns

The index of the pixel.

Return type

int

take_picture(filename='sky_picture.png', full_sky_image_path='himmelkule.npy')

Generates a picture of the sky in the direction that the spacecraft is pointing directly after launch.

Note

You can safely assume that the spacecraft is looking along the solar system plane.

Parameters
  • filename (str, optional) – The name/path to use for the generated image. By default the image is stored as “sky_picture.png” in the working directory.

  • full_sky_image_path (str, optional) – The name/path to use when looking for the sky data file. This file must be downloaded from the course website. By default the file is assumed to be named “himmelkule.npy” and reside in the working directory.

Raises
measure_star_doppler_shifts()

Returns the Doppler shifts of the two reference stars as measured by your spacecraft directly after launch.

Note

The Doppler shifts are computed for the H-alpha spectral line, which has a central wavelength of 656.3 nm.

Returns

Tuple (\(\Delta\lambda_0\), \(\Delta\lambda_1\)) containing the Doppler shifts of the stars relative to your spacecraft, in nanometers.

Return type

tuple(float)

Raises

RuntimeError – When called before verify_launch_result().

measure_distances()

Returns the distances to the bodies of the solar system as measured by your spacecraft directly after launch.

Returns

Array of shape (number_of_planets+1,) containing the distances to the planets and sun (last entry) in your system, in astronomical units.

Return type

1-D numpy.ndarray

Raises

RuntimeError – When called before verify_launch_result().

verify_manual_orientation(position_after_launch, velocity_after_launch, angle_after_launch)

Verifies that your manually inferred values of the position, velocity and pointing angle of the spacecraft directly after launch are reasonable.

Parameters
  • position_after_launch (1-D array_like) – Array of shape (2,) containing your inferred values for the x and y-position of the spacecraft, in astronomical units relative to the star.

  • velocity_after_launch (1-D array_like) – Array of shape (2,) containing your inferred values for the x and y-velocity of the spacecraft, in astronomical units per year relative to the star.

  • angle_after_launch (float) – Your inferred value for the azimuthal angle of the spacecraft’s pointing, in degrees.

Raises
begin_interplanetary_travel()

Initiates an interplanetary travel process allowing you to guide your spacecraft to a different planet.

Note

Any ongoing interplanetary travel or landing sequence will be terminated. Any recorded destination state will be cleared.

Returns

A new instance of InterplanetaryTravel associated with your system.

Return type

InterplanetaryTravel

begin_landing_sequence(assume_uniform_gravity_atmosphere=True)

Initiates a landing sequence process allowing you to land on a planet.

Note

Any ongoing interplanetary travel or landing sequence will be terminated. Any recorded landing site coordinates will be cleared.

Parameters

assume_uniform_gravity_atmosphere (bool, optional) – Whether to neglect the change of gravitational force with height when modelling the atmosphere. Default is True.

Returns

A new instance of LandingSequence associated with your system.

Return type

LandingSequence