pyipma 3.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyipma/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Python library for http://api.ipma.pt."""
2
+ __version__ = "3.0.10"
3
+
4
+ class IPMAException(Exception):
5
+ pass
pyipma/api.py ADDED
@@ -0,0 +1,73 @@
1
+ """API to IPMA."""
2
+ import ast
3
+ import asyncio
4
+ import logging
5
+ import json
6
+ import aiohttp
7
+
8
+ from . import IPMAException
9
+
10
+ LOGGER = logging.getLogger(__name__)
11
+ LOGGER.setLevel(logging.DEBUG)
12
+
13
+ DEFAULT_TIMEOUT = 10
14
+
15
+
16
+ class IPMA_API: # pylint: disable=invalid-name
17
+ """Interfaces to http://api.ipma.pt service."""
18
+
19
+ def __init__(self, websession, timeout=DEFAULT_TIMEOUT):
20
+ """Initializer API session."""
21
+ self.websession = websession
22
+ self.timeout = timeout
23
+
24
+ async def retrieve(self, url, **kwargs):
25
+ """Issue API requests."""
26
+ headers = {"Referer": "http://www.ipma.pt"}
27
+ headers.update(kwargs.pop("headers", {}) or {})
28
+
29
+ if self.timeout is not None and "timeout" not in kwargs:
30
+ if isinstance(self.timeout, aiohttp.ClientTimeout):
31
+ kwargs["timeout"] = self.timeout
32
+ else:
33
+ kwargs["timeout"] = aiohttp.ClientTimeout(total=self.timeout)
34
+
35
+ try:
36
+ async with self.websession.request(
37
+ "GET", url, headers=headers, **kwargs
38
+ ) as response:
39
+ try:
40
+ response.raise_for_status()
41
+ except aiohttp.ClientResponseError as err:
42
+ body = await response.text()
43
+ message = (
44
+ f"Could not retrieve information from API: "
45
+ f"{url} returned HTTP {err.status}"
46
+ )
47
+ if body:
48
+ message = f"{message}: {body[:200]}"
49
+ raise IPMAException(message) from err
50
+
51
+ if self._is_json_response(response):
52
+ return await response.json()
53
+ return await response.text()
54
+ except aiohttp.ClientError as err:
55
+ raise IPMAException(f"Could not retrieve information from API: {url}") from err
56
+ except asyncio.TimeoutError as err:
57
+ raise IPMAException(f"Timed out retrieving information from API: {url}") from err
58
+ except json.decoder.JSONDecodeError as err:
59
+ raise IPMAException(f"Could not decode JSON from API: {url}") from err
60
+
61
+ @classmethod
62
+ def _is_json_response(cls, response):
63
+ """Return True when the response has a JSON media type."""
64
+ content_type = response.content_type or ""
65
+ return content_type == "application/json" or content_type.endswith("+json")
66
+
67
+ @classmethod
68
+ def _to_number(cls, string):
69
+ """Convert string to int or float."""
70
+ num = ast.literal_eval(string)
71
+ if isinstance(num, (int, float)):
72
+ return num
73
+ return string
pyipma/auxiliar.py ADDED
@@ -0,0 +1,270 @@
1
+ import logging
2
+ from dataclasses import dataclass
3
+
4
+ from geopy import distance
5
+
6
+ from pyipma.api import IPMA_API
7
+ from pyipma import IPMAException
8
+
9
+ LOGGER = logging.getLogger(__name__) # pylint: disable=invalid-name
10
+
11
+ class AuxiliarParser:
12
+ def __init__(self, api: IPMA_API, type="location"):
13
+ _TYPES = {"location": self.get_location, "type": self.get_type}
14
+ self.data = None
15
+ self.api = api
16
+ self.get = _TYPES[type]
17
+
18
+ async def get_type(self, id):
19
+ if not self.data:
20
+ raw = await self.api.retrieve(url=self.endpoint)
21
+
22
+ self.data = sorted(self._data_to_obj_list(raw), key=lambda d: abs(d.id))
23
+
24
+ if id >= 0:
25
+ return self.data[id]
26
+ else:
27
+ return self.data[-1] # -99 is the last
28
+
29
+ async def get_location(self, lon, lat):
30
+ if not self.data:
31
+ raw = await self.api.retrieve(url=self.endpoint)
32
+
33
+ if raw is None:
34
+ raise IPMAException(f"Could not retrieve location for {lon}, {lat}")
35
+
36
+ self.data = self._data_to_obj_list(raw)
37
+
38
+ if (lon, lat) != (None, None):
39
+ self.data = sorted(
40
+ self.data,
41
+ key=lambda d: distance.distance((lon, lat), d.coordinates).km,
42
+ )
43
+
44
+ return self.data
45
+
46
+
47
+ @dataclass
48
+ class District:
49
+ globalIdLocal: int
50
+ local: str
51
+ idRegiao: int
52
+ idDistrito: int
53
+ idConcelho: int
54
+ idAreaAviso: str
55
+ coordinates: tuple[float, float]
56
+
57
+ def __str__(self):
58
+ return f"{self.local}({self.globalIdLocal})"
59
+
60
+
61
+ class Districts(AuxiliarParser):
62
+ def __init__(self, api: IPMA_API):
63
+ super().__init__(api)
64
+ self.endpoint = "https://api.ipma.pt/open-data/distrits-islands.json"
65
+
66
+ def _data_to_obj_list(self, raw):
67
+ return [
68
+ District(
69
+ d["globalIdLocal"],
70
+ d["local"],
71
+ d["idRegiao"],
72
+ d["idDistrito"],
73
+ d["idConcelho"],
74
+ d["idAreaAviso"],
75
+ (float(d["latitude"]), float(d["longitude"])),
76
+ )
77
+ for d in raw["data"]
78
+ ]
79
+
80
+
81
+ @dataclass
82
+ class Forecast_Location:
83
+ globalIdLocal: int
84
+ local: str
85
+ idRegiao: int
86
+ idDistrito: int
87
+ idConcelho: int
88
+ idAreaAviso: str
89
+ coordinates: tuple[float, float]
90
+
91
+ def __str__(self):
92
+ return f"{self.local}({self.globalIdLocal})"
93
+
94
+
95
+ class Forecast_Locations(AuxiliarParser):
96
+ def __init__(self, api: IPMA_API):
97
+ super().__init__(api)
98
+ self.endpoint = "http://api.ipma.pt/public-data/forecast/locations.json"
99
+
100
+ def _data_to_obj_list(self, raw):
101
+ return [
102
+ Forecast_Location(
103
+ int(d["globalIdLocal"]),
104
+ d["local"],
105
+ d["idRegiao"],
106
+ d["idDistrito"],
107
+ d["idConcelho"],
108
+ d["idAreaAviso"],
109
+ (float(d["latitude"]), float(d["longitude"])),
110
+ )
111
+ for d in raw
112
+ ]
113
+
114
+ async def find(self, globalIdLocal):
115
+ if self.data is None:
116
+ await self.get(None, None)
117
+ return [l for l in self.data if l.globalIdLocal == globalIdLocal][0]
118
+
119
+
120
+ @dataclass
121
+ class Sea_Location:
122
+ globalIdLocal: int
123
+ local: str
124
+ idRegiao: int
125
+ idAreaAviso: str
126
+ idLocal: int
127
+ coordinates: tuple[float, float]
128
+
129
+ def __str__(self):
130
+ return f"{self.local}({self.globalIdLocal})"
131
+
132
+
133
+ class Sea_Locations(AuxiliarParser):
134
+ def __init__(self, api: IPMA_API):
135
+ super().__init__(api)
136
+ self.endpoint = "https://api.ipma.pt/open-data/sea-locations.json"
137
+
138
+ def _data_to_obj_list(self, raw):
139
+ return [
140
+ Sea_Location(
141
+ d["globalIdLocal"],
142
+ d["local"],
143
+ d["idRegiao"],
144
+ d["idAreaAviso"],
145
+ d["idLocal"],
146
+ (float(d["latitude"]), float(d["longitude"])),
147
+ )
148
+ for d in raw
149
+ ]
150
+
151
+ async def find(self, globalIdLocal):
152
+ if self.data is None:
153
+ await self.get(None, None)
154
+ return [l for l in self.data if l.globalIdLocal == globalIdLocal][0]
155
+
156
+
157
+ @dataclass
158
+ class Station:
159
+ idEstacao: int
160
+ localEstacao: str
161
+ coordinates: tuple[float, float]
162
+
163
+ def __str__(self):
164
+ return f"{self.localEstacao}({self.idEstacao})"
165
+
166
+
167
+ class Stations(AuxiliarParser):
168
+ def __init__(self, api: IPMA_API):
169
+ super().__init__(api)
170
+ self.endpoint = "https://api.ipma.pt/open-data/observation/meteorology/stations/stations.json"
171
+
172
+ def _data_to_obj_list(self, raw):
173
+ return [
174
+ Station(
175
+ s["properties"]["idEstacao"],
176
+ s["properties"]["localEstacao"],
177
+ (s["geometry"]["coordinates"][1], s["geometry"]["coordinates"][0]),
178
+ )
179
+ for s in raw
180
+ ]
181
+
182
+
183
+ @dataclass
184
+ class Weather_Type:
185
+ id: int
186
+ en: str
187
+ pt: str
188
+
189
+ def desc(self, lang="pt"):
190
+ if lang == "pt":
191
+ return self.pt
192
+ return self.en
193
+
194
+ def __str__(self):
195
+ return self.desc()
196
+
197
+
198
+ class Weather_Types(AuxiliarParser):
199
+ def __init__(self, api: IPMA_API):
200
+ super().__init__(api, "type")
201
+ self.endpoint = "https://api.ipma.pt/open-data/weather-type-classe.json"
202
+ self.order = lambda d: abs(d.id)
203
+
204
+ def _data_to_obj_list(self, raw):
205
+ return [
206
+ Weather_Type(
207
+ id=w["idWeatherType"],
208
+ en=w["descWeatherTypeEN"],
209
+ pt=w["descWeatherTypePT"],
210
+ )
211
+ for w in raw["data"]
212
+ ]
213
+
214
+
215
+ @dataclass
216
+ class Wind_Speed_Daily_Type:
217
+ id: int
218
+ en: str
219
+ pt: str
220
+
221
+ def desc(self, lang="pt"):
222
+ if lang == "pt":
223
+ return self.pt
224
+ return self.en
225
+
226
+
227
+ class Wind_Speed_Daily_Types(AuxiliarParser):
228
+ def __init__(self, api: IPMA_API):
229
+ super().__init__(api, "type")
230
+ self.endpoint = "https://api.ipma.pt/open-data/wind-speed-daily-classe.json"
231
+ self.order = lambda d: abs(d.id)
232
+
233
+ def _data_to_obj_list(self, raw):
234
+ return [
235
+ Weather_Type(
236
+ id=int(w["classWindSpeed"]),
237
+ en=w["descClassWindSpeedDailyEN"],
238
+ pt=w["descClassWindSpeedDailyPT"],
239
+ )
240
+ for w in raw["data"]
241
+ ]
242
+
243
+
244
+ @dataclass
245
+ class Precipitation_Class:
246
+ id: int
247
+ en: str
248
+ pt: str
249
+
250
+ def desc(self, lang="pt"):
251
+ if lang == "pt":
252
+ return self.pt
253
+ return self.en
254
+
255
+
256
+ class Precipitation_Classes(AuxiliarParser):
257
+ def __init__(self, api: IPMA_API):
258
+ super().__init__(api, "type")
259
+ self.endpoint = "https://api.ipma.pt/open-data/precipitation-classe.json"
260
+ self.order = lambda d: abs(d.id)
261
+
262
+ def _data_to_obj_list(self, raw):
263
+ return [
264
+ Weather_Type(
265
+ id=int(w["classPrecInt"]),
266
+ en=w["descClassPrecIntEN"],
267
+ pt=w["descClassPrecIntPT"],
268
+ )
269
+ for w in raw["data"]
270
+ ]
pyipma/dico_codes.py ADDED
@@ -0,0 +1,282 @@
1
+ """DICO Codes."""
2
+
3
+ DICO = {
4
+ "0101": ("Águeda", "AVEIRO"),
5
+ "0102": ("Albergaria-a-Velha", "AVEIRO"),
6
+ "0103": ("Anadia", "AVEIRO"),
7
+ "0104": ("Arouca", "AVEIRO"),
8
+ "0105": ("Aveiro", "AVEIRO"),
9
+ "0106": ("Castelo de Paiva", "AVEIRO"),
10
+ "0107": ("Espinho", "AVEIRO"),
11
+ "0108": ("Estarreja", "AVEIRO"),
12
+ "0109": ("Santa Maria da Feira", "AVEIRO"),
13
+ "0110": ("Ílhavo", "AVEIRO"),
14
+ "0111": ("Mealhada", "AVEIRO"),
15
+ "0112": ("Murtosa", "AVEIRO"),
16
+ "0113": ("Oliveira de Azeméis", "AVEIRO"),
17
+ "0114": ("Oliveira do Bairro", "AVEIRO"),
18
+ "0115": ("Ovar", "AVEIRO"),
19
+ "0116": ("São João da Madeira", "AVEIRO"),
20
+ "0117": ("Sever do Vouga", "AVEIRO"),
21
+ "0118": ("Vagos", "AVEIRO"),
22
+ "0119": ("Vale de Cambra", "AVEIRO"),
23
+ "0201": ("Aljustrel", "BEJA"),
24
+ "0202": ("Almodôvar", "BEJA"),
25
+ "0203": ("Alvito", "BEJA"),
26
+ "0204": ("Barrancos", "BEJA"),
27
+ "0205": ("Beja", "BEJA"),
28
+ "0206": ("Castro Verde", "BEJA"),
29
+ "0207": ("Cuba", "BEJA"),
30
+ "0208": ("Ferreira do Alentejo", "BEJA"),
31
+ "0209": ("Mértola", "BEJA"),
32
+ "0210": ("Moura", "BEJA"),
33
+ "0211": ("Odemira", "BEJA"),
34
+ "0212": ("Ourique", "BEJA"),
35
+ "0213": ("Serpa", "BEJA"),
36
+ "0214": ("Vidigueira", "BEJA"),
37
+ "0301": ("Amares", "BRAGA"),
38
+ "0302": ("Barcelos", "BRAGA"),
39
+ "0303": ("Braga", "BRAGA"),
40
+ "0304": ("Cabeceiras de Basto", "BRAGA"),
41
+ "0305": ("Celorico de Basto", "BRAGA"),
42
+ "0306": ("Esposende", "BRAGA"),
43
+ "0307": ("Fafe", "BRAGA"),
44
+ "0308": ("Guimarães", "BRAGA"),
45
+ "0309": ("Póvoa de Lanhoso", "BRAGA"),
46
+ "0310": ("Terras de Bouro", "BRAGA"),
47
+ "0311": ("Vieira do Minho", "BRAGA"),
48
+ "0312": ("Vila Nova de Famalicão", "BRAGA"),
49
+ "0313": ("Vila Verde", "BRAGA"),
50
+ "0314": ("Vizela", "BRAGA"),
51
+ "0401": ("Alfândega da Fé", "BRAGANÇA"),
52
+ "0402": ("Bragança", "BRAGANÇA"),
53
+ "0403": ("Carrazeda de Ansiães", "BRAGANÇA"),
54
+ "0404": ("Freixo de Espada à Cinta", "BRAGANÇA"),
55
+ "0405": ("Macedo de Cavaleiros", "BRAGANÇA"),
56
+ "0406": ("Miranda do Douro", "BRAGANÇA"),
57
+ "0407": ("Mirandela", "BRAGANÇA"),
58
+ "0408": ("Mogadouro", "BRAGANÇA"),
59
+ "0409": ("Torre de Moncorvo", "BRAGANÇA"),
60
+ "0410": ("Vila Flor", "BRAGANÇA"),
61
+ "0411": ("Vimioso", "BRAGANÇA"),
62
+ "0412": ("Vinhais", "BRAGANÇA"),
63
+ "0501": ("Belmonte", "CASTELO BRANCO"),
64
+ "0502": ("Castelo Branco", "CASTELO BRANCO"),
65
+ "0503": ("Covilhã", "CASTELO BRANCO"),
66
+ "0504": ("Fundão", "CASTELO BRANCO"),
67
+ "0505": ("Idanha-a-Nova", "CASTELO BRANCO"),
68
+ "0506": ("Oleiros", "CASTELO BRANCO"),
69
+ "0507": ("Penamacor", "CASTELO BRANCO"),
70
+ "0508": ("Proença-a-Nova", "CASTELO BRANCO"),
71
+ "0509": ("Sertã", "CASTELO BRANCO"),
72
+ "0510": ("Vila de Rei", "CASTELO BRANCO"),
73
+ "0511": ("Vila Velha de Ródão", "CASTELO BRANCO"),
74
+ "0601": ("Arganil", "COIMBRA"),
75
+ "0602": ("Cantanhede", "COIMBRA"),
76
+ "0603": ("Coimbra", "COIMBRA"),
77
+ "0604": ("Condeixa-a-Nova", "COIMBRA"),
78
+ "0605": ("Figueira da Foz", "COIMBRA"),
79
+ "0606": ("Góis", "COIMBRA"),
80
+ "0607": ("Lousã", "COIMBRA"),
81
+ "0608": ("Mira", "COIMBRA"),
82
+ "0609": ("Miranda do Corvo", "COIMBRA"),
83
+ "0610": ("Montemor-o-Velho", "COIMBRA"),
84
+ "0611": ("Oliveira do Hospital", "COIMBRA"),
85
+ "0612": ("Pampilhosa da Serra", "COIMBRA"),
86
+ "0613": ("Penacova", "COIMBRA"),
87
+ "0614": ("Penela", "COIMBRA"),
88
+ "0615": ("Soure", "COIMBRA"),
89
+ "0616": ("Tábua", "COIMBRA"),
90
+ "0617": ("Vila Nova de Poiares", "COIMBRA"),
91
+ "0701": ("Alandroal", "ÉVORA"),
92
+ "0702": ("Arraiolos", "ÉVORA"),
93
+ "0703": ("Borba", "ÉVORA"),
94
+ "0704": ("Estremoz", "ÉVORA"),
95
+ "0705": ("Évora", "ÉVORA"),
96
+ "0706": ("Montemor-o-Novo", "ÉVORA"),
97
+ "0707": ("Mora", "ÉVORA"),
98
+ "0708": ("Mourão", "ÉVORA"),
99
+ "0709": ("Portel", "ÉVORA"),
100
+ "0710": ("Redondo", "ÉVORA"),
101
+ "0711": ("Reguengos de Monsaraz", "ÉVORA"),
102
+ "0712": ("Vendas Novas", "ÉVORA"),
103
+ "0713": ("Viana do Alentejo", "ÉVORA"),
104
+ "0714": ("Vila Viçosa", "ÉVORA"),
105
+ "0801": ("Albufeira", "FARO"),
106
+ "0802": ("Alcoutim", "FARO"),
107
+ "0803": ("Aljezur", "FARO"),
108
+ "0804": ("Castro Marim", "FARO"),
109
+ "0805": ("Faro", "FARO"),
110
+ "0806": ("Lagoa", "FARO"),
111
+ "0807": ("Lagos", "FARO"),
112
+ "0808": ("Loulé", "FARO"),
113
+ "0809": ("Monchique", "FARO"),
114
+ "0810": ("Olhão", "FARO"),
115
+ "0811": ("Portimão", "FARO"),
116
+ "0812": ("São Brás de Alportel", "FARO"),
117
+ "0813": ("Silves", "FARO"),
118
+ "0814": ("Tavira", "FARO"),
119
+ "0815": ("Vila do Bispo", "FARO"),
120
+ "0816": ("Vila Real de Santo António", "FARO"),
121
+ "0901": ("Aguiar da Beira", "GUARDA"),
122
+ "0902": ("Almeida", "GUARDA"),
123
+ "0903": ("Celorico da Beira", "GUARDA"),
124
+ "0904": ("Figueira de Castelo Rodrigo", "GUARDA"),
125
+ "0905": ("Fornos de Algodres", "GUARDA"),
126
+ "0906": ("Gouveia", "GUARDA"),
127
+ "0907": ("Guarda", "GUARDA"),
128
+ "0908": ("Manteigas", "GUARDA"),
129
+ "0909": ("Mêda", "GUARDA"),
130
+ "0910": ("Pinhel", "GUARDA"),
131
+ "0911": ("Sabugal", "GUARDA"),
132
+ "0912": ("Seia", "GUARDA"),
133
+ "0913": ("Trancoso", "GUARDA"),
134
+ "0914": ("Vila Nova de Foz Côa", "GUARDA"),
135
+ "1001": ("Alcobaça", "LEIRIA"),
136
+ "1002": ("Alvaiázere", "LEIRIA"),
137
+ "1003": ("Ansião", "LEIRIA"),
138
+ "1004": ("Batalha", "LEIRIA"),
139
+ "1005": ("Bombarral", "LEIRIA"),
140
+ "1006": ("Caldas da Rainha", "LEIRIA"),
141
+ "1007": ("Castanheira de Pêra", "LEIRIA"),
142
+ "1008": ("Figueiró dos Vinhos", "LEIRIA"),
143
+ "1009": ("Leiria", "LEIRIA"),
144
+ "1010": ("Marinha Grande", "LEIRIA"),
145
+ "1011": ("Nazaré", "LEIRIA"),
146
+ "1012": ("Óbidos", "LEIRIA"),
147
+ "1013": ("Pedrógão Grande", "LEIRIA"),
148
+ "1014": ("Peniche", "LEIRIA"),
149
+ "1015": ("Pombal", "LEIRIA"),
150
+ "1016": ("Porto de Mós", "LEIRIA"),
151
+ "1101": ("Alenquer", "LISBOA"),
152
+ "1102": ("Arruda dos Vinhos", "LISBOA"),
153
+ "1103": ("Azambuja", "LISBOA"),
154
+ "1104": ("Cadaval", "LISBOA"),
155
+ "1105": ("Cascais", "LISBOA"),
156
+ "1106": ("Lisboa", "LISBOA"),
157
+ "1107": ("Loures", "LISBOA"),
158
+ "1108": ("Lourinhã", "LISBOA"),
159
+ "1109": ("Mafra", "LISBOA"),
160
+ "1110": ("Oeiras", "LISBOA"),
161
+ "1111": ("Sintra", "LISBOA"),
162
+ "1112": ("Sobral de Monte Agraço", "LISBOA"),
163
+ "1113": ("Torres Vedras", "LISBOA"),
164
+ "1114": ("Vila Franca de Xira", "LISBOA"),
165
+ "1115": ("Amadora", "LISBOA"),
166
+ "1116": ("Odivelas", "LISBOA"),
167
+ "1201": ("Alter do Chão", "PORTALEGRE"),
168
+ "1202": ("Arronches", "PORTALEGRE"),
169
+ "1203": ("Avis", "PORTALEGRE"),
170
+ "1204": ("Campo Maior", "PORTALEGRE"),
171
+ "1205": ("Castelo de Vide", "PORTALEGRE"),
172
+ "1206": ("Crato", "PORTALEGRE"),
173
+ "1207": ("Elvas", "PORTALEGRE"),
174
+ "1208": ("Fronteira", "PORTALEGRE"),
175
+ "1209": ("Gavião", "PORTALEGRE"),
176
+ "1210": ("Marvão", "PORTALEGRE"),
177
+ "1211": ("Monforte", "PORTALEGRE"),
178
+ "1212": ("Nisa", "PORTALEGRE"),
179
+ "1213": ("Ponte de Sor", "PORTALEGRE"),
180
+ "1214": ("Portalegre", "PORTALEGRE"),
181
+ "1215": ("Sousel", "PORTALEGRE"),
182
+ "1301": ("Amarante", "PORTO"),
183
+ "1302": ("Baião", "PORTO"),
184
+ "1303": ("Felgueiras", "PORTO"),
185
+ "1304": ("Gondomar", "PORTO"),
186
+ "1305": ("Lousada", "PORTO"),
187
+ "1306": ("Maia", "PORTO"),
188
+ "1307": ("Marco de Canaveses", "PORTO"),
189
+ "1308": ("Matosinhos", "PORTO"),
190
+ "1309": ("Paços de Ferreira", "PORTO"),
191
+ "1310": ("Paredes", "PORTO"),
192
+ "1311": ("Penafiel", "PORTO"),
193
+ "1312": ("Porto", "PORTO"),
194
+ "1313": ("Póvoa de Varzim", "PORTO"),
195
+ "1314": ("Santo Tirso", "PORTO"),
196
+ "1315": ("Valongo", "PORTO"),
197
+ "1316": ("Vila do Conde", "PORTO"),
198
+ "1317": ("Vila Nova de Gaia", "PORTO"),
199
+ "1318": ("Trofa", "PORTO"),
200
+ "1401": ("Abrantes", "SANTARÉM"),
201
+ "1402": ("Alcanena", "SANTARÉM"),
202
+ "1403": ("Almeirim", "SANTARÉM"),
203
+ "1404": ("Alpiarça", "SANTARÉM"),
204
+ "1405": ("Benavente", "SANTARÉM"),
205
+ "1406": ("Cartaxo", "SANTARÉM"),
206
+ "1407": ("Chamusca", "SANTARÉM"),
207
+ "1408": ("Constância", "SANTARÉM"),
208
+ "1409": ("Coruche", "SANTARÉM"),
209
+ "1410": ("Entroncamento", "SANTARÉM"),
210
+ "1411": ("Ferreira do Zêzere", "SANTARÉM"),
211
+ "1412": ("Golegã", "SANTARÉM"),
212
+ "1413": ("Mação", "SANTARÉM"),
213
+ "1414": ("Rio Maior", "SANTARÉM"),
214
+ "1415": ("Salvaterra de Magos", "SANTARÉM"),
215
+ "1416": ("Santarém", "SANTARÉM"),
216
+ "1417": ("Sardoal", "SANTARÉM"),
217
+ "1418": ("Tomar", "SANTARÉM"),
218
+ "1419": ("Torres Novas", "SANTARÉM"),
219
+ "1420": ("Vila Nova da Barquinha", "SANTARÉM"),
220
+ "1421": ("Ourém", "SANTARÉM"),
221
+ "1501": ("Alcácer do Sal", "SETÚBAL"),
222
+ "1502": ("Alcochete", "SETÚBAL"),
223
+ "1503": ("Almada", "SETÚBAL"),
224
+ "1504": ("Barreiro", "SETÚBAL"),
225
+ "1505": ("Grândola", "SETÚBAL"),
226
+ "1506": ("Moita", "SETÚBAL"),
227
+ "1507": ("Montijo", "SETÚBAL"),
228
+ "1508": ("Palmela", "SETÚBAL"),
229
+ "1509": ("Santiago do Cacém", "SETÚBAL"),
230
+ "1510": ("Seixal", "SETÚBAL"),
231
+ "1511": ("Sesimbra", "SETÚBAL"),
232
+ "1512": ("Setúbal", "SETÚBAL"),
233
+ "1513": ("Sines", "SETÚBAL"),
234
+ "1601": ("Arcos de Valdevez", "VIANA DO CASTELO"),
235
+ "1602": ("Caminha", "VIANA DO CASTELO"),
236
+ "1603": ("Melgaço", "VIANA DO CASTELO"),
237
+ "1604": ("Monção", "VIANA DO CASTELO"),
238
+ "1605": ("Paredes de Coura", "VIANA DO CASTELO"),
239
+ "1606": ("Ponte da Barca", "VIANA DO CASTELO"),
240
+ "1607": ("Ponte de Lima", "VIANA DO CASTELO"),
241
+ "1608": ("Valença", "VIANA DO CASTELO"),
242
+ "1609": ("Viana do Castelo", "VIANA DO CASTELO"),
243
+ "1610": ("Vila Nova de Cerveira", "VIANA DO CASTELO"),
244
+ "1701": ("Alijó", "VILA REAL"),
245
+ "1702": ("Boticas", "VILA REAL"),
246
+ "1703": ("Chaves", "VILA REAL"),
247
+ "1704": ("Mesão Frio", "VILA REAL"),
248
+ "1705": ("Mondim de Basto", "VILA REAL"),
249
+ "1706": ("Montalegre", "VILA REAL"),
250
+ "1707": ("Murça", "VILA REAL"),
251
+ "1708": ("Peso da Régua", "VILA REAL"),
252
+ "1709": ("Ribeira de Pena", "VILA REAL"),
253
+ "1710": ("Sabrosa", "VILA REAL"),
254
+ "1711": ("Santa Marta de Penaguião", "VILA REAL"),
255
+ "1712": ("Valpaços", "VILA REAL"),
256
+ "1713": ("Vila Pouca de Aguiar", "VILA REAL"),
257
+ "1714": ("Vila Real", "VILA REAL"),
258
+ "1801": ("Armamar", "VISEU"),
259
+ "1802": ("Carregal do Sal", "VISEU"),
260
+ "1803": ("Castro Daire", "VISEU"),
261
+ "1804": ("Cinfães", "VISEU"),
262
+ "1805": ("Lamego", "VISEU"),
263
+ "1806": ("Mangualde", "VISEU"),
264
+ "1807": ("Moimenta da Beira", "VISEU"),
265
+ "1808": ("Mortágua", "VISEU"),
266
+ "1809": ("Nelas", "VISEU"),
267
+ "1810": ("Oliveira de Frades", "VISEU"),
268
+ "1811": ("Penalva do Castelo", "VISEU"),
269
+ "1812": ("Penedono", "VISEU"),
270
+ "1813": ("Resende", "VISEU"),
271
+ "1814": ("Santa Comba Dão", "VISEU"),
272
+ "1815": ("São João da Pesqueira", "VISEU"),
273
+ "1816": ("São Pedro do Sul", "VISEU"),
274
+ "1817": ("Sátão", "VISEU"),
275
+ "1818": ("Sernancelhe", "VISEU"),
276
+ "1819": ("Tabuaço", "VISEU"),
277
+ "1820": ("Tarouca", "VISEU"),
278
+ "1821": ("Tondela", "VISEU"),
279
+ "1822": ("Vila Nova de Paiva", "VISEU"),
280
+ "1823": ("Viseu", "VISEU"),
281
+ "1824": ("Vouzela", "VISEU"),
282
+ }