Update production patches to source
parent
3e9f9ac4a5
commit
de4f6c0b9b
65
satnogs.py
65
satnogs.py
|
@ -11,6 +11,7 @@ from satnogs_api_client.satnogs_api_client import DB_BASE_URL, get_paginated_end
|
|||
from satellite_tle import fetch_tles
|
||||
from skyfield.api import EarthSatellite, utc, load
|
||||
import numpy
|
||||
#from pympler import muppy, summary
|
||||
|
||||
scheduler = BackgroundScheduler()
|
||||
app = Flask(__name__)
|
||||
|
@ -36,6 +37,9 @@ def getFuture():
|
|||
print("Getting future Passes")
|
||||
global Observations
|
||||
global TLEs
|
||||
global StationsPasses
|
||||
TLEs = defaultdict(list)
|
||||
StationsPasses = defaultdict(list)
|
||||
observations = defaultdict(dict)
|
||||
Start = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
End = (datetime.utcnow() + timedelta(minutes=30))
|
||||
|
@ -45,7 +49,9 @@ def getFuture():
|
|||
#for x in tqdm(obs):
|
||||
# observations[x["id"]] = x
|
||||
Observations = defaultdict(list)
|
||||
for x in tqdm(passes):
|
||||
for x in passes:
|
||||
if x["ground_station"] == None:
|
||||
continue
|
||||
#if x["id"] in observations:
|
||||
norad = int(x["tle1"].split(" ")[1].replace("U",""))
|
||||
try:
|
||||
|
@ -60,12 +66,16 @@ def getFuture():
|
|||
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"]})
|
||||
except Exception as e:
|
||||
pass
|
||||
print("Error on observation number: " + str(x["id"]) + " "+str(norad)+" " + str(e))
|
||||
|
||||
del observations
|
||||
del passes
|
||||
del End
|
||||
del Start
|
||||
print(str(len(Observations))+" Future passes found.")
|
||||
|
||||
|
||||
|
||||
|
||||
def GetGroundStations():
|
||||
print("Getting Ground Stations")
|
||||
stations = get_paginated_endpoint("https://network.satnogs.org/api/stations/")
|
||||
|
@ -75,6 +85,7 @@ def GetGroundStations():
|
|||
|
||||
|
||||
def FindPasses(observations_):
|
||||
print("Finding Future Passes")
|
||||
observations = observations_.copy()
|
||||
passses = []
|
||||
observation = observations.pop(0)
|
||||
|
@ -88,6 +99,7 @@ def FindPasses(observations_):
|
|||
passses.append(observation)
|
||||
observation = x
|
||||
passses.append(observation)
|
||||
print("Finished Finding Future Passes")
|
||||
return passses
|
||||
|
||||
|
||||
|
@ -114,21 +126,33 @@ def updateTransmitters():
|
|||
global Transmitters
|
||||
global SatDescrip
|
||||
SatDescrip = {}
|
||||
Transmitters = defaultdict(dict)
|
||||
print("Updating Transmitters")
|
||||
temp = requests.get("https://db.satnogs.org/api/transmitters/").json()
|
||||
for x in tqdm(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]]
|
||||
SatDescrip[x["norad_cat_id"]] = ""
|
||||
for x in Transmitters.keys():
|
||||
for y in Transmitters[x].keys():
|
||||
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>'
|
||||
|
||||
print("Finished Updating Transmitters")
|
||||
|
||||
@scheduler.scheduled_job('interval', minutes=15)#hours=1)
|
||||
def updatePasses():
|
||||
getFuture()
|
||||
updateCZML()
|
||||
|
||||
# total = 0
|
||||
# for x in StationsPasses.keys():
|
||||
# total+=len(StationsPasses[x])
|
||||
# print("Total StationsPassses: " +str(total))
|
||||
# print("Total TLE: "+str(len(TLEs)))
|
||||
# print("Total Passes: "+str(len(Passes)))
|
||||
#print("Total StationsPasses: "+str(len(StationsPasses)))
|
||||
# all_objects = muppy.get_objects()
|
||||
# sum1 = summary.summarize(all_objects)
|
||||
# summary.print_(sum1)
|
||||
# del all_objects
|
||||
# del sum1
|
||||
|
||||
@scheduler.scheduled_job('interval', hours=1)
|
||||
def updateStations():
|
||||
|
@ -139,6 +163,7 @@ def updateStations():
|
|||
|
||||
#@scheduler.scheduled_job('interval', minutes=5)
|
||||
def updateCZML():
|
||||
print("Updating CZML")
|
||||
global CZMLOnline
|
||||
global CZMLOffline
|
||||
global CZMLTesting
|
||||
|
@ -152,7 +177,7 @@ def updateCZML():
|
|||
CZMLOnline.append(onlineDoc)
|
||||
CZMLTesting.append(testingDoc)
|
||||
|
||||
for x in tqdm(Stations):
|
||||
for x in Stations:
|
||||
color = [0, 230, 64, 255]
|
||||
if x["status"] == "Testing":
|
||||
color = [248, 148, 6, 255]
|
||||
|
@ -183,7 +208,7 @@ def updateCZML():
|
|||
else:
|
||||
CZMLOnline.append(station)
|
||||
AliveSats = []
|
||||
for x in tqdm(Observations.keys()):
|
||||
for x in Observations.keys():
|
||||
for y in Observations[x]:
|
||||
sat = {}
|
||||
sat["id"] = str(y["id"])
|
||||
|
@ -211,16 +236,22 @@ def updateCZML():
|
|||
time += 60
|
||||
temp = temp + timedelta(minutes=1)
|
||||
else:
|
||||
if StationsByID[y["station"]]["status"] =="Testing":
|
||||
CZMLTesting.append(sat)
|
||||
else:
|
||||
if StationsByID[y["station"]]["status"] == "Offline":
|
||||
CZMLOffline.append(sat)
|
||||
try:
|
||||
# print(StationsByID)
|
||||
# print(y["station"])
|
||||
if StationsByID[y["station"]]["status"] =="Testing":
|
||||
CZMLTesting.append(sat)
|
||||
else:
|
||||
CZMLOnline.append(sat)
|
||||
if StationsByID[y["station"]]["status"] == "Offline":
|
||||
CZMLOffline.append(sat)
|
||||
else:
|
||||
CZMLOnline.append(sat)
|
||||
except:
|
||||
print(y)
|
||||
print(StationsByID[y["station"]])
|
||||
AliveSats.append(str(y["id"]))
|
||||
|
||||
for x in tqdm(Observations.keys()):
|
||||
for x in Observations.keys():
|
||||
for y in Observations[x]:
|
||||
if str(y["id"]) in AliveSats:
|
||||
sat = {}
|
||||
|
@ -233,7 +264,7 @@ def updateCZML():
|
|||
CZMLOffline.append(sat)
|
||||
else:
|
||||
CZMLOnline.append(sat)
|
||||
|
||||
print("Finished Updating CZML")
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
@ -348,4 +379,4 @@ updateTransmitters()
|
|||
getFuture()
|
||||
updateCZML()
|
||||
scheduler.start()
|
||||
app.run(use_reloader=False, host="0.0.0.0", port=5000)
|
||||
app.run(use_reloader=False, host="0.0.0.0", port=8080)
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<style>
|
||||
#overlay {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
left: 50px;
|
||||
top: 30px;
|
||||
background-color: rgba(0, 0, 0, 1);
|
||||
color: white;
|
||||
font-family: monospace;
|
||||
|
@ -37,6 +37,7 @@
|
|||
Offline = Cesium.CzmlDataSource.load("/czmloff")
|
||||
Testing = Cesium.CzmlDataSource.load("/czmltest")
|
||||
document.getElementById("online").checked = true;
|
||||
|
||||
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwYmEwOTc5YS01N2I3LTRhYmQtOGE0MS1lNTkyMWU2ZmM3YWUiLCJpZCI6Njg1OCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0NzU5ODkxOX0.p4alNyuyt_Eufuo8xX_SB6HKHuSixBTxgiVpD6UGI3Y';
|
||||
var viewer = new Cesium.Viewer('cesiumContainer',{shadows:true,timeline:false,vrButton:false,homeButton:false,animation:true,baseLayerPicker:false,navigationInstructionsInitiallyVisible:false,navigationHelpButton:false,imageryProvider :new Cesium.MapboxImageryProvider({
|
||||
mapId: 'mapbox.streets',
|
||||
|
@ -51,7 +52,8 @@
|
|||
viewer.clock.currentTime = now;
|
||||
viewer.clock.shouldAnimate = true
|
||||
toggle()
|
||||
temp = 0
|
||||
update()
|
||||
temp = 0
|
||||
viewer.camera.zoomIn(1000000*4)
|
||||
|
||||
function icrf(scene, time) {
|
||||
|
|
Loading…
Reference in New Issue