1
0
Fork 0

Add License and also strip out soemthing that is a lib.

dev
wgaylord 2018-10-24 15:45:34 -05:00
parent a4dc3721f6
commit bdb9c59815
8 changed files with 49 additions and 182 deletions

21
LICENSE.txt 100644
View File

@ -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.

View File

@ -1,2 +1,3 @@
# SatnogsMap
Uses Satnogs data to generate a map of all stations on Production and all sats currently observed.

View File

@ -1,2 +0,0 @@
from .fetch_tle import * # noqa
from .fetch_tles import * # noqa

View File

@ -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

View File

@ -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

View File

@ -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 'CalPoly' 'http://mstl.atl.calpoly.edu/~ops/keps/kepler.txt'
2 'AMSAT' 'https://www.amsat.org/amsat/ftp/keps/current/nasabare.txt'
3 'Celestrak (tle-new)' 'https://www.celestrak.com/NORAD/elements/tle-new.txt'
4 'Celestrak (stations)' 'https://www.celestrak.com/NORAD/elements/stations.txt'
5 'Celestrak (visual)' 'https://www.celestrak.com/NORAD/elements/visual.txt'
6 'Celestrak (1999-025)' 'https://www.celestrak.com/NORAD/elements/1999-025.txt'
7 'Celestrak (iridium-33-debris)' 'https://www.celestrak.com/NORAD/elements/iridium-33-debris.txt'
8 'Celestrak (cosmos-2251-debris)' 'https://www.celestrak.com/NORAD/elements/cosmos-2251-debris.txt'
9 'Celestrak (2012-044)' 'https://www.celestrak.com/NORAD/elements/2012-044.txt'
10 'Celestrak (weather)' 'https://www.celestrak.com/NORAD/elements/weather.txt'
11 'Celestrak (noaa)' 'https://www.celestrak.com/NORAD/elements/noaa.txt'
12 'Celestrak (goes)' 'https://www.celestrak.com/NORAD/elements/goes.txt'
13 'Celestrak (resource)' 'https://www.celestrak.com/NORAD/elements/resource.txt'
14 'Celestrak (sarsat)' 'https://www.celestrak.com/NORAD/elements/sarsat.txt'
15 'Celestrak (dmc)' 'https://www.celestrak.com/NORAD/elements/dmc.txt'
16 'Celestrak (tdrss)' 'https://www.celestrak.com/NORAD/elements/tdrss.txt'
17 'Celestrak (argos)' 'https://www.celestrak.com/NORAD/elements/argos.txt'
18 'Celestrak (planet)' 'https://www.celestrak.com/NORAD/elements/planet.txt'
19 'Celestrak (spire)' 'https://www.celestrak.com/NORAD/elements/spire.txt'
20 'Celestrak (geo)' 'https://www.celestrak.com/NORAD/elements/geo.txt'
21 'Celestrak (intelsat)' 'https://www.celestrak.com/NORAD/elements/intelsat.txt'
22 'Celestrak (ses)' 'https://www.celestrak.com/NORAD/elements/ses.txt'
23 'Celestrak (iridium)' 'https://www.celestrak.com/NORAD/elements/iridium.txt'
24 'Celestrak (iridium-NEXT)' 'https://www.celestrak.com/NORAD/elements/iridium-NEXT.txt'
25 'Celestrak (orbcomm)' 'https://www.celestrak.com/NORAD/elements/orbcomm.txt'
26 'Celestrak (globalstar)' 'https://www.celestrak.com/NORAD/elements/globalstar.txt'
27 'Celestrak (amateur)' 'https://www.celestrak.com/NORAD/elements/amateur.txt'
28 'Celestrak (other-comm)' 'https://www.celestrak.com/NORAD/elements/other-comm.txt'
29 'Celestrak (gorizont)' 'https://www.celestrak.com/NORAD/elements/gorizont.txt'
30 'Celestrak (raduga)' 'https://www.celestrak.com/NORAD/elements/raduga.txt'
31 'Celestrak (molniya)' 'https://www.celestrak.com/NORAD/elements/molniya.txt'
32 'Celestrak (gps-ops)' 'https://www.celestrak.com/NORAD/elements/gps-ops.txt'
33 'Celestrak (glo-ops)' 'https://www.celestrak.com/NORAD/elements/glo-ops.txt'
34 'Celestrak (galileo)' 'https://www.celestrak.com/NORAD/elements/galileo.txt'
35 'Celestrak (beidou)' 'https://www.celestrak.com/NORAD/elements/beidou.txt'
36 'Celestrak (sbas)' 'https://www.celestrak.com/NORAD/elements/sbas.txt'
37 'Celestrak (nnss)' 'https://www.celestrak.com/NORAD/elements/nnss.txt'
38 'Celestrak (musson)' 'https://www.celestrak.com/NORAD/elements/musson.txt'
39 'Celestrak (science)' 'https://www.celestrak.com/NORAD/elements/science.txt'
40 'Celestrak (geodetic)' 'https://www.celestrak.com/NORAD/elements/geodetic.txt'
41 'Celestrak (engineering)' 'https://www.celestrak.com/NORAD/elements/engineering.txt'
42 'Celestrak (education)' 'https://www.celestrak.com/NORAD/elements/education.txt'
43 'Celestrak (military)' 'https://www.celestrak.com/NORAD/elements/military.txt'
44 'Celestrak (radar)' 'https://www.celestrak.com/NORAD/elements/radar.txt'
45 'Celestrak (cubesat)' 'https://www.celestrak.com/NORAD/elements/cubesat.txt'
46 'Celestrak (other)' 'https://www.celestrak.com/NORAD/elements/other.txt'

View File

@ -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 re

View File

@ -36,8 +36,8 @@ var sat = L.icon({
var station = L.icon({
iconUrl: 'static/station-marker.png',
iconSize: [20, 20],
iconAnchor: [10, 10],
iconSize: [5, 5],
iconAnchor: [2, 2],
popupAnchor: [0, 0],
});
@ -68,9 +68,9 @@ stationList = {}
{%endfor%}
sats = {}
var sats = {}
links = {}
var links = {}
$.get("/api/occuringsats", function(data, status){