Skip to content

Commit 06a205c

Browse files
authored
UNDRR based hazard code for Desinventar
* DesInventar: update the hazard codes and validation * DesInventar(Testcase): add test cases and update cassettes
1 parent 0fa4ec9 commit 06a205c

File tree

5 files changed

+518
-69
lines changed

5 files changed

+518
-69
lines changed

pystac_monty/sources/desinventar.py

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -136,59 +136,59 @@ def parse_row_data(
136136

137137
# TODO: complete this mapping
138138
hazard_mapping = {
139-
"ALLUVION": ["MH0051", "nat-hyd-mmw-mud"], # Mud flow
140-
"AVALANCHE": ["MH0050", "nat-hyd-mmw-ava"], # Avalanche
141-
"ACCIDENT": ["tec-mis-col-col"],
142-
"BIOLOGICAL": ["nat-bio-epi-dis"], # Epidemic
143-
"BOAT CAPSIZE": ["tec-tra-wat-wat", "TL0050"],
144-
"COASTAL EROSION": ["EN0020", "nat-geo-env-coa "], # Coastal erosion
145-
"COLD WAVE": ["MH0049", "nat-met-ext-col"], # Cold wave
146-
"CYCLONE": ["MH0057", "nat-met-tro-tro"], # Tropical cyclone
147-
"DROUGHT": ["MH0035", "nat-met-dro-dro"], # Drought
148-
"EARTHQUAKE": ["GH0001", "nat-geo-ear-grd"], # Earthquake
149-
"ELECTRIC STORM": ["MH0002", "nat-met-sto-sto"], # Thunderstorm
150-
"EPIDEMIC": ["nat-bio-epi-dis"], # Epidemic
139+
"ALLUVION": ["GH0303", "nat-hyd-mmw-mud", "MS"], # Mud flow
140+
"AVALANCHE": ["MH0801", "nat-geo-mmd-ava", "AV"], # Avalanche
141+
"ACCIDENT": ["TL0007", "tec-mis-col-col", "AC"], # Structural Failure
142+
"BIOLOGICAL": ["BI0101", "nat-bio-epi-dis", "OT"], # Epidemic
143+
"BOAT CAPSIZE": ["TL0050", "tec-tra-wat-wat", "AC"],
144+
"COASTAL EROSION": ["GH0405", "nat-geo-env-sed", "OT"], # Coastal erosion
145+
"COLD WAVE": ["MH0502", "nat-met-ext-col", "CW"], # Cold wave
146+
"CYCLONE": ["MH0309", "nat-met-sto-tro", "TC"], # Tropical cyclone
147+
"DROUGHT": ["MH0401", "nat-cli-dro-dro", "DR"], # Drought
148+
"EARTHQUAKE": ["GH0101", "nat-geo-ear-gro", "EQ"], # Earthquake
149+
"ELECTRIC STORM": ["MH0103", "nat-met-sto-sto", "ST"], # Thunderstorm
150+
"EPIDEMIC": ["BI0101", "nat-bio-epi-dis", "OT"], # Epidemic
151151
"EPIZOOTIC": ["BI0027", "nat-bio-ani-ani"], # Animal Diseases (Not Zoonoses)
152-
"EROSION": ["EN0019"], # Soil erosion
153-
"ERUPTION": ["VO", "nat-geo-vol-vol"], # Volcanic eruption
154-
"EXPLOSION": ["tec-mis-exp-exp"], # Explosion
152+
"EROSION": ["GH0403", "nat-geo-env-soi", "OT"], # Soil erosion
153+
"ERUPTION": ["GH0205", "nat-geo-vol-vol", "VO"], # Volcanic eruption
154+
"EXPLOSION": ["TL0029", "tec-ind-exp-exp", "AC"], # Explosion
155155
"FAMINE": None,
156-
"FIRE": ["EN0013", "nat-cli-wil-wil"], # Fire
157-
"FLASH FLOOD": ["MH0006", "nat-hyd-flo-fla"], # Flash flood
158-
"FLOOD": ["nat-hyd-flo-flo"], # Flood
159-
"FOG": ["MH0016", "nat-met-fog-fog"], # Fog
156+
"FIRE": ["EN0205", "nat-cli-wil-wil", "WF"], # Fire
157+
"FLASH FLOOD": ["MH0603", "nat-hyd-flo-fla", "FF"], # Flash flood
158+
"FLOOD": ["MH0600", "nat-hyd-flo-flo", "FL"], # Flood
159+
"FOG": ["MH0202", "nat-met-fog-fog", "OT"], # Fog
160160
"FOREST FIRE": ["nat-cli-wil-for"], # Forest fire
161-
"FROST": ["MH0043", "nat-met-ext-sev"], # Severe frost
162-
"HAIL STORM": ["MH0036", "nat-met-sto-hai"], # Hailstorm
163-
"HAILSTORM": ["MH0036", "nat-met-sto-hai"], # Hailstorm
164-
"HEAT WAVE": ["MH0047", "nat-met-ext-hea"], # Heat wave
165-
"LAHAR": ["GH0013", "nat-geo-vol-lah"], # Lahar
166-
"LANDSLIDE": ["GH0007", "nat-hyd-mmw-lan"], # Landslide
167-
"LEAK": ["TL0030", "tec-ind-che-che"], # Chemical leak
168-
"LIQUEFACTION": ["GH0003", "nat-geo-ear-gro"], # Ground liquefaction
169-
"OTHER": ["OT"], # Other
161+
"FROST": ["MH0505", "nat-met-ext-sev", "OT"], # Severe frost
162+
"HAIL STORM": ["MH0404", "nat-met-sto-hai", "ST"], # Hailstorm
163+
"HAILSTORM": ["MH0404", "nat-met-sto-hai", "ST"], # Hailstorm
164+
"HEAT WAVE": ["MH0501", "nat-met-ext-hea", "HT"], # Heat wave
165+
"LAHAR": ["GH0204", "nat-geo-vol-lah", "VO"], # Lahar
166+
"LANDSLIDE": ["GH0300", "nat-geo-mmd-lan", "LS"], # Landslide
167+
"LEAK": ["TL0030", "tec-ind-che-che", "AC"], # Chemical leak
168+
"LIQUEFACTION": ["GH0307", "nat-geo-ear-gro", "EQ"], # Ground liquefaction
169+
"OTHER": None, # Other
170170
"PANIC": None,
171171
"PLAGUE": None,
172172
"POLLUTION": None,
173-
"RAIN": ["nat-met-sto-sto"], # Storm
174-
"RAINS": ["nat-met-sto-sto"], # Storm
175-
"SANDSTORM": ["MH0015", "nat-met-sto-san"], # Sandstorm
176-
"SEDIMENTATION": ["nat-geo-env-sed"], # Sedimentation
177-
"SNOW STORM": ["MH0039", "nat-met-sto-sto"], # Snow Storm
178-
"SNOWSTORM": ["MH0039", "nat-met-sto-sto"], # Snow Storm
179-
"STORM": ["nat-met-sto-sto"], # Storm
180-
"STRONG WIND": ["MH0060", "nat-met-sto-sto"], # Strong wind
181-
"STRUCT.COLLAPSE": ["TL0005", "tec-mis-col-col"], # Structural collapse
182-
"SUBSIDENCE": ["GH0005", "nat-geo-mmd-sub"], # Subsidence
183-
"SURGE": ["MH0027", "nat-met-sto-sur"], # Storm surge
184-
"THUNDERSTORM": ["MH0003", "nat-met-sto-sto"], # Thunderstorm
185-
"TORNADO": ["MH0059", "nat-met-sto-tor"], # Tornado
186-
"TSUNAMI": ["MH0029", "nat-geo-ear-tsu"], # Tsunami
187-
"WINDSTORM": ["MH0060", "nat-met-sto-sto"], # Strong wind
188-
"Inundación": ["nat-hyd-flo-flo"], # Flood
189-
"HURRICANE": ["MH0057", "nat-met-sto-tro"], # Tropical cyclone
190-
"VOLCANO": ["nat-geo-vol-vol"], # Volcanic eruption
191-
"COASTAL FLOOD": ["MH0004", "nat-hyd-flo-coa"], # Coastal flood
173+
"RAIN": ["MH0103", "nat-met-sto-sto", "ST"], # Storm
174+
"RAINS": ["MH0103", "nat-met-sto-sto", "ST"], # Storm
175+
"SANDSTORM": ["MH0201", "nat-met-sto-san", "VW"], # Sandstorm
176+
"SEDIMENTATION": ["GH0405", "nat-geo-env-sed", "OT"], # Sedimentation
177+
"SNOW STORM": ["MH0406", "OT"], # Snow Storm
178+
"SNOWSTORM": ["MH0406", "OT"], # Snow Storm
179+
"STORM": ["MH0103", "nat-met-sto-sto", "ST"], # Storm
180+
"STRONG WIND": ["MH0301", "nat-met-sto-sto", "VW"], # Strong wind
181+
"STRUCT.COLLAPSE": ["TL0005", "tec-mis-col-col", "AC"], # Structural collapse
182+
"SUBSIDENCE": ["GH0309", "nat-geo-ear-gro"], # Subsidence
183+
"SURGE": ["MH0703", "nat-met-sto-sur", "SS"], # Storm surge
184+
"THUNDERSTORM": ["MH0103", "nat-met-sto-sto", "ST"], # Thunderstorm
185+
"TORNADO": ["MH0305", "nat-met-sto-tor", "TO"], # Tornado
186+
"TSUNAMI": ["MH0705", "nat-geo-ear-tsu", "TS"], # Tsunami
187+
"WINDSTORM": ["MH0301", "nat-met-sto-sto", "VW"], # Strong wind
188+
"Inundación": ["MH0600", "nat-hyd-flo-flo", "FL"], # Flood
189+
"HURRICANE": ["MH0309", "nat-met-sto-tro", "TC"], # Tropical cyclone
190+
"VOLCANO": ["GH0205", "nat-geo-vol-vol", "VO"], # Volcanic eruption
191+
"COASTAL FLOOD": ["MH0601", "nat-hyd-flo-coa", "FL"], # Coastal flood
192192
}
193193

194194

@@ -302,7 +302,14 @@ def _create_event_item_from_row(self, row: DataRow) -> Optional[Item]:
302302

303303
monty.episode_number = 1 # Desinventar doesn't have episodes
304304
monty.hazard_codes = hazard_codes
305+
306+
monty.hazard_codes = self.hazard_profiles.get_canonical_hazard_codes(item=item)
307+
305308
monty.country_codes = [row.iso3.upper()]
309+
310+
hazard_keywords = self.hazard_profiles.get_keywords(monty.hazard_codes)
311+
item.properties["keywords"] = list(set(hazard_keywords + monty.country_codes))
312+
306313
monty.compute_and_set_correlation_id(hazard_profiles=self.hazard_profiles)
307314

308315
item.set_collection(self.get_event_collection())

0 commit comments

Comments
 (0)