This repository was archived by the owner on Aug 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActiveCallsignMap.py
More file actions
executable file
·68 lines (54 loc) · 1.67 KB
/
ActiveCallsignMap.py
File metadata and controls
executable file
·68 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
"""plots users who submitted logs
./ActiveCallsignMap.py data/2016cqww_ssb.asc
"""
import pycountry
import webbrowser
import folium
from pathlib import Path
import pandas as pd
from hamsci_datasci.findhams import readlogs,locatehams,country_rename
if __name__ == '__main__':
from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument('fn',help='.asc file to analyze')
p = p.parse_args()
fn = Path(p.fn).expanduser()
cs = readlogs(fn)
loc = locatehams(cs)
cdata = pd.DataFrame(index=cs,data=loc)
cdata['country'] = country_rename(cdata['country'])
# %% count entries
chist = cdata['country'].value_counts()
codes = []
for i in chist.index:
try:
codes.append(pycountry.countries.get(name=i).alpha_3)
except KeyError:
print(i,chist[i])
codes.append(i) #leave broken value
chist.index=codes
# %% chloropleth
# https://github.com/python-visualization/folium/tree/master/examples/data
# https://github.com/python-visualization/folium/blob/106d8292afbc8952fa224f2be65a8839688714c2/folium/folium.py
geo = 'data/world-countries.json'
m = folium.Map(location=[37, -102], zoom_start=5)
m.choropleth(
geo_data=geo,
name='choropleth',
data=chist,
columns=['country',],
key_on='feature.id',
fill_color='YlOrRd',
threshold_scale=[1, 50, 100, 200, 1000],
# fill_opacity=0.7,
# line_opacity=0.2,
legend_name=fn.name,
)
# %% generate map output
folium.LayerControl().add_to(m)
ofn = fn.with_suffix('.html')
print('writing',ofn)
m.save(str(ofn))
webbrowser.open(str(ofn))
# chist.hist(bins=20)