Skip to content

Instantly share code, notes, and snippets.

@wgaylord
Created January 1, 2018 05:18
Show Gist options
  • Save wgaylord/7a787931ae2db904b061edad032393e0 to your computer and use it in GitHub Desktop.
Save wgaylord/7a787931ae2db904b061edad032393e0 to your computer and use it in GitHub Desktop.
import numpy as np
import pylab as plt
import ephem
import datetime
# Setup lat long of telescope
oxford = ephem.Observer()
oxford.lat =np.deg2rad(41.840)
oxford.long = np.deg2rad(-87.640)
oxford.date = ephem.Date('2018/01/01 11:33:00.00')
# Load Satellite TLE data.
l1 = 'NOAA 15'
l2 = '1 25338U 98030A 17365.61696846 +.00000044 +00000-0 +37566-4 0 9998'
l3 = '2 25338 098.7770 016.8714 0010501 359.5344 000.5824 14.25833252020880'
biif1 = ephem.readtle(l1,l2,l3)
# Make some datetimes
midnight = ephem.Date('2018/01/01 11:33:00.00')
min = 0.0006944444467080757
dt = [ephem.Date(midnight + x*min) for x in range(0, 30)]
print dt
# Compute satellite locations at each datetime
sat_alt, sat_az = [], []
for date in dt:
oxford.date = date
biif1.compute(oxford)
sat_alt.append(np.rad2deg(biif1.alt))
sat_az.append(np.rad2deg(biif1.az))
# Plot satellite tracks
plt.subplot(211)
plt.plot(dt, sat_alt)
plt.ylabel("Altitude (deg)")
plt.xticks(rotation=25)
plt.subplot(212)
plt.plot(dt, sat_az)
plt.ylabel("Azimuth (deg)")
plt.xticks(rotation=25)
plt.show()
# Plot satellite track in polar coordinates
plt.polar(np.deg2rad(sat_az)-(3.1495/2.0), 90-np.array(sat_alt))
plt.ylim(0,90)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment