From 65b7d815a41cedda64549b29ee59b6c23f71b508 Mon Sep 17 00:00:00 2001 From: Matias Piano Date: Tue, 22 Oct 2024 18:13:40 -0300 Subject: [PATCH 1/5] Logging when there is a RuntimeError and expose the TLE --- pipe_satellite_data/utils/locations.py | 37 +++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/pipe_satellite_data/utils/locations.py b/pipe_satellite_data/utils/locations.py index bdd06f4..0fe706a 100644 --- a/pipe_satellite_data/utils/locations.py +++ b/pipe_satellite_data/utils/locations.py @@ -13,6 +13,7 @@ import time import udatetime import ujson as json +import logging EPOCH = udatetime.utcfromtimestamp(0) @@ -103,19 +104,23 @@ def satellite_locations(tles, dt): end_ts = start_ts + SECONDS_IN_DAY for tle in tles: - tle_lines = [str(tle['TLE_LINE%s' % i]) for i in range(3)] - orbit = ephem.readtle(*tle_lines) - - for ts in range(start_ts, end_ts): - orbit.compute(datetime.utcfromtimestamp(ts).strftime("%Y/%m/%d %H:%M:%S")) - lon = ephem.degrees(orbit.sublong) * 180 / 3.1416 - lat = ephem.degrees(orbit.sublat) * 180 / 3.1416 - elevation = orbit.elevation - - yield dict( - norad_id=tle['NORAD_CAT_ID'], - lat=lat, - lon=lon, - timestamp=ts, - altitude=elevation - ) + try: + tle_lines = [str(tle['TLE_LINE%s' % i]) for i in range(3)] + orbit = ephem.readtle(*tle_lines) + + for ts in range(start_ts, end_ts): + orbit.compute(datetime.utcfromtimestamp(ts).strftime("%Y/%m/%d %H:%M:%S")) + lon = ephem.degrees(orbit.sublong) * 180 / 3.1416 + lat = ephem.degrees(orbit.sublat) * 180 / 3.1416 + elevation = orbit.elevation + + yield dict( + norad_id=tle['NORAD_CAT_ID'], + lat=lat, + lon=lon, + timestamp=ts, + altitude=elevation + ) + except RuntimeError as e: + logging.error(e, f'Error found in TLE: {tle}') + raise e From 0909987830019efebd7579b07a741b57e0f88b98 Mon Sep 17 00:00:00 2001 From: Matias Piano Date: Tue, 22 Oct 2024 18:18:21 -0300 Subject: [PATCH 2/5] Increments project version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 824d564..271d36b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='pipe-satellite-data', - version='3.1.0', + version='3.1.1', packages=find_packages(exclude=['test*.*', 'tests']) ) From 92857f4a92fd809d86ecb1b86465394facce07a8 Mon Sep 17 00:00:00 2001 From: Matias Piano Date: Wed, 23 Oct 2024 10:43:38 -0300 Subject: [PATCH 3/5] Logging when there is a RuntimeError and expose the TLE --- pipe_satellite_data/utils/locations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipe_satellite_data/utils/locations.py b/pipe_satellite_data/utils/locations.py index 0fe706a..0995975 100644 --- a/pipe_satellite_data/utils/locations.py +++ b/pipe_satellite_data/utils/locations.py @@ -122,5 +122,5 @@ def satellite_locations(tles, dt): altitude=elevation ) except RuntimeError as e: - logging.error(e, f'Error found in TLE: {tle}') + logging.error(e, f'Error found in TLE: {tle}.\nCheck satellite status: https://www.n2yo.com/satellite/?s={tle["NORAD_CAT_ID"]}') raise e From a00f525e06fddc04e9c276ae7dfda28e5ca580a5 Mon Sep 17 00:00:00 2001 From: Matias Piano Date: Wed, 23 Oct 2024 15:25:21 -0300 Subject: [PATCH 4/5] Skips the tles that are not in orbit and already DECAYED --- pipe_satellite_data/process/sat_locations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pipe_satellite_data/process/sat_locations.py b/pipe_satellite_data/process/sat_locations.py index ea93980..162e110 100644 --- a/pipe_satellite_data/process/sat_locations.py +++ b/pipe_satellite_data/process/sat_locations.py @@ -28,6 +28,9 @@ def process(self, date_ts, norad_ids): # get TLEs for norad_ids for the date tles = fetch_TLE(self.st_auth, norad_ids, dt) + + # https://www.space-track.org/documentation#api-basicSpaceDataDecay + tles = filter(lambda x: int(x["DECAYED"]) not in [1, 2], tles) tles, tles_4_sats = tee(tles) #store in GCP From 5a728e37c2a68894d040ff90b260304bacad4045 Mon Sep 17 00:00:00 2001 From: Matias Piano Date: Thu, 24 Oct 2024 14:19:41 -0300 Subject: [PATCH 5/5] Logs the norad_id that are DECAYED since the API --- pipe_satellite_data/process/sat_locations.py | 3 --- pipe_satellite_data/utils/locations.py | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pipe_satellite_data/process/sat_locations.py b/pipe_satellite_data/process/sat_locations.py index 162e110..ea93980 100644 --- a/pipe_satellite_data/process/sat_locations.py +++ b/pipe_satellite_data/process/sat_locations.py @@ -28,9 +28,6 @@ def process(self, date_ts, norad_ids): # get TLEs for norad_ids for the date tles = fetch_TLE(self.st_auth, norad_ids, dt) - - # https://www.space-track.org/documentation#api-basicSpaceDataDecay - tles = filter(lambda x: int(x["DECAYED"]) not in [1, 2], tles) tles, tles_4_sats = tee(tles) #store in GCP diff --git a/pipe_satellite_data/utils/locations.py b/pipe_satellite_data/utils/locations.py index 0995975..b448024 100644 --- a/pipe_satellite_data/utils/locations.py +++ b/pipe_satellite_data/utils/locations.py @@ -78,7 +78,10 @@ def fetch_TLE(st_auth, norad_ids, dt): for tles_list_by_norad in norad_dict.values(): first_tle=[tles_list_by_norad[0]] for tle in first_tle: - yield tle + if int(tle["DECAYED"]) not in [1, 2]: # https://www.space-track.org/documentation#api-basicSpaceDataDecay + yield tle + else: + logging.info(f'>>> TLE already DECAYED: {tle["NORAD_CAT_ID"]}')