-
Notifications
You must be signed in to change notification settings - Fork 1
/
wx_gen_ids.py
216 lines (186 loc) · 5.64 KB
/
wx_gen_ids.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import metoffer
import pprint
key = "" # Met Office API key
M = metoffer.MetOffer(key)
def ids_of(sitelist):
try:
sites = [
(s["name"], s["id"]) for s in sitelist["Locations"]["Location"]
]
except KeyError:
sites = [
(s["@name"], s["@id"]) for s in sitelist["Locations"]["Location"]
]
return dict(sites)
def print_cities(forecast_sites):
cities = [
"Inverness",
"Pitlochry",
"Edinburgh",
"Newcastle Upon Tyne",
"Manchester",
"Belfast",
"Birmingham",
"Cardiff",
"Plymouth",
"Cambridge",
"London",
]
city_ids = dict()
for c in cities:
city_ids[c.lower().split()[0]] = forecast_sites[c]
print("city_ids = ", end="")
pprint.pprint(city_ids)
print()
def print_region_locs(forecast_sites):
region_locs = [
("Mallaig", "highlands"),
("Aberdeen", "grampian"),
("Dundee", "tayside"),
("Livingston", "central"),
("Cookstown", "nireland"),
("Durham", "northeast"),
("Preston", "northwest"),
("Selby", "yorks"),
("Machynlleth", "wales"),
("Stoke", "midlands"),
("Stroud", "west"),
("Thetford", "east"),
("Winchester", "south"),
("Royal Tunbridge Wells", "southeast"),
("Launceston", "southwest"),
]
region_ids = dict()
for c, r in region_locs:
region_ids[r] = forecast_sites[c]
print("region_ids = ", end="")
pprint.pprint(region_ids)
print()
def print_regions():
region_ids = ids_of(
M.text_forecast(metoffer.REGIONAL_FORECAST, metoffer.SITELIST)
)
region_txt = [
("he", "highlands"),
("gr", "grampian"),
("ta", "tayside"),
("st", "central"),
("dg", "borders"),
("ni", "nireland"),
("ne", "northeast"),
("nw", "northwest"),
("yh", "yorks"),
("wl", "wales"),
("wm", "wmidlands"),
("em", "emidlands"),
("wm", "west"),
("ee", "east"),
("sw", "south"),
("se", "southeast"),
("sw", "southwest"),
("uk", "uk"),
]
regions = dict()
for abbr, region in region_txt:
regions[abbr] = region_ids[abbr]
print("regions = ", end="")
pprint.pprint(regions)
print()
def print_obs():
observation_sites = ids_of(M.loc_observations(metoffer.SITELIST))
obs_locs = [
("Aberdeen", "Aberdeen Airport"),
("Aberdaron", "Aberdaron"),
("Belfast", "Belfast International Airport"),
("Birmingham", "Coleshill"),
("Bristol", "Lyneham"),
("Cardiff", "St-Athan"),
("Eastbourne", "Herstmonceux West End"),
("Edinburgh", "Edinburgh/Gogarbank"),
("Glasgow", "Glasgow/Bishopton"),
("Inverness", "Aviemore"),
("Ipswich", "Wattisham"),
("Isle of Man", "Ronaldsway"),
("Leeds", "Bingley Samos"),
("Lerwick", "Lerwick (S. Screen)"),
("Lincoln", "Waddington"),
("London", "Northolt"),
("Manchester", "Rostherne No 2"),
("Margate", "Manston"),
("Norwich", "Weybourne"),
("Newcastle", "Albemarle"),
("Newquay", "Camborne"),
("Oxford", "Benson"),
("Peterborough", "Wittering"),
("Plymouth", "Mount Batten"),
("St Andrews", "Leuchars"),
("St Helier", "Jersey"),
("Salisbury", "Boscombe Down"),
("Shrewsbury", "Shawbury"),
("Southampton", "Middle Wallop"),
("York", "Linton On Ouse"),
]
observation_ids = dict()
for name, loc in obs_locs:
observation_ids[name] = observation_sites[loc]
print("observation_ids = ", end="")
pprint.pprint(observation_ids)
print()
def print_fivedays(forecast_sites):
fivedays = [
("Aberdeen", "Aberdeen"),
("Aberystwyth", "Aberystwyth"),
("Llangefni", "Anglesey"),
("Ayr", "Ayr"),
("Belfast", "Belfast"),
("Birmingham", "Birmingham"),
("Bristol", "Bristol"),
("Cardiff", "Cardiff"),
("Carlisle", "Carlisle"),
("Douglas (Isle Of Man)", "Douglas, I of Man"),
("Dover", "Dover"),
("Edinburgh", "Edinburgh"),
("Exeter", "Exeter"),
("Glasgow", "Glasgow"),
("Hull", "Hull"),
("Inverness", "Inverness"),
("Leeds", "Leeds"),
("Lerwick", "Lerwick"),
("Lincoln", "Lincoln"),
("Liverpool", "Liverpool"),
("London", "London"),
("Londonderry (Derry)", "Londonderry"),
("Manchester", "Manchester"),
("Newcastle Upon Tyne", "Newcastle"),
("Norwich", "Norwich"),
("Nottingham", "Nottingham"),
("Oban", "Oban"),
("Penzance", "Penzance"),
("Peterborough", "Peterborough"),
("Plymouth", "Plymouth"),
("St Helier", "St Helier"),
("St Peter Port", "St Peter Port"),
("Salisbury", "Salisbury"),
("Scarborough", "Scarborough"),
("Sheffield", "Sheffield"),
("Shrewsbury", "Shrewsbury"),
("Southampton", "Southampton"),
("Stranraer", "Stranraer"),
("Worcester", "Worcester"),
("York", "York"),
]
fiveday_ids = dict()
for real, screen in fivedays:
fiveday_ids[screen] = forecast_sites[real]
print("fiveday_ids = ", end="")
pprint.pprint(fiveday_ids)
print()
def main():
forecast_sites = ids_of(M.loc_forecast(metoffer.SITELIST, ""))
print_cities(forecast_sites)
print_region_locs(forecast_sites)
print_regions()
print_obs()
print_fivedays(forecast_sites)
if __name__ == "__main__":
main()