#!/usr/bin/env python # -*- coding: utf-8 -*- from skyfield.api import Topos, load import numpy as np import matplotlib.pyplot as plt # mostly from https://rhodesmill.org/skyfield/earth-satellites.html resource_satellites_url = 'https://celestrak.org/NORAD/elements/resource.txt' resource_satellites = load.tle(resource_satellites_url) SMAP = resource_satellites['SMAP'] print(SMAP) print('epoch of the SMAP TLE found: ', SMAP.epoch.utc_jpl()) ts = load.timescale() days = ts.now() - SMAP.epoch print('{:.3f} days away from epoch'.format(days)) # still from that example: bluffton = Topos('40.8939 N', '83.8917 W') t0 = ts.utc(2020, 2, 23) t1 = ts.utc(2020, 2, 24) t, events = SMAP.find_events(bluffton, t0, t1, altitude_degrees=30.0) for ti, event in zip(t, events): name = ('rise above 30°', 'culminate', 'set below 30°')[event] print(ti.utc_jpl(), name) # WARNING I've hard coded a date here, if you run this later the TLE retrieved # will be newer and so will be less accurate. You'd like the TLE you use to be within # a few weeks (if not a few days) of your date for best accuracy. minutes = range(24*60+1) times = ts.utc(2020, 2, 24, 0, minutes, 0) # Example; every minute for 24-feb-2020 subsat_pts = SMAP.at(times).subpoint() lat, lon = subsat_pts.latitude.degrees, subsat_pts.longitude.degrees subsat_pts_now = SMAP.at(ts.now()).subpoint() lat_now, lon_now = subsat_pts_now.latitude.degrees, subsat_pts_now.longitude.degrees # fudging around to keep the plot from wrapping arond the Earth breakpoints = lon[1:] - lon[:-1] > 10. # for SMAP this means that longitude has wrapped lat, lon = lat[:-1], lon[:-1] lon[breakpoints] = np.nan if True: plt.figure() plt.plot(lon, lat) plt.title('SMAP map every minute for 24-feb-2020, dot is for ts.now()') plt.xlabel('longitude (degs)') plt.ylabel('latitude (degs)') plt.plot([lon_now], [lat_now], 'ok') # put a dot for right now plt.show()
Now we also have the pytroll-schedule package, in case you need to make a full acquisition plan, that will allow you for example to put priorities on satellites: https://github.com/pytroll/pytroll-schedule