Last active
October 12, 2023 17:43
-
-
Save boozeman/a20e1a1354e260fbaad429c49daf96cf to your computer and use it in GitHub Desktop.
Revisions
-
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ # Examples: # FMIWeather.py Tampere windspeed # FMIWeather.py Hämeenlinna rain1h # NOTE! If you live place without FMI weather station, like Turenki, Renko or Lammi, It takes the readings for the closest station. # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example # All data with 10 min resolution # ws_10min = Wind Speed 10min avg (in m/s) -
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,19 @@ # Correct the file sensor paths for configuration.yaml if needed # Usage: python3 FMIWeather.py station parameter # Examples: # FMIWeather.py Tampere windspeed # FMIWeather.py Hämeenlinna rain1h # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example # All data with 10 min resolution # ws_10min = Wind Speed 10min avg (in m/s) # wg_10min = Wind Gusts 1omin avg (in m/s) # wd_10min = Wind Direction 10min avg (in degrees) # t2m = Temperature (in Celcius) # rh = Humidity (in hPa) # td = Devpoint (in Celcius) # r_1h = Rain 1 hour (in millimeters) # ri_10min = Rain intensity (in millimeters) # snow_aws = Snow Depth (in centimeters) # p_sea = Atmospheric Pressure (Hpa) # vis = Visibility (in meters) # n_man = Cloud Coverage (1 to 8 meaning 1/8 to 8/8) @@ -27,7 +30,7 @@ def fetch_data(station, parameter): "windspeed": "ws_10min", "windgust": "wg_10min", "winddirection": "wd_10min", "temperature": "t2m", "humidity": "rh", "devpoint": "td", "rain1h": "r_1h", -
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ # p_sea = Atmospheric Pressure (Hpa) # vis = Visibility (in meters) # n_man = Cloud Coverage (1 to 8 meaning 1/8 to 8/8) # wawa = weather code -> Weathersymbol3 https://www.ilmatieteenlaitos.fi/latauspalvelun-pikaohje import requests import xml.etree.ElementTree as ET -
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ # Copy this on root of config directory or any place you want # Correct the file sensor paths for configuration.yaml if needed # Usage: python3 FMIWeather.py station parameter # Examples: # FMIWeather.py Tampere windspeed # FMIWeather.py Hämeenlinna rain1h # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example # All data with 10 min resolution # t2m = Temperature # rh = Humidity # td = Devpoint -
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Example: wind_data.py Tampere speed # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example # Orher possible measurements. All data with 10 min resolution # t2m = Temperature # rh = Humidity # td = Devpoint # r_1h = Rain 1 hour @@ -22,9 +22,9 @@ def fetch_data(station, parameter): parameter_mapping = { "windspeed": "ws_10min", "windgust": "wg_10min", "winddirection": "wd_10min", "temperature": "t2_m", "humidity": "rh", "devpoint": "td", @@ -43,7 +43,7 @@ def fetch_data(station, parameter): parameter_name = parameter_mapping[parameter] url = f"https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place={station}¶meters={parameter_name}&" response = requests.get(url) root = ET.fromstring(response.content) json_data = [] -
boozeman renamed this gist
Oct 12, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
boozeman revised this gist
Oct 12, 2023 . 1 changed file with 15 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,13 +22,23 @@ def fetch_data(station, parameter): parameter_mapping = { "windspeed": "ws", "windgust": "wg", "winddirection": "wd", "temperature": "t2_m", "humidity": "rh", "devpoint": "td", "rain1h": "r_1h", "rainintensity": "ri_10min", "snowdepth": "snow_aws", "pressure": "p_sea", "visibility": "vis", "cloudcoverage": "n_man", "weathercode": "wawa" } if parameter not in parameter_mapping: print("Invalid parameter. Please provide windspeed, windgust, winddirection, temperature, humidity, devpoint, rain1h, rainintensity, snowdepth, pressure, visibilty, cloudcoverage or weathercode.") sys.exit(1) parameter_name = parameter_mapping[parameter] @@ -45,7 +55,7 @@ def fetch_data(station, parameter): def main(): if len(sys.argv) != 3: print("Please provide two arguments: station and parameter (windspeed, windgust, winddirection, temperature, humidity, devpoint, rain1h, rainintensity, snowdepth, pressure, visibilty, cloudcoverage or weathercode).") sys.exit(1) station = sys.argv[1] -
boozeman revised this gist
Sep 29, 2023 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,17 @@ # Usage: python3 wind_data.py station speed|direction|gust # Example: wind_data.py Tampere speed # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example # Orher possible measurements. All data with 10 min resolution # t2_m = Temperature # rh = Humidity # td = Devpoint # r_1h = Rain 1 hour # ri_10min = Rain intensity # snow_aws = Snow Depth # p_sea = Atmospheric Pressure (Hpa) # vis = Visibility (in meters) # n_man = Cloud Coverage (1 to 8 meaning 1/8 to 8/8) # wawa = weather code import requests import xml.etree.ElementTree as ET -
boozeman revised this gist
Sep 23, 2023 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ # Copy this on root of config directory or any place you want # Correct the file sensor paths for configuration.yaml if needed # Usage: python3 wind_data.py station speed|direction|gust # Example: wind_data.py Tampere speed # You can find the stations here: https://www.tuulikartta.info/#lang=fi#latlon=61.04,24.29,9#parameter=ws_10min for example import requests import xml.etree.ElementTree as ET -
boozeman revised this gist
Sep 23, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # Copy this on root of confic directory or any place you want # Check configuration.yaml file sensor paths # usage python3 wind_data.py station speed|direction|gust # Example: wind_data.py Tampere speed import requests import xml.etree.ElementTree as ET -
boozeman revised this gist
Sep 23, 2023 . 1 changed file with 21 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,27 @@ # Copy this on root of confic directory or any place you want # Check configuration.yaml file sensor paths # usage python3 wind_data.py station speed|direction|gust # Example: wind_data.py Tampere dpeed import requests import xml.etree.ElementTree as ET import json import sys def fetch_data(station, parameter): parameter_mapping = { "speed": "ws", "gust": "wg", "direction": "wd" } if parameter not in parameter_mapping: print("Invalid parameter. Please provide speed, gust, or direction.") sys.exit(1) parameter_name = parameter_mapping[parameter] url = f"https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place={station}¶meters={parameter_name}_10min&" response = requests.get(url) root = ET.fromstring(response.content) json_data = [] @@ -22,20 +32,14 @@ def fetch_data(url): return json_data def main(): if len(sys.argv) != 3: print("Please provide two arguments: station and parameter (speed, gust, or direction).") sys.exit(1) station = sys.argv[1] parameter = sys.argv[2] data = fetch_data(station, parameter) json_data = json.dumps({"result": data}) print(json_data) -
boozeman revised this gist
Sep 21, 2023 . No changes.There are no files selected for viewing
-
boozeman revised this gist
Sep 21, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ # Copy this on root of confic directory or any place you want # Check configuration.yaml file sensor paths # Adjust url_direcction, speed and gusts paths to nearest FMI Weather Station import requests import xml.etree.ElementTree as ET -
boozeman revised this gist
Sep 21, 2023 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # Copy this on root of confic directory or any place you want # Check configuration.yaml file sensor paths import requests import xml.etree.ElementTree as ET import json -
boozeman revised this gist
Jul 11, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def main(): print("Invalid argument. Please provide direction, speed, or gusts.") sys.exit(1) json_data = json.dumps({"result": data}) print(json_data) if __name__ == "__main__": -
boozeman created this gist
Jul 10, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ import requests import xml.etree.ElementTree as ET import json import sys url_direction = "https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place=Hämeenlinna¶meters=wd_10min&" url_speed = "https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place=Hämeenlinna¶meters=ws_10min&" url_gusts = "https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place=Hämeenlinna¶meters=wg_10min&" def fetch_data(url): response = requests.get(url) root = ET.fromstring(response.content) json_data = [] for point in root.findall(".//{http://www.opengis.net/waterml/2.0}point"): time = point.find(".//{http://www.opengis.net/waterml/2.0}time").text value = point.find(".//{http://www.opengis.net/waterml/2.0}value").text json_data.append({"time": time, "value": value}) return json_data def main(): if len(sys.argv) < 2: print("Please provide an argument: direction, speed, or gusts") sys.exit(1) arg = sys.argv[1] if arg == "direction": data = fetch_data(url_direction) elif arg == "speed": data = fetch_data(url_speed) elif arg == "gusts": data = fetch_data(url_gusts) else: print("Invalid argument. Please provide direction, speed, or gusts.") sys.exit(1) json_data = json.dumps(data) print(json_data) if __name__ == "__main__": main()