Advertisement
Guest User

Untitled

a guest
May 3rd, 2014
11,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import datetime
  2.  
  3. launch = datetime.date(1977, 9 , 5)
  4. ejup = 1.0921  # Synodic period of Earth-Jupiter
  5. jsat = 19.8584 # Synodic period of Jupiter-Saturn
  6.  
  7.  
  8. i = 1 # synodic year earth-jupiter counter
  9. tol = 15 # tolerance in days
  10. while True:
  11.     d1 = datetime.timedelta(days=365.242*ejup*i) # Time of the E-J synodic period
  12.     j = round(ejup*i / jsat) # Nearest J-S synodic period
  13.     d2 = datetime.timedelta(days=365.242*jsat*j) # Time of the J-S synodic period
  14.  
  15.     # Difference (in days) between the two synodic periods
  16.     dif = abs((d1.total_seconds() - d2.total_seconds()) / 60.0 / 60.0 / 24.0)
  17.  
  18.     if dif <= tol:
  19.         print("Found matching launch date!")
  20.         print(launch + d1)
  21.         print("Dif:", dif)
  22.         break
  23.    
  24.    
  25.     i += 1
  26.     if not i%1000:
  27.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement