Add License and also strip out soemthing that is a lib.
parent
a4dc3721f6
commit
bdb9c59815
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 William Gaylord
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
|
@ -1,2 +1,3 @@
|
||||||
# SatnogsMap
|
# SatnogsMap
|
||||||
|
|
||||||
|
Uses Satnogs data to generate a map of all stations on Production and all sats currently observed.
|
|
@ -1,2 +0,0 @@
|
||||||
from .fetch_tle import * # noqa
|
|
||||||
from .fetch_tles import * # noqa
|
|
|
@ -1,64 +0,0 @@
|
||||||
import csv
|
|
||||||
from lxml import html
|
|
||||||
import requests
|
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
SOURCES_LIST = pkg_resources.resource_filename('satellite_tle', 'sources.csv')
|
|
||||||
|
|
||||||
|
|
||||||
def get_tle_sources():
|
|
||||||
'''
|
|
||||||
Returns a list of (source, url)-tuples for well-known TLE sources.
|
|
||||||
'''
|
|
||||||
|
|
||||||
sources = []
|
|
||||||
|
|
||||||
with open(SOURCES_LIST) as csvfile:
|
|
||||||
csv_reader = csv.reader(csvfile,
|
|
||||||
delimiter=',',
|
|
||||||
quotechar='\'',
|
|
||||||
quoting=csv.QUOTE_NONNUMERIC)
|
|
||||||
for row in csv_reader:
|
|
||||||
source, url = row
|
|
||||||
sources.append((source, url))
|
|
||||||
|
|
||||||
return sources
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_tle_from_celestrak(norad_cat_id):
|
|
||||||
'''
|
|
||||||
Returns the TLE for a given norad_cat_id as currently available from CelesTrak.
|
|
||||||
Raises IndexError if no data is available for the given norad_cat_id.
|
|
||||||
'''
|
|
||||||
|
|
||||||
r = requests.get('https://www.celestrak.com/satcat/tle.php?CATNR={}'.format(norad_cat_id))
|
|
||||||
page = html.fromstring(r.text)
|
|
||||||
|
|
||||||
tle = page.xpath('//pre/text()')[0].split('\n')
|
|
||||||
if tle[1].strip() == 'No TLE found':
|
|
||||||
raise LookupError
|
|
||||||
|
|
||||||
return tle[1].strip(), tle[2].strip(), tle[3].strip()
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_tles_from_url(url):
|
|
||||||
'''
|
|
||||||
Downloads the TLE set from the given url.
|
|
||||||
Returns a dictionary of the form {norad_id1: tle1, norad_id2: tle2} for all TLEs found.
|
|
||||||
tleN is returned as list of three strings: [satellite_name, line1, line2].
|
|
||||||
'''
|
|
||||||
|
|
||||||
r = requests.get(url)
|
|
||||||
|
|
||||||
tles = dict()
|
|
||||||
l0 = ''
|
|
||||||
l1 = ''
|
|
||||||
lines = r.text.splitlines()
|
|
||||||
for l in lines[:-1]:
|
|
||||||
if l[0] == '2':
|
|
||||||
norad_cat_id = int(l1[2:7].encode('ascii'))
|
|
||||||
tles[norad_cat_id] = (l0.strip(), l1, l)
|
|
||||||
l0 = l1
|
|
||||||
l1 = l
|
|
||||||
|
|
||||||
return tles
|
|
|
@ -1,66 +0,0 @@
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from sgp4.earth_gravity import wgs72
|
|
||||||
from sgp4.io import twoline2rv
|
|
||||||
|
|
||||||
from . import get_tle_sources, fetch_tles_from_url, fetch_tle_from_celestrak
|
|
||||||
|
|
||||||
|
|
||||||
def fetch_tles(requested_norad_ids):
|
|
||||||
'''
|
|
||||||
Returns the most recent TLEs found for the requested satellites
|
|
||||||
available via Celestrak, CalPoly and AMSAT.
|
|
||||||
'''
|
|
||||||
|
|
||||||
# List of 2-tuples of the form (source, tle)
|
|
||||||
# source is a human-readable string
|
|
||||||
# tle is a 3-tuple of strings
|
|
||||||
tles = dict()
|
|
||||||
|
|
||||||
def update_tles(source, tle):
|
|
||||||
if norad_id not in requested_norad_ids:
|
|
||||||
# Satellite not requested,
|
|
||||||
# skip.
|
|
||||||
return
|
|
||||||
|
|
||||||
if norad_id not in tles.keys():
|
|
||||||
# Satellite requested and first occurence in the downloaded data,
|
|
||||||
# store new TLE.
|
|
||||||
#print('Found {}'.format(norad_id))
|
|
||||||
tles[norad_id] = source, tle
|
|
||||||
return
|
|
||||||
|
|
||||||
# There are multiple TLEs for this satellite available.
|
|
||||||
# Parse and compare epoch of both TLEs and choose the most recent one.
|
|
||||||
current_sat = twoline2rv(tles[norad_id][1][1], tles[norad_id][1][2], wgs72)
|
|
||||||
new_sat = twoline2rv(tle[1], tle[2], wgs72)
|
|
||||||
if new_sat.epoch > current_sat.epoch:
|
|
||||||
# Found a more recent TLE than the current one,
|
|
||||||
# store the new TLE.
|
|
||||||
|
|
||||||
tles[norad_id] = source, tle
|
|
||||||
|
|
||||||
# Fetch TLE sets from well-known TLE sources
|
|
||||||
sources = get_tle_sources()
|
|
||||||
|
|
||||||
for source, url in sources:
|
|
||||||
#print('Fetch from {}'.format(url))
|
|
||||||
new_tles = fetch_tles_from_url(url=url)
|
|
||||||
|
|
||||||
for norad_id, tle in new_tles.items():
|
|
||||||
update_tles(source, tle)
|
|
||||||
|
|
||||||
# Try fetching missing sats from another Celestrak endoint
|
|
||||||
missing_norad_ids = set(requested_norad_ids) - set(tles.keys())
|
|
||||||
|
|
||||||
for norad_id in missing_norad_ids:
|
|
||||||
try:
|
|
||||||
#print('Fetching {} from Celestrak (satcat):'.format(norad_id), end='')
|
|
||||||
tle = fetch_tle_from_celestrak(norad_id)
|
|
||||||
#print(' ok, ', end='')
|
|
||||||
update_tles('Celestrak (satcat)', tle)
|
|
||||||
except LookupError:
|
|
||||||
#print(' failed.')
|
|
||||||
continue
|
|
||||||
|
|
||||||
return tles
|
|
|
@ -1,46 +0,0 @@
|
||||||
'CalPoly','http://mstl.atl.calpoly.edu/~ops/keps/kepler.txt'
|
|
||||||
'AMSAT','https://www.amsat.org/amsat/ftp/keps/current/nasabare.txt'
|
|
||||||
'Celestrak (tle-new)','https://www.celestrak.com/NORAD/elements/tle-new.txt'
|
|
||||||
'Celestrak (stations)','https://www.celestrak.com/NORAD/elements/stations.txt'
|
|
||||||
'Celestrak (visual)','https://www.celestrak.com/NORAD/elements/visual.txt'
|
|
||||||
'Celestrak (1999-025)','https://www.celestrak.com/NORAD/elements/1999-025.txt'
|
|
||||||
'Celestrak (iridium-33-debris)','https://www.celestrak.com/NORAD/elements/iridium-33-debris.txt'
|
|
||||||
'Celestrak (cosmos-2251-debris)','https://www.celestrak.com/NORAD/elements/cosmos-2251-debris.txt'
|
|
||||||
'Celestrak (2012-044)','https://www.celestrak.com/NORAD/elements/2012-044.txt'
|
|
||||||
'Celestrak (weather)','https://www.celestrak.com/NORAD/elements/weather.txt'
|
|
||||||
'Celestrak (noaa)','https://www.celestrak.com/NORAD/elements/noaa.txt'
|
|
||||||
'Celestrak (goes)','https://www.celestrak.com/NORAD/elements/goes.txt'
|
|
||||||
'Celestrak (resource)','https://www.celestrak.com/NORAD/elements/resource.txt'
|
|
||||||
'Celestrak (sarsat)','https://www.celestrak.com/NORAD/elements/sarsat.txt'
|
|
||||||
'Celestrak (dmc)','https://www.celestrak.com/NORAD/elements/dmc.txt'
|
|
||||||
'Celestrak (tdrss)','https://www.celestrak.com/NORAD/elements/tdrss.txt'
|
|
||||||
'Celestrak (argos)','https://www.celestrak.com/NORAD/elements/argos.txt'
|
|
||||||
'Celestrak (planet)','https://www.celestrak.com/NORAD/elements/planet.txt'
|
|
||||||
'Celestrak (spire)','https://www.celestrak.com/NORAD/elements/spire.txt'
|
|
||||||
'Celestrak (geo)','https://www.celestrak.com/NORAD/elements/geo.txt'
|
|
||||||
'Celestrak (intelsat)','https://www.celestrak.com/NORAD/elements/intelsat.txt'
|
|
||||||
'Celestrak (ses)','https://www.celestrak.com/NORAD/elements/ses.txt'
|
|
||||||
'Celestrak (iridium)','https://www.celestrak.com/NORAD/elements/iridium.txt'
|
|
||||||
'Celestrak (iridium-NEXT)','https://www.celestrak.com/NORAD/elements/iridium-NEXT.txt'
|
|
||||||
'Celestrak (orbcomm)','https://www.celestrak.com/NORAD/elements/orbcomm.txt'
|
|
||||||
'Celestrak (globalstar)','https://www.celestrak.com/NORAD/elements/globalstar.txt'
|
|
||||||
'Celestrak (amateur)','https://www.celestrak.com/NORAD/elements/amateur.txt'
|
|
||||||
'Celestrak (other-comm)','https://www.celestrak.com/NORAD/elements/other-comm.txt'
|
|
||||||
'Celestrak (gorizont)','https://www.celestrak.com/NORAD/elements/gorizont.txt'
|
|
||||||
'Celestrak (raduga)','https://www.celestrak.com/NORAD/elements/raduga.txt'
|
|
||||||
'Celestrak (molniya)','https://www.celestrak.com/NORAD/elements/molniya.txt'
|
|
||||||
'Celestrak (gps-ops)','https://www.celestrak.com/NORAD/elements/gps-ops.txt'
|
|
||||||
'Celestrak (glo-ops)','https://www.celestrak.com/NORAD/elements/glo-ops.txt'
|
|
||||||
'Celestrak (galileo)','https://www.celestrak.com/NORAD/elements/galileo.txt'
|
|
||||||
'Celestrak (beidou)','https://www.celestrak.com/NORAD/elements/beidou.txt'
|
|
||||||
'Celestrak (sbas)','https://www.celestrak.com/NORAD/elements/sbas.txt'
|
|
||||||
'Celestrak (nnss)','https://www.celestrak.com/NORAD/elements/nnss.txt'
|
|
||||||
'Celestrak (musson)','https://www.celestrak.com/NORAD/elements/musson.txt'
|
|
||||||
'Celestrak (science)','https://www.celestrak.com/NORAD/elements/science.txt'
|
|
||||||
'Celestrak (geodetic)','https://www.celestrak.com/NORAD/elements/geodetic.txt'
|
|
||||||
'Celestrak (engineering)','https://www.celestrak.com/NORAD/elements/engineering.txt'
|
|
||||||
'Celestrak (education)','https://www.celestrak.com/NORAD/elements/education.txt'
|
|
||||||
'Celestrak (military)','https://www.celestrak.com/NORAD/elements/military.txt'
|
|
||||||
'Celestrak (radar)','https://www.celestrak.com/NORAD/elements/radar.txt'
|
|
||||||
'Celestrak (cubesat)','https://www.celestrak.com/NORAD/elements/cubesat.txt'
|
|
||||||
'Celestrak (other)','https://www.celestrak.com/NORAD/elements/other.txt'
|
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
"""The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Sean Herron, 2018 Fabian P. Schmidt
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
"""
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ var sat = L.icon({
|
||||||
|
|
||||||
var station = L.icon({
|
var station = L.icon({
|
||||||
iconUrl: 'static/station-marker.png',
|
iconUrl: 'static/station-marker.png',
|
||||||
iconSize: [20, 20],
|
iconSize: [5, 5],
|
||||||
iconAnchor: [10, 10],
|
iconAnchor: [2, 2],
|
||||||
popupAnchor: [0, 0],
|
popupAnchor: [0, 0],
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -68,9 +68,9 @@ stationList = {}
|
||||||
{%endfor%}
|
{%endfor%}
|
||||||
|
|
||||||
|
|
||||||
sats = {}
|
var sats = {}
|
||||||
|
|
||||||
links = {}
|
var links = {}
|
||||||
|
|
||||||
|
|
||||||
$.get("/api/occuringsats", function(data, status){
|
$.get("/api/occuringsats", function(data, status){
|
||||||
|
|
Loading…
Reference in New Issue