1
0
Fork 0

Update production patches to source

master
William Gaylord 2019-10-02 21:51:20 +00:00
parent 3e9f9ac4a5
commit de4f6c0b9b
2 changed files with 53 additions and 20 deletions

View File

@ -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 satellite_tle import fetch_tles
from skyfield.api import EarthSatellite, utc, load from skyfield.api import EarthSatellite, utc, load
import numpy import numpy
#from pympler import muppy, summary
scheduler = BackgroundScheduler() scheduler = BackgroundScheduler()
app = Flask(__name__) app = Flask(__name__)
@ -36,6 +37,9 @@ def getFuture():
print("Getting future Passes") print("Getting future Passes")
global Observations global Observations
global TLEs global TLEs
global StationsPasses
TLEs = 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(minutes=30))
@ -45,7 +49,9 @@ def getFuture():
#for x in tqdm(obs): #for x in tqdm(obs):
# observations[x["id"]] = x # observations[x["id"]] = x
Observations = defaultdict(list) Observations = defaultdict(list)
for x in tqdm(passes): for x in passes:
if x["ground_station"] == None:
continue
#if x["id"] in observations: #if x["id"] in observations:
norad = int(x["tle1"].split(" ")[1].replace("U","")) norad = int(x["tle1"].split(" ")[1].replace("U",""))
try: try:
@ -60,12 +66,16 @@ def getFuture():
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[norad][x["transmitter"]], "start": start, "end": end, "id": x["id"]})
except Exception as e: except Exception as e:
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))
del observations
del passes
del End
del Start
print(str(len(Observations))+" Future passes found.") print(str(len(Observations))+" Future passes found.")
def GetGroundStations(): def GetGroundStations():
print("Getting Ground Stations") print("Getting Ground Stations")
stations = get_paginated_endpoint("https://network.satnogs.org/api/stations/") stations = get_paginated_endpoint("https://network.satnogs.org/api/stations/")
@ -75,6 +85,7 @@ def GetGroundStations():
def FindPasses(observations_): def FindPasses(observations_):
print("Finding Future Passes")
observations = observations_.copy() observations = observations_.copy()
passses = [] passses = []
observation = observations.pop(0) observation = observations.pop(0)
@ -88,6 +99,7 @@ def FindPasses(observations_):
passses.append(observation) passses.append(observation)
observation = x observation = x
passses.append(observation) passses.append(observation)
print("Finished Finding Future Passes")
return passses return passses
@ -114,21 +126,33 @@ def updateTransmitters():
global Transmitters global Transmitters
global SatDescrip global SatDescrip
SatDescrip = {} SatDescrip = {}
Transmitters = defaultdict(dict)
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 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]] 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"]] = "" SatDescrip[x["norad_cat_id"]] = ""
for x in Transmitters.keys(): for x in Transmitters.keys():
for y in Transmitters[x].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>' 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) @scheduler.scheduled_job('interval', minutes=15)#hours=1)
def updatePasses(): def updatePasses():
getFuture() getFuture()
updateCZML() 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) @scheduler.scheduled_job('interval', hours=1)
def updateStations(): def updateStations():
@ -139,6 +163,7 @@ def updateStations():
#@scheduler.scheduled_job('interval', minutes=5) #@scheduler.scheduled_job('interval', minutes=5)
def updateCZML(): def updateCZML():
print("Updating CZML")
global CZMLOnline global CZMLOnline
global CZMLOffline global CZMLOffline
global CZMLTesting global CZMLTesting
@ -152,7 +177,7 @@ def updateCZML():
CZMLOnline.append(onlineDoc) CZMLOnline.append(onlineDoc)
CZMLTesting.append(testingDoc) CZMLTesting.append(testingDoc)
for x in tqdm(Stations): for x in Stations:
color = [0, 230, 64, 255] color = [0, 230, 64, 255]
if x["status"] == "Testing": if x["status"] == "Testing":
color = [248, 148, 6, 255] color = [248, 148, 6, 255]
@ -183,7 +208,7 @@ def updateCZML():
else: else:
CZMLOnline.append(station) CZMLOnline.append(station)
AliveSats = [] AliveSats = []
for x in tqdm(Observations.keys()): for x in Observations.keys():
for y in Observations[x]: for y in Observations[x]:
sat = {} sat = {}
sat["id"] = str(y["id"]) sat["id"] = str(y["id"])
@ -211,16 +236,22 @@ def updateCZML():
time += 60 time += 60
temp = temp + timedelta(minutes=1) temp = temp + timedelta(minutes=1)
else: else:
if StationsByID[y["station"]]["status"] =="Testing": try:
CZMLTesting.append(sat) # print(StationsByID)
else: # print(y["station"])
if StationsByID[y["station"]]["status"] == "Offline": if StationsByID[y["station"]]["status"] =="Testing":
CZMLOffline.append(sat) CZMLTesting.append(sat)
else: 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"])) AliveSats.append(str(y["id"]))
for x in tqdm(Observations.keys()): for x in Observations.keys():
for y in Observations[x]: for y in Observations[x]:
if str(y["id"]) in AliveSats: if str(y["id"]) in AliveSats:
sat = {} sat = {}
@ -233,7 +264,7 @@ def updateCZML():
CZMLOffline.append(sat) CZMLOffline.append(sat)
else: else:
CZMLOnline.append(sat) CZMLOnline.append(sat)
print("Finished Updating CZML")
@app.route("/") @app.route("/")
def index(): def index():
@ -348,4 +379,4 @@ updateTransmitters()
getFuture() getFuture()
updateCZML() updateCZML()
scheduler.start() 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)

View File

@ -9,8 +9,8 @@
<style> <style>
#overlay { #overlay {
position: absolute; position: absolute;
left: 10px; left: 50px;
top: 10px; top: 30px;
background-color: rgba(0, 0, 0, 1); background-color: rgba(0, 0, 0, 1);
color: white; color: white;
font-family: monospace; font-family: monospace;
@ -37,6 +37,7 @@
Offline = Cesium.CzmlDataSource.load("/czmloff") Offline = Cesium.CzmlDataSource.load("/czmloff")
Testing = Cesium.CzmlDataSource.load("/czmltest") Testing = Cesium.CzmlDataSource.load("/czmltest")
document.getElementById("online").checked = true; document.getElementById("online").checked = true;
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwYmEwOTc5YS01N2I3LTRhYmQtOGE0MS1lNTkyMWU2ZmM3YWUiLCJpZCI6Njg1OCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0NzU5ODkxOX0.p4alNyuyt_Eufuo8xX_SB6HKHuSixBTxgiVpD6UGI3Y'; 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({ 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', mapId: 'mapbox.streets',
@ -51,7 +52,8 @@
viewer.clock.currentTime = now; viewer.clock.currentTime = now;
viewer.clock.shouldAnimate = true viewer.clock.shouldAnimate = true
toggle() toggle()
temp = 0 update()
temp = 0
viewer.camera.zoomIn(1000000*4) viewer.camera.zoomIn(1000000*4)
function icrf(scene, time) { function icrf(scene, time) {