I'm trying to get an alert whenever some space object passes over my location so my plan was to use skyfield to generate a list of passes with the find_events function (dont care if visible, no elevation restrictions) and store a list of pass times with satellite info. So I have my full TLE list of tracked objects and I set skyfield going and it creates the list just fine... but I notice after about two hours of pretty consistent passes it gets really sparse. like every few minutes and then even more sparse.
So my question is - why does it do this? Is there a better approach?
Here is a graph of the number of pass culmination times stored as the day goes on:
Appreciate any insight anyone might have. Willing to change my approach completely but also just confused about why the passes get so sparse after two hours. My current solution is just to re-run the code every two hours ish but its pretty computationally intensive.
Relevant code below:
def next_pass_details(tle_line1, tle_line2, observer_location):
ts = load.timescale()
satellite = EarthSatellite(tle_line1, tle_line2)
observer = Topos(latitude_degrees=observer_location[0], longitude_degrees=observer_location[1])
start_time = ts.now()
end_time = start_time + 1.0 # Look 24 hours ahead
culmination_time = None
altitude_km = -1
times, events = satellite.find_events(observer, start_time, end_time, altitude_degrees=0.0)
for time, event in zip(times, events):
if event == 1: # Culmination
culmination_time = time
geocentric = satellite.at(time)
subpoint = geocentric.subpoint()
altitude_km = subpoint.elevation.km
observer_location = (observer.latitude.degrees, observer.longitude.degrees)
subsatellite_point = (subpoint.latitude.degrees, subpoint.longitude.degrees)
distance_km = geodesic(observer_location, subsatellite_point).km
if distance_km > radius: #exclude satellites too far away
return None
print(distance_km)
return {
'culmination_time': culmination_time.utc_strftime('%Y-%m-%d %H:%M:%S'),
'altitude_km': altitude_km,
'distance_km': distance_km
}
return None
Thanks
Dumb but the error was that I'm using a for loop to return the pass event, so it only returns one event per TLE and skips the rest.