mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-06-17 16:45:56 +02:00
Update solarconditions.py
This commit is contained in:
+19
-1
@@ -24,6 +24,24 @@ def hf_band_conditions():
|
||||
hf_cond = hf_cond[:-1] # remove the last newline
|
||||
return hf_cond
|
||||
|
||||
def solar_conditions():
|
||||
solar_cond = ""
|
||||
# get the solar conditions from the xml at "https://www.hamqsl.com/solarxml.php"
|
||||
solar_cond = requests.get("https://www.hamqsl.com/solarxml.php", timeout=5)
|
||||
if(solar_cond.ok):
|
||||
solar_xml = xml.dom.minidom.parseString(solar_cond.text)
|
||||
for i in solar_xml.getElementsByTagName("solardata"):
|
||||
solar_a_index = i.getElementsByTagName("aindex")[0].childNodes[0].data
|
||||
solar_k_index = i.getElementsByTagName("kindex")[0].childNodes[0].data
|
||||
solar_xray = i.getElementsByTagName("xray")[0].childNodes[0].data
|
||||
solar_flux = i.getElementsByTagName("solarflux")[0].childNodes[0].data
|
||||
sunspots = i.getElementsByTagName("sunspots")[0].childNodes[0].data
|
||||
signalnoise = i.getElementsByTagName("signalnoise")[0].childNodes[0].data
|
||||
solar_cond = "A-Index: " + solar_a_index + "\nK-Index: " + solar_k_index + "\nSunspots: " + sunspots + "\nX-Ray Flux: " + solar_xray + "\nSolar Flux: " + solar_flux + "\nSignal Noise: " + signalnoise
|
||||
else:
|
||||
solar_cond += "error fetching"
|
||||
return solar_cond
|
||||
|
||||
def drap_xray_conditions():
|
||||
drap_cond = ""
|
||||
drap_cond = requests.get("https://services.swpc.noaa.gov/text/drap_global_frequencies.txt", timeout=5)
|
||||
@@ -45,4 +63,4 @@ def get_sunrise_sunset():
|
||||
if today_ss < today_sr: # if sunset is before sunrise, then it's tomorrow
|
||||
today_ss = today_ss + timedelta(1)
|
||||
todaysun = [today_sr.astimezone(to_zone).strftime('%a %d %I:%M'), today_ss.astimezone(to_zone).strftime('%a %d %I:%M')]
|
||||
return todaysun
|
||||
return todaysun
|
||||
|
||||
Reference in New Issue
Block a user