Scientific Computing Using Python - PHYS:4905
Python Homework #4
Due 9/10/2019
This homework must be handed in electronically. You will need
to upload one file for each problem containing your Python code as a
text file. Please have the file name start with your last
name, e.g. smith.py. You can make the name longer if you like,
e.g. smith_hw4_1.py for the first problem and smith_hw4_2.py for the
second. I will grade the assignment by downloading your code
and running it, so you should be sure that it is complete and runs
correctly under Spyder.
1. (5) Write a Python program to import the HaloSat orbit data in
FITS format, plot the distance of HaloSat from the center of the
Earth as a function of time, and find the minimum and maximum of
that distance. From inspection of your results, about how far
is HaloSat above the surface of the Earth? You may treat the
Earth as a sphere.
2. (30) Write a Python program to do a random walk in two dimensions
and plot the walk path. Each step should have a length of 1
and be randomly chosen to be in any direction with equal
probability. 'Any direction' means that the step can be at any
angle, not only the four cardinal directions. Have the walk
stop when it has reached a distance of 10 or greater from its
origin. Do 5 walks and plot all of them on the same plot using
different colors or line styles so that the walks can be
distinguished. Include a legend indicating the number of steps
taken in each walk and a circle with a radius of 10 centered on the
origin.