Advertisement
Guest User

Untitled

a guest
Jul 27th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. from skyfield.api import Loader
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
  6. to_degs, to_rads = 180/pi, pi/180
  7. R_sun =  695700. # kilometers
  8.  
  9. load = Loader('~/Documents/fishing/SkyData')  # avoids multiple copies of large files
  10.  
  11. ts = load.timescale() # include builtin=True if you want to use older files (you may miss some leap-seconds)
  12. eph = load('de421.bsp') # Use de405 or another if you want to go past year 2053
  13. earth, sun, mars = [eph[x] for x in ('earth', 'sun', 'mars')]
  14.  
  15. days = np.arange(0, 53*365.2564, 0.1)
  16. years = 2000 + days/365.2564
  17.  
  18. times = ts.utc(2000, 1, days)
  19. m = mars.at(times)
  20. e, s = [m.observe(thing) for thing in (earth, sun)]
  21. ems = e.separation_from(s).degrees
  22. dsun = s.distance().km
  23. half_angle_sun = to_degs*np.arctan2(R_sun, dsun)
  24.  
  25. plt.figure()
  26. plt.rcParams['axes.formatter.useoffset'] = False # https://stackoverflow.com/a/29535832/3904031
  27. plt.subplot(2, 1, 1)
  28. plt.plot(years, ems)
  29. plt.plot(years, half_angle_sun, '-k')
  30. plt.ylim(0, None)
  31. plt.xlim(2000, 2053)
  32. plt.subplot(2, 1, 2)
  33. plt.plot(years, ems)
  34. plt.plot(years, half_angle_sun, '-k')
  35. plt.ylim(0, 1)
  36. plt.xlim(2000, 2053)
  37. plt.suptitle('Sun-Mars-Earth angle and Sun half-angle', fontsize=16)
  38. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement