skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.38k stars 208 forks source link

find_events does not return satellite events if no culmination found #856

Open SerBrynden opened 1 year ago

SerBrynden commented 1 year ago

The find_events method does not return the satellite rise or set events if no culmination event was determined in the given time window. The below example can be used to repeat this problem. Note the different times for t0 and t1 in the two sections. When the time window is wide enough to include a culmination event, find_events properly returns any events found. When the time window is adjusted to start after a culmination event, nothing is returned even though there is still a set event that should have been captured. Same thing happens for rise events.

import skyfield.api as sf

name = 'CALSPHERE 1'
line1 = '1 00900U 64063C   23132.76805348  .00000959  00000+0  10041-2 0  9990'
line2 = '2 00900  90.1911  47.1536 0028577 107.2446 307.0044 13.74297586915882'

ts = sf.load.timescale()
satellite = sf.EarthSatellite(line1, line2, name, ts)
print(satellite)

fairbanks = sf.wgs84.latlon(64.9725, -147.5011)

event_names = 'rise above 5°', 'culminate', 'set below 5°'

t0 = ts.utc(2023, 5, 12, 16, 49, 0)
t1 = ts.utc(2023, 5, 12, 16, 55, 0)

t, events = satellite.find_events(fairbanks, t0, t1, altitude_degrees=5.0)

print(len(events), 'events found between',
      t0.utc_strftime('%m/%d/%Y %H:%M:%S'), 'and', t1.utc_strftime('%m/%d/%Y %H:%M:%S'))

for ti, event in zip(t, events):
    name = event_names[event]
    print(satellite.name, ti.utc_strftime('%m/%d/%Y %H:%M:%S'), name)

t0 = ts.utc(2023, 5, 12, 16, 50, 0)
t1 = ts.utc(2023, 5, 12, 16, 55, 0)

t, events = satellite.find_events(fairbanks, t0, t1, altitude_degrees=5.0)

print(len(events), 'events found between',
      t0.utc_strftime('%m/%d/%Y %H:%M:%S'), 'and', t1.utc_strftime('%m/%d/%Y %H:%M:%S'))

for ti, event in zip(t, events):
    name = event_names[event]
    print(satellite.name, ti.utc_strftime('%m/%d/%Y %H:%M:%S'), name)

Output:

CALSPHERE 1 catalog #900 epoch 2023-05-12 18:26:00 UTC
2 events found between 05/12/2023 16:49:00 and 05/12/2023 16:55:00
CALSPHERE 1 05/12/2023 16:49:17 culminate
CALSPHERE 1 05/12/2023 16:51:55 set below 5°
0 events found between 05/12/2023 16:50:00 and 05/12/2023 16:55:00
brandon-rhodes commented 1 year ago

Oh, interesting. That does make sense — I think the routine first looks for transits, and only for the transits it finds does it then go looking for rising and setting events. The next time I'm in that routine, I'll think about how it might catch risings and settings for which it doesn't catch the actual transit.

SerBrynden commented 1 year ago

Oh, interesting. That does make sense — I think the routine first looks for transits, and only for the transits it finds does it then go looking for rising and setting events. The next time I'm in that routine, I'll think about how it might catch risings and settings for which it doesn't catch the actual transit.

Cool! Thank you.