Satellite Bulk Tracker
This 'bulk tracker' will handle the entire TLE catalog from Space-Track.org. Find the pass by timings for 1000's of satellites over your area!
If you have the TLE catalog from space-tracker.org this application will build track by-pass times for the lot of time!
from sgp4.api import Satrec
from orbit_predictor.utils import datetime_from_jday
from orbit_predictor.locations import Location
from orbit_predictor.sources import get_predictor_from_tle_lines
from datetime import datetime, timedelta
import pandas as pd
class Sat_Tracker:
def __init__(self):
self.base_lat = 0
self.base_long = 0
self.elevation = 3000
self.max_elevation = 5 # Filter passes with elevations under this many degrees.
self.pass_elevation = 60 # Start pass time must be greater than this.
self.tle_catalog = {}
self.tle_catalog_count = 0
self.location = Location('base_station', self.base_lat, self.base_long, self.elevation)
self.rtl_min_freq = 50.0
self.rlt_max_freq = 1500.0
print("dkdkd")
def load_tle_ascii(self, tfile, filter):
name = ''
with open(tfile, 'r') as g:
data = g.read().split('\n')
csat = 0
for line in data:
try:
if line[0] == '0':
name = line[2:]
if line[0] == '1':
tle_a = line
if line[0] == '2':
if filter not in name:
tle_b = line
predictor = get_predictor_from_tle_lines((tle_a, tle_b))
# None will hold predict times.
self.tle_catalog[name] = [tle_a, tle_b, predictor, None]
csat += 1
except Exception as e:
pass
print(f"Satellite TLE Data for {csat} Raw Loaded.")
def update_predict_times(self):
satellite_list = self.tle_catalog.keys()
rnow = datetime.now()
one_day_from_now = rnow + timedelta(days=1)
skip_list = 0
for satellite in satellite_list:
try:
sat_module = self.tle_catalog[satellite]
predictor = sat_module[2] # Re-obtain the predictor code
"""
max_elevation_gt: filter passes with max_elevation under it.
aos_at_dg: This is if we want to start the pass at a specific elevation.
"""
next_pass_0 = predictor.get_next_pass(self.location, max_elevation_gt=self.max_elevation, aos_at_dg=self.pass_elevation, limit_date=one_day_from_now)
sat_module[3] = next_pass_0
self.tle_catalog[satellite] = sat_module
print(f"Next pass for satellite {satellite} is {next_pass_0.aos} for a duration of {next_pass_0.duration_s}")
except Exception as e:
skip_list += 1
print(f"{skip_list} Satellites do not have a orbital path in your parameters")
def run_predictors(self, orbital_track):
try:
tle_line_0 = orbital_track[0]
tle_line_1 = orbital_track[1]
sgp4_sat = Satrec.twoline2rv(tle_line_0, tle_line_1)
stuple = {tle_line_0, tle_line_1}
db = [sgp4_sat.satnum, tuple(stuple), datetime_from_jday(sgp4_sat.jdsatepoch, sgp4_sat.jdsatepochF)]
print("dkdkd")
except Exception as e:
print(f"Error as: {e}")
st = Sat_Tracker()
st.load_tle_ascii('full_catalog.txt', 'STARLINK')
st.update_predict_times()