Commit 5030ec7f authored by Jan Horák's avatar Jan Horák
Browse files

Upload New File

parent 5dad7591
import requests
from pprint import pprint
import maidenhead
import sys
DATUM_OD = 20200302
markers = ''
polyline = 'var polyline = [\n'
infowindows = ''
listeners = ''
s = requests.Session()
zaznamy = []
min_lat = None
max_lat = None
min_lng = None
max_lng = None
for call in ['OK1RAJ', '0C1***']:
#for call in ['OH2BC']:
r = s.post('http://wsprnet.org/drupal/wsprnet/spotquery', data={"band":"All","count":"1000","call":call,"reporter":"","timelimit":"1209600","sortby":"date","op":"Update","form_build_id":"form-p2q1omC2Cxm9qBh2W9grIIdFzsxTNXVLGDSSY7F3TEA","form_id":"wsprnet_spotquery_form"})
print(r.status_code)
r = s.get('http://wsprnet.org/drupal/wsprnet/spots')
print(r.status_code)
#pprint(r.text)
table = r.text[r.text.find('</tr>', r.text.find('Timestamp')):r.text.find('</table', r.text.find('Timestamp'))]
#print()
#print(table)
zapisy_html = table.split('</tr>')
zapisy_html = zapisy_html[1:-1]
num = 1
for zapis in zapisy_html:
udaje = zapis.split('</td><td')
#print('udaje', udaje)
print('udaje0', udaje[0])
timestamp = udaje[0].split('&nbsp;')[1]
print(timestamp)
call = udaje[1].split('&nbsp;')[1]
print(call)
mhz = udaje[2].split('&nbsp;')[1]
print(mhz)
snr = udaje[3].split('&nbsp;')[1]
print(snr)
drift = udaje[4].split('&nbsp;')[1]
print(drift)
grid = udaje[5].split('&nbsp;')[1]
print(grid)
pwr = udaje[6].split('&nbsp;')[1]
print(pwr)
reporter = udaje[7].split('&nbsp;')[1]
print(reporter)
rgrid = udaje[8].split('&nbsp;')[1]
print(rgrid)
km = udaje[9].split('&nbsp;')[1]
print(km)
az = udaje[10].split('&nbsp;')[1]
print(az)
mhz += ' MHz'
km += ' km'
lat = maidenhead.toLoc(grid)[0]
lng = maidenhead.toLoc(grid)[1]
if '0C' in call:
call = '(' + call + ')'
grid = '(' + grid + ')'
km = ''
az = ''
temp = str(12 - 2*(ord(call[4]) - 64)) + ' °C'
if temp == '10 °C':
temp = '≥10 °C'
if grid[1] == 'J':
voltage1 = '0'
else:
voltage1 = str(ord(grid[1]) - 64)
if grid[2] == 'J':
voltage2 = '0'
else:
voltage2 = str(ord(grid[2]) - 64)
voltage = voltage1 + ',' + voltage2 + ' V'
alt = grid[3] + grid[4] + '00 m'
else:
temp = ''
voltage = ''
alt = ''
datum_timestamp = int(timestamp[:4] + timestamp[5:7] + timestamp[8:10])
if datum_timestamp >= DATUM_OD and lng not in [-120.0, -180.0] and '14' in mhz:
zaznamy.append({'timestamp': timestamp, 'call': call, 'mhz': mhz, 'snr': snr, 'drift': drift, 'grid': grid, 'pwr': pwr, 'reporter': reporter, 'rgrid': rgrid, 'km': km, 'az': az, 'lat': lat, 'lng': lng, 'temp': temp, 'voltage': voltage, 'alt': alt})
if lng not in [-120.0, -180.0] and '0C' not in call:
markers += 'var marker_'
markers += str(num)
markers += ' = new google.maps.Marker({position: {lat: '
markers += str(lat)
markers += ', lng: '
markers += str(lng)
markers += '}, map: map, title: "'
markers += timestamp
markers += '"});\n'
polyline += '{lat: '
polyline += str(lat)
polyline += ', lng: '
polyline += str(lng)
polyline += '},\n'
infowindows += 'var infowindow_'
infowindows += str(num)
infowindows += ' = new google.maps.InfoWindow({content: " "});\n'
listeners += 'marker_'
listeners += str(num)
listeners += ".addListener('click', function() {infowindow_"
listeners += str(num)
listeners += '.open(map, marker_'
listeners += str(num)
listeners += ');});\n'
if min_lat and lat < min_lat:
min_lat = lat
else:
min_lat = lat
if max_lat and lat > max_lat:
max_lat = lat
else:
max_lat = lat
if min_lng and lng < min_lng:
min_lng = lng
else:
min_lng = lng
if max_lng and lng > max_lng:
max_lng = lng
else:
max_lng = lng
num += 1
print('záznamy:')
pprint(zaznamy)
print('min_lng:', min_lng)
#avg_lat = (min_lat + max_lat) / 2
#avg_lng = (min_lng + max_lng) / 2
min_lat = 50.8402
max_lat = 50.8402
min_lng = 13.129
max_lng = 13.129
avg_lat = 50.8402
avg_lng = 13.129
js = """function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: """
js += str(avg_lat)
js += ', lng: '
js += str(avg_lng)
js += """},
zoom: 4
});"""
zaznamy_sorted = sorted(zaznamy, key=lambda k: k['timestamp'], reverse=True)
('seřazené záznamy:')
pprint(zaznamy_sorted)
html_tab = '<table>\n<tr><th>čas (UTC)</th><th>značka</th><th>kmitočet</th><th>SNR</th><th>lokátor</th><th>přijímač</th><th>lokátor přijímače</th><th>vzdálenost od přijímače</th><th>azimut</th><th>teplota</th><th>napětí na solárních článcích</th><th>nadmořská výška</th></tr>'
for zaznam in zaznamy_sorted:
html_tab += ('<tr><td>' + zaznam['timestamp'] + '</td><td>' + zaznam['call'] + '</td><td>' + zaznam['mhz'] + '</td><td>' + zaznam['snr'] + '</td><td>' + zaznam['grid'] + '</td><td>' + zaznam['reporter'] + '</td><td>' + zaznam['rgrid'] + '</td><td>' + zaznam['km'] + '</td><td>' + zaznam['az'] + '</td><td>' + zaznam['temp'] + '</td><td>' + zaznam['voltage'] + '</td><td>' + zaznam['alt'] + '</td></tr>\n')
html_tab += '</table>\n'
js += markers
polyline += '];\n'
js += polyline
js += """var flightPath = new google.maps.Polyline({
path: polyline,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);"""
js += infowindows
js += listeners
js += '}'
with open('wspr.js', 'w') as js_file:
js_file.write(js)
with open('index.html', 'w') as html_file:
html_file.write("""<!DOCTYPE html>
<html>
<head>
<title>RAJ-x monitor</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" href="wspr.css" />
</head>
<body>
<div class="text">
<h1>Let RAJ-7</h1>
<p>Start 02.03.2020, 12:34 UTC (Hvězdárna Brno)</p>
</div>
<div id="map"><script type="text/javascript" src="wspr.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDKB3gXdknWtITvX8EF-lD7yp4yxvW0u0E&callback=initMap"
async defer></script></div><h2>Dostupné záznamy</h2>"""
+ html_tab + """
<p>Data jsou převzata z <a href="http://wsprnet.org">WSPRnet.org</a>.</p>
<p>Stránku vytvořil Honza OK1HZP.</p>
</body>
</html>""")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment