Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroNolan authored Oct 3, 2024
1 parent feaec5c commit dc9868a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import numpy as np
import plotly.graph_objects as go
from datetime import datetime, timedelta, timezone
import threading
import time as time_module
import requests
import logging
Expand Down Expand Up @@ -126,6 +125,8 @@ def NextPassage(tle_raw, obs_lat, obs_lon):
break

next_visibility['MAX'] = next_visibility['MAX'] or first_passage
del tle, station, orb
gc.collect()
return next_visibility

def NextPassageUpdate(tle, obs_lat, obs_lon):
Expand All @@ -144,7 +145,7 @@ def NextPassageUpdate(tle, obs_lat, obs_lon):
'azimuth': f"{azimuth:.2f}°",
'elevation': f"{elevation:.2f}°",
'distance': f"{distance:.0f} km"
}
}

return ((next_passage_time['AOS']['date'].datetime.replace(tzinfo=timezone.utc) if next_passage_time.get('AOS') else None),
(next_passage_time['MAX']['date'].datetime.replace(tzinfo=timezone.utc) if next_passage_time.get('MAX') else None),
Expand Down Expand Up @@ -250,11 +251,12 @@ def update_orbit_data():

socketio.emit('update_orbit', {'fig': fig_dict, 'tle_update_time': tle_update_time})
socketio.emit('next_passage_time', next_passage_data)
del gp, fig_dict, prs_spacecraft, t_span
gc.collect()

iteration_duration = time_module.time() - iteration_start_time
sleep_time = max(0, target_iteration_time - iteration_duration)
time_module.sleep(sleep_time)
socketio.sleep(sleep_time)

@socketio.on('update_observer')
def handle_update_observer(data):
Expand All @@ -272,7 +274,5 @@ def index():
return render_template('index.html', observer_lat=observer_lat, observer_lon=observer_lon)

if __name__ == '__main__':
thread = threading.Thread(target=update_orbit_data)
thread.daemon = True
thread.start()
socketio.start_background_task(update_orbit_data)
socketio.run(app, host='127.0.0.1', port=int(os.getenv("PORT", 5000)), debug=False)
9 changes: 7 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PariSat Live Tracking</title>
<link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<style>
body, html {
Expand Down Expand Up @@ -40,14 +41,18 @@
height: 100%;
padding: 10px;
box-sizing: border-box;
align-items: center;
justify-content: center;
}
#plot {
flex: 0 1 70%;
height: 100%;
height: 95%;
align-items: center;
justify-content: center;
}
#description {
flex: 0 1 30%;
height: 100%;
height: auto;
display: flex;
flex-direction: column;
align-items: left;
Expand Down

0 comments on commit dc9868a

Please sign in to comment.