-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgw.py
75 lines (62 loc) · 1.88 KB
/
imgw.py
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
69
70
71
72
73
74
75
# (c) stonatm@gmail.com
# library to read synoptic data for
# polish cities from imgw.pl
class imgw:
import urequests
import json
data = {"message":"Acquire data first"}
def acquireData(station_id):
url = 'https://danepubliczne.imgw.pl/api/data/synop/id/' + str(station_id)
headers={'Content-Type':'text/html'}
response = imgw.urequests.get(url, headers=headers)
imgw.data = imgw.json.loads(response.text)
def getStationID():
if 'id_stacji' in imgw.data:
return (imgw.data['id_stacji'])
else:
return(imgw.data['message'])
def getStationName():
if 'stacja' in imgw.data:
return (imgw.data['stacja'])
else:
return(imgw.data['message'])
def getMeasurementDate():
if 'data_pomiaru' in imgw.data:
return (imgw.data['data_pomiaru'])
else:
return(imgw.data['message'])
def getMeasurementTime():
if 'godzina_pomiaru' in imgw.data:
return (imgw.data['godzina_pomiaru'])
else:
return(imgw.data['message'])
def getTemperature():
if 'temperatura' in imgw.data:
return (imgw.data['temperatura'])
else:
return(imgw.data['message'])
def getWindSpeed():
if 'predkosc_wiatru' in imgw.data:
return (imgw.data['predkosc_wiatru'])
else:
return(imgw.data['message'])
def getWindDirection():
if 'kierunek_wiatru' in imgw.data:
return (imgw.data['kierunek_wiatru'])
else:
return(imgw.data['message'])
def getRelativeHumidity():
if 'wilgotnosc_wzgledna' in imgw.data:
return (imgw.data['wilgotnosc_wzgledna'])
else:
return(imgw.data['message'])
def getTotalRainfall():
if 'suma_opadu' in imgw.data:
return (imgw.data['suma_opadu'])
else:
return(imgw.data['message'])
def getPressure():
if 'cisnienie' in imgw.data:
return (imgw.data['cisnienie'])
else:
return(imgw.data['message'])