You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Thanks for the work you've done on Skyfield. I'm using it to find rise/set times of objects, and recently came across this corner case(?) where the find_events method is giving incomplete results.
The track of the object that I noticed this on:
I wrote a small program to demo this behavior:
#!/usr/bin/env python3importdatetimeasdtfromdatetimeimportdatetimefromskyfield.apiimportEarthSatellite, Time, load, load_file, wgs84fromskyfield.toposlibimportGeographicPositionfromskyfield.vectorlibimportVectorSumdefmain():
"""Attempt to find rise/set events for an example pass."""planets=load_file("de421.bsp")
ts=load.timescale(builtin=True)
site_latitude=33site_longitude=-118site_altitude=30min_elevation_angle=10site=wgs84.latlon(site_latitude, site_longitude, elevation_m=site_altitude)
# This object has a highly elliptical orbit:sat_target=EarthSatellite(
"1 17328U 87008A 24305.23833080 .00000500 00000-0 22722-2 0 9997",
"2 17328 63.0833 7.8955 7415190 253.9972 19.6892 2.00632911273252",
"MOLNIYA 3-31",
ts,
)
earth=planets["earth"]
groundstation=earth+sitesatellite=earth+sat_target# This is an example pass where we noticed we weren't getting the right rise/setsobs_start_time=datetime(2024, 10, 31, 5, 28, 6, 0, tzinfo=dt.timezone.utc)
obs_end_time=datetime(2024, 10, 31, 5, 40, 6, 0, tzinfo=dt.timezone.utc)
t0=ts.from_datetime(obs_start_time)
t1=ts.from_datetime(obs_end_time)
event_times, events=find_events(site, groundstation, sat_target, satellite, t0, t1, min_elevation_angle)
print("This should have found a 'rise':")
print(events, event_times)
print("...but it has not found a rise event.\n")
# However, this *does* work:obs_start_time=datetime(2024, 10, 31, 2, 28, 6, 0, tzinfo=dt.timezone.utc)
obs_end_time=datetime(2024, 10, 31, 7, 40, 6, 0, tzinfo=dt.timezone.utc)
t0=ts.from_datetime(obs_start_time)
t1=ts.from_datetime(obs_end_time)
event_times, events=find_events(site, groundstation, sat_target, satellite, t0, t1, min_elevation_angle)
print("Expand the boundary, and it finds events:")
print(events, event_times)
print("...including a rise and culmination.\n")
obs_long_end_time=datetime(2024, 10, 31, 16, 40, 6, 0, tzinfo=dt.timezone.utc)
t2=ts.from_datetime(obs_long_end_time)
event_times, events=find_events(site, groundstation, sat_target, satellite, t0, t2, min_elevation_angle)
print("Expand it further, and it should have found a rise, culmination, and set:")
print(events, event_times)
print("...but it found a rise, two culminates, and no set.\n")
# note: adjust the range fidelity to see more detail on the tracktrack_time=ts.utc(2024, 10, 31, 5, range(20, 710, 4))
print_track(groundstation, satellite, track_time)
deffind_events(
site: GeographicPosition,
site_vector: VectorSum,
satellite: EarthSatellite,
sat_vector: VectorSum,
t0: Time,
t1: Time,
min_elevation: float,
) ->tuple:
alt_initial, az_initial, ssb_dist=site_vector.at(t0).observe(sat_vector).apparent().altaz()
alt_final, az_final, ssb_dist=site_vector.at(t1).observe(sat_vector).apparent().altaz()
print(f"Start/End (Az/El): {az_initial.degrees:.5f} / {alt_initial.degrees:.5f} ----> {az_final.degrees:.5f} / {alt_final.degrees:.5f}")
# This fails to find the "rise" above 10 degrees elevation.event_times, events=satellite.find_events(site, t0, t1, altitude_degrees=min_elevation)
returnevent_times, eventsdefprint_track(groundstation: VectorSum, satellite: EarthSatellite, track_time: Time) ->None:
"""Print a minute-by-minute track of a satellite."""print("Propagated track:")
forobs_timeintrack_time:
ssb_alt, ssb_az, ssb_dist=groundstation.at(obs_time).observe(satellite).apparent().altaz()
print(f"{obs_time.utc_strftime('%Y-%m-%d %H:%M')}: {ssb_az.degrees:.5f} / {ssb_alt.degrees:.5f}")
if__name__=="__main__":
main()
I would prefer to continue using Skyfield for finding rise and set events, and I don't think I'm doing anything wrong. Is this a bug/limitation in Skyfield? Are there intentional limitations here that I should work around?
Thanks again!
The text was updated successfully, but these errors were encountered:
Hi! Thanks for the work you've done on Skyfield. I'm using it to find rise/set times of objects, and recently came across this corner case(?) where the find_events method is giving incomplete results.
The track of the object that I noticed this on:
I wrote a small program to demo this behavior:
The output, trimmed a bit for brevity:
I would prefer to continue using Skyfield for finding rise and set events, and I don't think I'm doing anything wrong. Is this a bug/limitation in Skyfield? Are there intentional limitations here that I should work around?
Thanks again!
The text was updated successfully, but these errors were encountered: