Update remote with local emergancy fixes
parent
de4f6c0b9b
commit
7b1366ad37
30
satnogs.py
30
satnogs.py
|
@ -38,23 +38,29 @@ def getFuture():
|
||||||
global Observations
|
global Observations
|
||||||
global TLEs
|
global TLEs
|
||||||
global StationsPasses
|
global StationsPasses
|
||||||
|
norads = {}
|
||||||
TLEs = defaultdict(list)
|
TLEs = defaultdict(list)
|
||||||
StationsPasses = defaultdict(list)
|
StationsPasses = defaultdict(list)
|
||||||
observations = defaultdict(dict)
|
observations = defaultdict(dict)
|
||||||
Start = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')
|
Start = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||||
End = (datetime.utcnow() + timedelta(minutes=30))
|
End = (datetime.utcnow() + timedelta(days = 1))
|
||||||
End = End.strftime('%Y-%m-%dT%H:%M:%S%z')
|
End = End.strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||||
passes = get_paginated_endpoint("https://network.satnogs.org/api/jobs/")
|
passes = get_paginated_endpoint("https://network.satnogs.org/api/jobs/")
|
||||||
#obs = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+end+"&format=json&start="+start)
|
# print("Started")
|
||||||
#for x in tqdm(obs):
|
# obs = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+End+"&format=json&start="+Start)
|
||||||
# observations[x["id"]] = x
|
# for x in obs:
|
||||||
|
# norads[x["id"]] = x["noard_cat_id"]
|
||||||
|
print("Ended")
|
||||||
Observations = defaultdict(list)
|
Observations = defaultdict(list)
|
||||||
for x in passes:
|
for x in passes:
|
||||||
if x["ground_station"] == None:
|
if x["ground_station"] == None:
|
||||||
continue
|
continue
|
||||||
#if x["id"] in observations:
|
#if x["id"] in observations:
|
||||||
|
#noard = norads[x["id"]]
|
||||||
norad = int(x["tle1"].split(" ")[1].replace("U",""))
|
norad = int(x["tle1"].split(" ")[1].replace("U",""))
|
||||||
try:
|
try:
|
||||||
|
if(not norad in SatDescrip.keys()):
|
||||||
|
continue
|
||||||
start = datetime.strptime(x["start"], '%Y-%m-%dT%H:%M:%Sz')
|
start = datetime.strptime(x["start"], '%Y-%m-%dT%H:%M:%Sz')
|
||||||
start = start.replace(tzinfo=utc)
|
start = start.replace(tzinfo=utc)
|
||||||
|
|
||||||
|
@ -62,9 +68,9 @@ def getFuture():
|
||||||
end = end.replace(tzinfo=utc)
|
end = end.replace(tzinfo=utc)
|
||||||
# "transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]]
|
# "transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]]
|
||||||
if start < end:
|
if start < end:
|
||||||
Observations[norad].append({"station": x["ground_station"], "transmitter": Transmitters[norad][x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
Observations[norad].append({"station": x["ground_station"], "transmitter": Transmitters[x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||||
TLEs[norad] = EarthSatellite(x["tle1"], x["tle2"],x["tle0"])
|
TLEs[norad] = EarthSatellite(x["tle1"], x["tle2"],x["tle0"])
|
||||||
StationsPasses[x["ground_station"]].append({"norad": norad, "transmitter": Transmitters[norad][x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
StationsPasses[x["ground_station"]].append({"norad": norad, "transmitter": Transmitters[x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
print("Error on observation number: " + str(x["id"]) + " "+str(norad)+" " + str(e))
|
print("Error on observation number: " + str(x["id"]) + " "+str(norad)+" " + str(e))
|
||||||
|
@ -130,11 +136,11 @@ def updateTransmitters():
|
||||||
print("Updating Transmitters")
|
print("Updating Transmitters")
|
||||||
temp = requests.get("https://db.satnogs.org/api/transmitters/").json()
|
temp = requests.get("https://db.satnogs.org/api/transmitters/").json()
|
||||||
for x in temp:
|
for x in temp:
|
||||||
Transmitters[x["norad_cat_id"]][x["uuid"]] = [x["description"], [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255]]
|
Transmitters[x["uuid"]] = [x["description"], [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255]]
|
||||||
SatDescrip[x["norad_cat_id"]] = ""
|
SatDescrip[x["norad_cat_id"]] = ""
|
||||||
for x in Transmitters.keys():
|
#for x in Transmitters.keys():
|
||||||
for y in Transmitters[x].keys():
|
for x in temp:
|
||||||
SatDescrip[x] += '<div class="trans" style="background-color:#'+str("%02x" % Transmitters[x][y][1][0])+str("%02x" % Transmitters[x][y][1][1])+str("%02x" % Transmitters[x][y][1][2])+'";>'+Transmitters[x][y][0]+'</div>'
|
SatDescrip[x["norad_cat_id"]] += '<div class="trans" style="background-color:#'+str("%02x" % Transmitters[x["uuid"]][1][0])+str("%02x" % Transmitters[x["uuid"]][1][1])+str("%02x" % Transmitters[x["uuid"]][1][2])+'";>'+Transmitters[x["uuid"]][0]+'</div>'
|
||||||
print("Finished Updating Transmitters")
|
print("Finished Updating Transmitters")
|
||||||
|
|
||||||
@scheduler.scheduled_job('interval', minutes=15)#hours=1)
|
@scheduler.scheduled_job('interval', minutes=15)#hours=1)
|
||||||
|
@ -163,6 +169,7 @@ def updateStations():
|
||||||
|
|
||||||
#@scheduler.scheduled_job('interval', minutes=5)
|
#@scheduler.scheduled_job('interval', minutes=5)
|
||||||
def updateCZML():
|
def updateCZML():
|
||||||
|
#print(SatDescrip.keys())
|
||||||
print("Updating CZML")
|
print("Updating CZML")
|
||||||
global CZMLOnline
|
global CZMLOnline
|
||||||
global CZMLOffline
|
global CZMLOffline
|
||||||
|
@ -217,6 +224,7 @@ def updateCZML():
|
||||||
sat["billboard"] = {"image": "static/sat.png", "scale": 0.50}
|
sat["billboard"] = {"image": "static/sat.png", "scale": 0.50}
|
||||||
sat["position"] = {}
|
sat["position"] = {}
|
||||||
sat["position"]["cartographicDegrees"] = []
|
sat["position"]["cartographicDegrees"] = []
|
||||||
|
# print(y)
|
||||||
sat["description"] = SatDescrip[x]
|
sat["description"] = SatDescrip[x]
|
||||||
temp = y["start"]
|
temp = y["start"]
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -379,4 +387,4 @@ updateTransmitters()
|
||||||
getFuture()
|
getFuture()
|
||||||
updateCZML()
|
updateCZML()
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
app.run(use_reloader=False, host="0.0.0.0", port=8080)
|
app.run(use_reloader=False, host="0.0.0.0", port=5000)
|
||||||
|
|
Loading…
Reference in New Issue