Skip to content

Commit d9d5992

Browse files
committed
add orbit overlap
1 parent e1a0492 commit d9d5992

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

app/routes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from app import app
2-
from .service import satellitesData,issData
2+
from .service import satellitesData,issData,orbitOverlap
33
from flask import jsonify,render_template,url_for
44
from . import removeFile
55

@@ -47,4 +47,9 @@ def starlinkjson():
4747
satellitesData.satList.clear()
4848
url = 'https://www.celestrak.com/NORAD/elements/starlink.txt'
4949
satellitesData.getData(url)
50-
return jsonify({'data':satellitesData.satList,'total':len(satellitesData.satList)})
50+
return jsonify({'data':satellitesData.satList,'total':len(satellitesData.satList)})
51+
52+
@app.route('/api/orbitOverlap')
53+
def orbitOverlapGet():
54+
removeFile.remCall()
55+
return jsonify({'data':orbitOverlap.getData()})

app/service/orbitOverlap.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from skyfield.api import Topos, load
2+
import numpy as np
3+
from flask import jsonify
4+
5+
ts = load.timescale()
6+
7+
satellites = load.tle_file('https://www.celestrak.com/NORAD/elements/stations.txt')
8+
# sat = satellites[0]
9+
10+
def getData():
11+
satOrbits = []
12+
for sat in satellites:
13+
satOrbits.append(getOrbits(sat))
14+
return satOrbits
15+
16+
def getOrbits(sat):
17+
t_utc_now = ts.now().utc_datetime()
18+
# t_utc_now = ts.utc(2020,7,4,12,0,0)
19+
minutes = np.arange(0, 90, 0.1) # about one orbit
20+
year = int(t_utc_now.strftime("%Y"))
21+
month = int(t_utc_now.strftime("%m"))
22+
date = int(t_utc_now.strftime("%d"))
23+
# hour = int(t_utc_now.strftime("%H"))
24+
25+
# manually set time specs
26+
# year = 2020
27+
# month = 7
28+
# date = 4
29+
hour = 12
30+
31+
t_utc_now = ts.utc(year,month,date,hour,0,0).utc_datetime()
32+
33+
# times for orbits
34+
times = ts.utc(year,month,date,hour,minutes)
35+
36+
# current orbit
37+
geocentric = sat.at(times)
38+
subsatLat = geocentric.subpoint().latitude.degrees
39+
subsatLong = geocentric.subpoint().longitude.degrees
40+
41+
coordinateArr = []
42+
43+
for i in range(len(subsatLat)):
44+
coordinateArr.append([subsatLong[i],subsatLat[i]])
45+
46+
# print(coordinateArr)
47+
return ({'name':str(sat.name),'number':str(sat.model.satnum),
48+
'timestamp': str(t_utc_now),
49+
'orbitalData': coordinateArr
50+
})

app/templates/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ <h2>Welcome to SatTrack!</h2>
2828
<li>
2929
<a href="/api/issOrbit">/api/issOrbit</a>
3030
</li>
31+
<li>
32+
<a href="/api/orbitOverlap">/api/orbitOverlap</a>
33+
</li>
3134
</ul>
3235
</p>
3336
</body>

0 commit comments

Comments
 (0)