├── README.md ├── .gitignore ├── .htaccess ├── morse ├── morse.csv └── morse_lametric.py ├── callsign └── callsign_lametric.py ├── radio ├── radio_lametric.py └── indicatif.dat ├── LICENSE ├── exoplanet └── exoplanet_lametric.py ├── solar ├── data │ └── solar.xml ├── solar_lametric.py~ └── solar_lametric.py └── asteroid └── asteroid_lametric.py /README.md: -------------------------------------------------------------------------------- 1 | # lametric 2 | LaMetric Time Apps 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store 3 | __pycache__ 4 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | Options +ExecCGI 2 | AddHandler cgi-script .py 3 | -------------------------------------------------------------------------------- /morse/morse.csv: -------------------------------------------------------------------------------- 1 | A,.- 2 | B,-... 3 | C,-.-. 4 | D,-.. 5 | E,. 6 | F,..-. 7 | G,--. 8 | H,.... 9 | I,.. 10 | J,.--- 11 | K,-.- 12 | L,.-.. 13 | M,-- 14 | N,-. 15 | O,--- 16 | P,.--. 17 | Q,--.- 18 | R,.-. 19 | S,... 20 | T,- 21 | U,..- 22 | V,...- 23 | W,.-- 24 | X,-..- 25 | Y,-.-- 26 | Z,--.. 27 | 0,----- 28 | 1,.---- 29 | 2,..--- 30 | 3,...-- 31 | 4,....- 32 | 5,..... 33 | 6,-.... 34 | 7,--... 35 | 8,---.. 36 | 9,----. -------------------------------------------------------------------------------- /callsign/callsign_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import cgi 4 | import json 5 | 6 | # --- constants & variables 7 | 8 | data = { 9 | "frames": [] 10 | } 11 | 12 | callsign = "F4HWN" 13 | 14 | try: 15 | arg = cgi.FieldStorage() 16 | callsign = arg['Callsign'].value 17 | 18 | except: 19 | pass 20 | 21 | 22 | # -- public functions 23 | 24 | # ---- add name 25 | 26 | def add_name(text, icon): 27 | 28 | value = { 29 | "text": text, 30 | "icon": icon 31 | } 32 | 33 | data["frames"].append(value) 34 | 35 | 36 | # -- main loop 37 | 38 | def main(): 39 | 40 | add_name(callsign, "46933") 41 | add_name("ON AIR", "46933") 42 | 43 | # post frame 44 | 45 | print 46 | print json.dumps(data, indent=4, separators=(",", ": ")) 47 | 48 | if __name__ == '__main__': 49 | main() 50 | -------------------------------------------------------------------------------- /radio/radio_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import random 4 | import json 5 | 6 | # --- constants & variables 7 | 8 | file = "indicatif.dat" 9 | 10 | data = { 11 | "frames": [] 12 | } 13 | 14 | 15 | # -- public functions 16 | 17 | # ---- add name 18 | 19 | def add_name(text, icon): 20 | 21 | value = { 22 | "text": text, 23 | "icon": icon 24 | } 25 | 26 | data["frames"].append(value) 27 | 28 | 29 | # -- main loop 30 | 31 | def main(): 32 | 33 | # analyse file 34 | 35 | line = random.choice(open(file).readlines()) 36 | line = line.strip() 37 | element = line.split(';') 38 | 39 | # format frame 40 | 41 | for i in xrange(0, len(element)): 42 | add_name(element[i], "a4297") 43 | 44 | # post frame 45 | 46 | print 47 | print json.dumps(data, indent=4, separators=(",", ": ")) 48 | 49 | if __name__ == '__main__': 50 | main() 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Armel FAUVEAU 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /morse/morse_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import random 5 | import json 6 | import csv 7 | 8 | # --- constants & variables 9 | 10 | file = "morse.csv" 11 | 12 | data = { 13 | "frames": [] 14 | } 15 | 16 | 17 | # -- public functions 18 | 19 | # ---- add name 20 | 21 | def add_name(text, icon): 22 | 23 | value = { 24 | "text": text, 25 | "icon": icon 26 | } 27 | 28 | data["frames"].append(value) 29 | 30 | 31 | # -- main loop 32 | 33 | def main(): 34 | # analyse file 35 | 36 | morse = {} 37 | reader = csv.reader(open(file, 'r')) 38 | for row in reader: 39 | letter, code = row 40 | morse[letter] = code 41 | 42 | letter = random.choice(morse.keys()) 43 | code = morse[letter] 44 | recode = code.replace('.', '·') 45 | 46 | spell = '' 47 | 48 | for char in code: 49 | if char == '-': 50 | spell += 'dash' 51 | else: 52 | spell += 'dot' 53 | spell += ' ' 54 | 55 | # format frame 56 | 57 | add_name(str(letter), "a11188") 58 | add_name(str(recode), "a11188") 59 | add_name(str(spell), "a11188") 60 | 61 | # post frame 62 | 63 | print 64 | print json.dumps(data, indent=4, separators=(",", ": ")) 65 | 66 | if __name__ == '__main__': 67 | main() 68 | -------------------------------------------------------------------------------- /exoplanet/exoplanet_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | import datetime 5 | import json 6 | import csv 7 | import os 8 | 9 | # --- constants & variables 10 | 11 | http = "https://raw.githubusercontent.com/OpenExoplanetCatalogue/oec_tables/master/comma_separated/open_exoplanet_catalogue.txt" 12 | file = "data/exoplanet.csv" 13 | 14 | data = { 15 | "frames": [] 16 | } 17 | 18 | 19 | # -- public functions 20 | 21 | # ---- add name 22 | 23 | def add_name(text, icon): 24 | 25 | value = { 26 | "text": text, 27 | "icon": icon 28 | } 29 | 30 | data["frames"].append(value) 31 | 32 | 33 | # -- main loop 34 | 35 | def main(): 36 | # set date 37 | 38 | now = datetime.datetime.now() 39 | 40 | today = now.strftime("%Y-%m-%d") 41 | year = now.strftime("%Y") 42 | 43 | # check file 44 | 45 | if os.path.isfile(file): 46 | update = datetime.datetime.fromtimestamp(os.path.getmtime(file)).strftime("%Y-%m-%d") 47 | 48 | if not os.path.isfile(file) or update != today: 49 | r = requests.get(http) 50 | f = open(file, 'w') 51 | f.write(r.content) 52 | f.close 53 | 54 | # analyse file 55 | 56 | total = 0 57 | total_this_year = 0 58 | 59 | for row in open(file, "rb"): 60 | if not row.startswith("#"): 61 | element = row.split(',') 62 | if element[14] == year: 63 | total_this_year += 1 64 | total += 1 65 | 66 | # format frame 67 | 68 | add_name(str(total), "a4749") 69 | add_name("+" + str(total_this_year), "a4749") 70 | 71 | # post frame 72 | 73 | print 74 | print json.dumps(data, indent=4, separators=(",", ": ")) 75 | 76 | if __name__ == '__main__': 77 | main() 78 | -------------------------------------------------------------------------------- /solar/data/solar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | N0NBH 5 | 29 Sep 2021 0125 GMT 6 | 88 7 | 10 8 | 3 9 | No Report 10 | A9.8 11 | 67 12 | ch 13 | 112 14 | 1560 15 | 1 16 | 1.99 17 | 67.5 18 | 472.0 19 | -0.7 20 | 21 | Poor 22 | Fair 23 | Poor 24 | Poor 25 | Fair 26 | Fair 27 | Poor 28 | Poor 29 | 30 | 31 | Band Closed 32 | Band Closed 33 | Band Closed 34 | Band Closed 35 | Band Closed 36 | 37 | UNSETTLD 38 | S2-S3 39 | 6.45 40 | 2.89 41 | 18.63 42 | 43 | -------------------------------------------------------------------------------- /radio/indicatif.dat: -------------------------------------------------------------------------------- 1 | 3A;Monaco 2 | 4K;Azerbaidjan 3 | 4L;Georgie 4 | 4O;Montenegro 5 | 4U;ONU & UIT 6 | 5B;Chypre 7 | 9A;Croatie 8 | 9H;Malte 9 | C3;Andorre 10 | CT7;Portugal 11 | CT8;Acores 12 | CT9;Madere 13 | DL;Allemagne 14 | E7;Bosnie Herzegovine 15 | EA;Espagne 16 | EI;Irlande 17 | ER;Moldavie 18 | ES;Estonie 19 | EW;Bielorussie 20 | M;Royaume Uni 21 | MD;Ile de Man 22 | MI;Irlande du Nord 23 | MJ;Jersey 24 | MM;Ecosse 25 | MU;Guernesey 26 | MW;Pays de Galles 27 | HA;Hongrie 28 | HG;Hongrie 29 | HB9;Suisse 30 | HB0;Liechtenstein 31 | HV;Vatican 32 | I;Italie 33 | LA;Norvege 34 | LX;Luxembourg 35 | LY;Lituanie 36 | LZ;Bulgarie 37 | OE;Autriche 38 | OH;Finlande 39 | OK;Republique Tcheque 40 | OM;Slovaquie 41 | ON;Belgique 42 | OX;Groenland 43 | OY;Iles Feroe 44 | OZ;Danemark 45 | PA;Pays-Bas 46 | S5;Slovenie 47 | SM;Suede 48 | SP;Pologne 49 | SV;Grece 50 | T7;Saint-Marin 51 | TA;Turquie 52 | TF;Islande 53 | RA;Federation de Russie 54 | UA;Russie 55 | UT;Ukraine 56 | YU;Serbie 57 | YL;Lettonie 58 | YO;Roumanie 59 | Z3;Macedoine 60 | ZA;Albanie 61 | VK;Australie 62 | VE;Canada 63 | 4X;Israel 64 | OA;Perou 65 | ZL;Nouvelle Zelande 66 | ZS;Afrique du Sud 67 | PY;Bresil 68 | TU;Cote d'Ivoire 69 | JA;Japon 70 | 5Z;Kenya 71 | HS;Thailande 72 | F;France 73 | TK;Corse 74 | FR;Reunion 75 | FH;Mayotte 76 | FG;Guadeloupe 77 | FM;Martinique 78 | FY;Guyane 79 | FS;St Martin 80 | FJ;St Bartelemy 81 | FP;St Pierre & Miquelon 82 | FW;Wallis & Futuna 83 | FK;Nouvelle Caledonie 84 | FO;Polynesie Francaise 85 | FT;Terres Australes Antarctiques Francaise 86 | LF 2222m;0,1357;0,1378;C 87 | MF 630m;0,472;0,479;C 88 | MF 160m;1,810;1,850;A 89 | HF 80m;3,500;3,800;B 90 | HF 40m;7,000;7,200;A 91 | HF 30m;10,100;10,150;C 92 | HF 20m;14,000;14,350;A 93 | HF 17m;18,068;18,168;A 94 | HF 15m;21,000;21,450;A 95 | HF 12m;24,890;24,990;A 96 | HF 10m;28,000;29,700;A 97 | VHF 6m;50,000;52,000;C 98 | VHF 2m;144,000;146,000;A 99 | UHF 70cm;430,000;434,000;C 100 | UHF 70cm;434,000;440,000;B 101 | UHF 23cm;1.240;1.300;C 102 | UHF 13cm;2.300;2.450;C -------------------------------------------------------------------------------- /asteroid/asteroid_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/python 2 | 3 | import requests 4 | import datetime 5 | import time 6 | import json 7 | import os 8 | 9 | # --- constants & variables 10 | 11 | http = "http://www.neowsapp.com/rest/v1/feed" 12 | file = "asteroid.json" 13 | 14 | data = { 15 | "frames": [] 16 | } 17 | 18 | 19 | # -- public functions 20 | 21 | # ---- add name 22 | 23 | def add_name(text, icon): 24 | 25 | value = { 26 | "text": text, 27 | "icon": icon 28 | } 29 | 30 | data["frames"].append(value) 31 | 32 | 33 | # ---- add sparkline 34 | 35 | def add_sparkline(chart): 36 | 37 | value = { 38 | "chartData": 39 | chart 40 | } 41 | 42 | data["frames"].append(value) 43 | 44 | # -- main loop 45 | 46 | def main(): 47 | # set date 48 | 49 | now = datetime.datetime.now() 50 | 51 | today = now.strftime("%Y-%m-%d") 52 | delta = (now + datetime.timedelta(days=6)).strftime("%Y-%m-%d") 53 | year = now.strftime("%Y") 54 | 55 | # check file 56 | 57 | if os.path.isfile(file): 58 | modify = datetime.datetime.fromtimestamp(os.path.getmtime(file)).strftime("%Y-%m-%d") 59 | 60 | if not os.path.isfile(file) or modify != today: # if necessary update file 61 | try: 62 | r = requests.get(http+"?start_date="+today+"&end_date="+delta+"&detailed=false") 63 | f = open(file, 'w') 64 | f.write(r.content) 65 | f.close 66 | 67 | asteroid = json.loads(r.content) 68 | except: 69 | with open(file) as data_file: 70 | asteroid = json.load(data_file) 71 | else: 72 | with open(file) as data_file: 73 | asteroid = json.load(data_file) 74 | 75 | # analyse file 76 | 77 | count = 0 78 | message = [] 79 | 80 | for i in asteroid["near_earth_objects"][today]: 81 | name = i["name"] 82 | 83 | velocity = i["close_approach_data"][0]["relative_velocity"]["kilometers_per_hour"] 84 | velocity = str("%d" % float(velocity)) 85 | velocity = "{0:,}".format(int(velocity)).replace(',', ' ') 86 | 87 | distance = i["close_approach_data"][0]["miss_distance"]["kilometers"] 88 | distance = str("%d" % float(distance)) 89 | distance = "{0:,}".format(int(distance)).replace(',', ' ') 90 | 91 | magnitude = i["absolute_magnitude_h"] 92 | magnitude = str("%.2f" % float(magnitude)) 93 | 94 | count += 1 95 | 96 | message.append(("neo %s - %s - Velocity: %s kph - Distance: %s km - Magnitude: %s" % (count, name, velocity, distance, magnitude))) 97 | 98 | # format frames 99 | 100 | add_name("today " + str(count), "a4772") 101 | 102 | indice = 1 103 | for i in message: 104 | add_name(i, "a4772") 105 | indice += 1 106 | 107 | total = 0 108 | prevision = [] 109 | for i in xrange(0, 7): 110 | delta = (now + datetime.timedelta(days=i)).strftime("%Y-%m-%d") 111 | count = 0 112 | try: 113 | for j in asteroid["near_earth_objects"][delta]: 114 | count += 1 115 | except: 116 | pass 117 | 118 | total += count 119 | prevision.append(count) 120 | 121 | add_name("week " + str(total), "a4772") 122 | add_sparkline(prevision) 123 | 124 | # post frames 125 | 126 | print 127 | print json.dumps(data, indent=4, separators=(",", ": ")) 128 | 129 | if __name__ == '__main__': 130 | main() 131 | -------------------------------------------------------------------------------- /solar/solar_lametric.py~: -------------------------------------------------------------------------------- 1 | 2 | import requests 3 | import os 4 | import json 5 | from lxml import etree 6 | from datetime import datetime, timedelta 7 | from time import sleep 8 | 9 | # --- constants & variables 10 | 11 | http = "http://www.hamqsl.com/solarxml.php" 12 | file = "data/solar.xml" 13 | 14 | data = { 15 | "frames": [] 16 | } 17 | 18 | 19 | # -- public functions 20 | 21 | # ---- add name 22 | 23 | def add_name(text, icon): 24 | 25 | value = { 26 | "text": text, 27 | "icon": icon 28 | } 29 | 30 | data["frames"].append(value) 31 | 32 | 33 | # ---- add sparkline 34 | 35 | def add_sparkline(chart): 36 | 37 | value = { 38 | "chartData": 39 | chart 40 | } 41 | 42 | data["frames"].append(value) 43 | 44 | # -- main loop 45 | 46 | def main(): 47 | # set date 48 | 49 | now = datetime.now() - timedelta(minutes=60) 50 | today = format(now, "%Y-%m-%d %H:%M:%S") 51 | 52 | # check file 53 | 54 | if os.path.isfile(file): 55 | modify = datetime.fromtimestamp(os.path.getmtime(file)).strftime("%Y-%m-%d %H:%M:%S") 56 | 57 | # print today, modify 58 | 59 | if not os.path.isfile(file) or today > modify: # if necessary update file 60 | r = requests.get(http) 61 | f = open(file, 'w') 62 | f.write(r.content) 63 | f.close 64 | solar = etree.fromstring(r.content) 65 | else: 66 | solar = etree.parse(file) 67 | 68 | # update 69 | for value in solar.xpath("/solar/solardata/updated"): 70 | updated = value.text.strip() 71 | # sfi solar flux index: 72 | for value in solar.xpath("/solar/solardata/solarflux"): 73 | solarflux = value.text.strip() 74 | # sn sunspot number 75 | for value in solar.xpath("/solar/solardata/sunspots"): 76 | sunspots = value.text.strip() 77 | # a-index 78 | for value in solar.xpath("/solar/solardata/aindex"): 79 | aindex = value.text.strip() 80 | # k-index 81 | for value in solar.xpath("/solar/solardata/kindex"): 82 | kindex = value.text.strip() 83 | # k-index nt 84 | for value in solar.xpath("/solar/solardata/kindexnt"): 85 | kindexnt = value.text.strip() 86 | # x-ray 87 | for value in solar.xpath("/solar/solardata/xray"): 88 | xray = value.text.strip() 89 | # aurora 90 | for value in solar.xpath("/solar/solardata/aurora"): 91 | aurora = value.text.strip() 92 | # normalisation 93 | for value in solar.xpath("/solar/solardata/normalization"): 94 | normalization = value.text.strip() 95 | # protonflux 96 | for value in solar.xpath("/solar/solardata/protonflux"): 97 | protonflux = value.text.strip() 98 | # electronflux 99 | for value in solar.xpath("/solar/solardata/electonflux"): 100 | electonflux = value.text.strip() 101 | # geomagfield 102 | for value in solar.xpath("/solar/solardata/geomagfield"): 103 | geomagfield = value.text.strip() 104 | # signalnoise 105 | for value in solar.xpath("/solar/solardata/signalnoise"): 106 | signalnoise = value.text.strip() 107 | # solarwind 108 | for value in solar.xpath("/solar/solardata/solarwind"): 109 | solarwind = value.text.strip() 110 | 111 | # calculatedconditions 112 | condition = [] 113 | for value in solar.xpath("/solar/solardata/calculatedconditions/band"): 114 | condition.append(value.get("name") + " " + value.get("time") + " " + value.text.strip()) 115 | 116 | # calculatedvhfconditions 117 | vhfcondition = [] 118 | for value in solar.xpath("/solar/solardata/calculatedvhfconditions/phenomenon"): 119 | vhfcondition.append(value.get("name") + " " + value.get("location") + " " + value.text.strip()) 120 | 121 | # format frames 122 | 123 | add_name("Last update " + str(updated), "a2245") 124 | add_name("SFI " + str(solarflux), "a2245") 125 | add_name("SN " + str(sunspots), "a2245") 126 | add_name("A-Index " + str(aindex), "a2245") 127 | if kindexnt != "No Report": 128 | add_name("K-Index " + str(kindex) + " / " + str(kindexnt), "a2245") 129 | else: 130 | add_name("K-Index " + str(kindex), "a2245") 131 | 132 | add_name("X-Ray " + str(xray), "a2245") 133 | add_name("Ptn Flx " + str(protonflux), "a2245") 134 | add_name("Elc Flx " + str(electonflux), "a2245") 135 | add_name("Aurora " + str(aurora) + " / " + str(normalization), "a2245") 136 | add_name("Solar Wind " + str(solarwind), "a2245") 137 | 138 | for i in xrange(0, 4): 139 | add_name("HF Conditions " + condition[i] + " / " + condition[i+4], "a2245") 140 | 141 | for i in xrange(0, 4): 142 | add_name("VHF Conditions " + vhfcondition[i], "a2245") 143 | 144 | add_name("Geomag Field " + str(geomagfield), "a2245") 145 | add_name("Sig Noise Lvl " + str(signalnoise), "a2245") 146 | 147 | # post frames 148 | 149 | print 150 | print json.dumps(data, indent=4, separators=(",", ": ")) 151 | 152 | if __name__ == '__main__': 153 | main() 154 | 155 | -------------------------------------------------------------------------------- /solar/solar_lametric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | import os 5 | import json 6 | from lxml import etree 7 | from datetime import datetime, timedelta 8 | from time import sleep 9 | 10 | # --- constants & variables 11 | 12 | http = "http://www.hamqsl.com/solarxml.php" 13 | file = "data/solar.xml" 14 | 15 | data = { 16 | "frames": [] 17 | } 18 | 19 | 20 | # -- public functions 21 | 22 | # ---- add name 23 | 24 | def add_name(text, icon): 25 | 26 | value = { 27 | "text": text, 28 | "icon": icon 29 | } 30 | 31 | data["frames"].append(value) 32 | 33 | 34 | # ---- add sparkline 35 | 36 | def add_sparkline(chart): 37 | 38 | value = { 39 | "chartData": 40 | chart 41 | } 42 | 43 | data["frames"].append(value) 44 | 45 | # -- main loop 46 | 47 | def main(): 48 | # set date 49 | 50 | now = datetime.now() - timedelta(minutes=60) 51 | today = format(now, "%Y-%m-%d %H:%M:%S") 52 | 53 | # check file 54 | 55 | if os.path.isfile(file): 56 | modify = datetime.fromtimestamp(os.path.getmtime(file)).strftime("%Y-%m-%d %H:%M:%S") 57 | 58 | # print today, modify 59 | 60 | if not os.path.isfile(file) or today > modify: # if necessary update file 61 | r = requests.get(http) 62 | f = open(file, 'w') 63 | f.write(r.content) 64 | f.close 65 | solar = etree.fromstring(r.content) 66 | else: 67 | solar = etree.parse(file) 68 | 69 | # update 70 | for value in solar.xpath("/solar/solardata/updated"): 71 | updated = value.text.strip() 72 | # sfi solar flux index: 73 | for value in solar.xpath("/solar/solardata/solarflux"): 74 | solarflux = value.text.strip() 75 | # sn sunspot number 76 | for value in solar.xpath("/solar/solardata/sunspots"): 77 | sunspots = value.text.strip() 78 | # a-index 79 | for value in solar.xpath("/solar/solardata/aindex"): 80 | aindex = value.text.strip() 81 | # k-index 82 | for value in solar.xpath("/solar/solardata/kindex"): 83 | kindex = value.text.strip() 84 | # k-index nt 85 | for value in solar.xpath("/solar/solardata/kindexnt"): 86 | kindexnt = value.text.strip() 87 | # x-ray 88 | for value in solar.xpath("/solar/solardata/xray"): 89 | xray = value.text.strip() 90 | # aurora 91 | for value in solar.xpath("/solar/solardata/aurora"): 92 | aurora = value.text.strip() 93 | # normalisation 94 | for value in solar.xpath("/solar/solardata/normalization"): 95 | normalization = value.text.strip() 96 | # protonflux 97 | for value in solar.xpath("/solar/solardata/protonflux"): 98 | protonflux = value.text.strip() 99 | # electronflux 100 | for value in solar.xpath("/solar/solardata/electonflux"): 101 | electonflux = value.text.strip() 102 | # geomagfield 103 | for value in solar.xpath("/solar/solardata/geomagfield"): 104 | geomagfield = value.text.strip() 105 | # signalnoise 106 | for value in solar.xpath("/solar/solardata/signalnoise"): 107 | signalnoise = value.text.strip() 108 | # solarwind 109 | for value in solar.xpath("/solar/solardata/solarwind"): 110 | solarwind = value.text.strip() 111 | 112 | # calculatedconditions 113 | condition = [] 114 | for value in solar.xpath("/solar/solardata/calculatedconditions/band"): 115 | condition.append(value.get("name") + " " + value.get("time") + " " + value.text.strip()) 116 | 117 | # calculatedvhfconditions 118 | vhfcondition = [] 119 | for value in solar.xpath("/solar/solardata/calculatedvhfconditions/phenomenon"): 120 | vhfcondition.append(value.get("name") + " " + value.get("location") + " " + value.text.strip()) 121 | 122 | # format frames 123 | 124 | add_name("Last update " + str(updated), "a2245") 125 | add_name("SFI " + str(solarflux), "a2245") 126 | add_name("SN " + str(sunspots), "a2245") 127 | add_name("A-Index " + str(aindex), "a2245") 128 | if kindexnt != "No Report": 129 | add_name("K-Index " + str(kindex) + " / " + str(kindexnt), "a2245") 130 | else: 131 | add_name("K-Index " + str(kindex), "a2245") 132 | 133 | add_name("X-Ray " + str(xray), "a2245") 134 | add_name("Ptn Flx " + str(protonflux), "a2245") 135 | add_name("Elc Flx " + str(electonflux), "a2245") 136 | add_name("Aurora " + str(aurora) + " / " + str(normalization), "a2245") 137 | add_name("Solar Wind " + str(solarwind), "a2245") 138 | 139 | for i in xrange(0, 4): 140 | add_name("HF Conditions " + condition[i] + " / " + condition[i+4], "a2245") 141 | 142 | for i in xrange(0, 4): 143 | add_name("VHF Conditions " + vhfcondition[i], "a2245") 144 | 145 | add_name("Geomag Field " + str(geomagfield), "a2245") 146 | add_name("Sig Noise Lvl " + str(signalnoise), "a2245") 147 | 148 | # post frames 149 | 150 | print 151 | print json.dumps(data, indent=4, separators=(",", ": ")) 152 | 153 | if __name__ == '__main__': 154 | main() 155 | 156 | --------------------------------------------------------------------------------