mirror of
https://github.com/smittix/intercept.git
synced 2026-06-15 09:03:38 -07:00
Fix weather satellite next-pass countdown timestamps
This commit is contained in:
@@ -14,6 +14,15 @@ from utils.weather_sat import WEATHER_SATELLITES
|
||||
logger = get_logger('intercept.weather_sat_predict')
|
||||
|
||||
|
||||
def _format_utc_iso(dt: datetime.datetime) -> str:
|
||||
"""Return an ISO8601 UTC timestamp with a single timezone designator."""
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=datetime.timezone.utc)
|
||||
else:
|
||||
dt = dt.astimezone(datetime.timezone.utc)
|
||||
return dt.isoformat().replace('+00:00', 'Z')
|
||||
|
||||
|
||||
def predict_passes(
|
||||
lat: float,
|
||||
lon: float,
|
||||
@@ -38,8 +47,9 @@ def predict_passes(
|
||||
Raises:
|
||||
ImportError: If skyfield is not installed.
|
||||
"""
|
||||
from skyfield.api import load, wgs84, EarthSatellite
|
||||
from skyfield.almanac import find_discrete
|
||||
from skyfield.api import EarthSatellite, load, wgs84
|
||||
|
||||
from data.satellites import TLE_SATELLITES
|
||||
|
||||
# Use live TLE cache from satellite module if available (refreshed from CelesTrak)
|
||||
@@ -100,8 +110,10 @@ def predict_passes(
|
||||
i += 1
|
||||
continue
|
||||
|
||||
rise_dt = rise_time.utc_datetime()
|
||||
set_dt = set_time.utc_datetime()
|
||||
duration_seconds = (
|
||||
set_time.utc_datetime() - rise_time.utc_datetime()
|
||||
set_dt - rise_dt
|
||||
).total_seconds()
|
||||
duration_minutes = round(duration_seconds / 60, 1)
|
||||
|
||||
@@ -141,14 +153,14 @@ def predict_passes(
|
||||
_, set_az, _ = set_topo.altaz()
|
||||
|
||||
pass_data: dict[str, Any] = {
|
||||
'id': f"{sat_key}_{rise_time.utc_datetime().strftime('%Y%m%d%H%M%S')}",
|
||||
'id': f"{sat_key}_{rise_dt.strftime('%Y%m%d%H%M%S')}",
|
||||
'satellite': sat_key,
|
||||
'name': sat_info['name'],
|
||||
'frequency': sat_info['frequency'],
|
||||
'mode': sat_info['mode'],
|
||||
'startTime': rise_time.utc_datetime().strftime('%Y-%m-%d %H:%M UTC'),
|
||||
'startTimeISO': rise_time.utc_datetime().isoformat() + 'Z',
|
||||
'endTimeISO': set_time.utc_datetime().isoformat() + 'Z',
|
||||
'startTime': rise_dt.strftime('%Y-%m-%d %H:%M UTC'),
|
||||
'startTimeISO': _format_utc_iso(rise_dt),
|
||||
'endTimeISO': _format_utc_iso(set_dt),
|
||||
'maxEl': round(max_el, 1),
|
||||
'maxElAz': round(max_el_az, 1),
|
||||
'riseAz': round(rise_az.degrees, 1),
|
||||
|
||||
Reference in New Issue
Block a user