# -*- coding: utf-8 -*- """ Template for the main solution code in Part 4 of the project. The objective of the template files is to give you an idea of the most important functions that you have to implement, what input they will need and what output they should produce. To make things work in practice you will have to add more functionalities than the ones outlined, and you might have to adapt the interfaces to fit your specific approach. You are of course free (and encouraged) to structure the code in any way you want! """ import ast2000tools.constants as const import ast2000tools.utils as utils from ast2000tools.space_mission import SpaceMission import part_3 def generate_reference_image(mission, width, height, phi_0, theta_0, field_of_view_phi, field_of_view_theta): """ Here you can implement the sky image generation for challenge A.2 of Part 4 of the project. """ # Load the full-sky image full_sky_image = np.load('himmelkule.npy') # Insert awesome code here... # You will need the following method: # mission.get_sky_image_pixel # You will probably also need this constant: # const.pi return image def predict_spacecraft_pointing_phi(captured_image_filename): """ Here you can implement the angle prediction for challenge B of Part 4 of the project. """ # Insert awesome code here... return predicted_phi def predict_spacecraft_velocity(mission, measured_star_1_doppler_shift, measured_star_2_doppler_shift): """ Here you can implement the velocity prediction for challenge C of Part 4 of the project. """ # Insert awesome code here... # You will probably also need these quantities: # const.pi # const.c # mission.reference_wavelength # mission.star_direction_angles # mission.star_doppler_shifts_at_sun return predicted_velocity def predict_spacecraft_position(time_of_measurement, measured_distances): """ Here you can implement the position prediction for challenge D of Part 4 of the project. """ # Load the exact planet trajectories from Part 2 times, planet_positions = np.load('planet_trajectories.npy') # Insert awesome code here... return predicted_position def launch_and_orient_spacecraft(mission, number_of_boxes, number_of_particles_in_box, box_side_length, temperature, box_hole_area, initial_fuel_mass, launch_direction, time_of_launch): """ This function performs a rocket launch before predicting and verifying the orientation of the spacecraft. """ # Perform the rocket launch part_3.simulate_and_perform_launch(mission, number_of_boxes, number_of_particles_in_box, box_side_length, temperature, box_hole_area, initial_fuel_mass, launch_direction, time_of_launch) # Predict pointing angle after launch captured_image_filename = 'sky_picture.png' mission.take_picture(filename=captured_image_filename) predicted_phi = predict_spacecraft_pointing_phi(captured_image_filename) # Predict velocity after launch measured_star_1_doppler_shift, \ measured_star_2_doppler_shift \ = mission.measure_star_doppler_shifts() predicted_velocity = predict_spacecraft_velocity(mission, measured_star_1_doppler_shift, measured_star_2_doppler_shift) # Predict position after launch time_of_measurement = mission.time_after_launch measured_distances = mission.measure_distances() predicted_position = predict_spacecraft_position(time_of_measurement, measured_distances) # Verify manually inferred orientation values mission.verify_manual_orientation(predicted_position, predicted_velocity, predicted_phi) # Prevent the following code from executing when calling `import part_4` if __name__ == '__main__': # Print a message if a newer version of ast2000tools is available utils.check_for_newer_version() # Construct SpaceMission instance for my mission seed = utils.get_seed('my_username') mission = SpaceMission(seed) # Perform launch and orientation launch_and_orient_spacecraft(mission, number_of_boxes, number_of_particles_in_box, box_side_length, temperature, box_hole_area, initial_fuel_mass, launch_direction, time_of_launch)