Homework 3 Question 3 (William Matzko)
import numpy as np
JD = input('Insert the last known transit in Julian Days ')
P = input('Insert the period (in days) of the planet ')
n = input('How many future transits would you like to see? ')
N = np.array(range(1,n+1))
Next_Transit = (JD + P)
print
print"The next transit time is ",Next_Transit," (JD)"
print
Future_Transit = (JD + N*P)
print"Future transits (in JD) are: ",Future_Transit,""
The above code is written in Python 2.7. It prompts the user to enter the last known transit time in Julian Days (this could be the beginning of the transit, the midpoint, etc.), the period of the planet in days, as well as the desired number of future transits. For instance, if you want to see the next 10 transits, you would put in 10 when prompted to do so. It will return the next transit in one line, and then all the future transits in another line, all in Julian Days. I tried adding a feature that would go through the returned array and remove Julian Days that corresponded to daytime, but I couldn't get it to work out. So, it will return all transits, regardless of whether or not they are actually observable from campus. It's a trivial matter though to put the JD into a converter and see what time it corresponds to, so this isn't really a big problem. Attached is a screenshot of the output.
Comments
Post a Comment