Skip to content

Commit 3cea1ec

Browse files
Send data into pdc transformer in a temp file.
1 parent 3b2dc6c commit 3cea1ec

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pystac_monty/sources/pdc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import os
32
from datetime import datetime
43
from typing import Any, List, Optional, Union
54

@@ -47,11 +46,11 @@ def __init__(self, pdc_data_src: PDCDataSource):
4746
self.exposure_detail = {}
4847
self.geojson_data = {}
4948

50-
if "hazards_file_path" in self.config_data and os.path.exists(self.config_data["hazards_file_path"]):
49+
if "hazards_file_path" in self.config_data:
5150
with open(self.config_data["hazards_file_path"], "r", encoding="utf-8") as f:
5251
self.hazards_data = json.loads(f.read())
5352

54-
if "exposure_detail_file_path" in self.config_data and os.path.exists(self.config_data["exposure_detail_file_path"]):
53+
if "exposure_detail_file_path" in self.config_data:
5554
with open(self.config_data["exposure_detail_file_path"], "r", encoding="utf-8") as f:
5655
self.exposure_detail = json.loads(f.read())
5756

@@ -63,7 +62,8 @@ def __init__(self, pdc_data_src: PDCDataSource):
6362
self.episode_number = int(float(self.config_data.get("exposure_timestamp", 0)))
6463
except ValueError:
6564
self.episode_number = 0
66-
if "geojson_file_path" in self.config_data and os.path.exists(self.config_data["geojson_file_path"]):
65+
66+
if "geojson_file_path" in self.config_data:
6767
with open(self.config_data["geojson_file_path"], "r", encoding="utf-8") as f:
6868
self.geojson_data = json.loads(f.read())
6969

@@ -130,8 +130,8 @@ def make_source_event_item(self) -> Optional[Item]:
130130
item.set_collection(self.get_event_collection())
131131
item.properties["roles"] = ["source", "event"]
132132

133-
all_iso3 = []
134-
all_iso3.extend([i["country"] for i in self.exposure_detail["totalByCountry"]])
133+
# NOTE Done to handle country as None
134+
all_iso3 = [i["country"] for i in self.exposure_detail.get("totalByCountry", []) if i.get("country")]
135135

136136
MontyExtension.add_to(item)
137137
monty = MontyExtension.ext(item)
@@ -161,7 +161,7 @@ def _map_pdc_to_hazard_codes(self, hazard: str) -> List[str]:
161161
"TORNADO": ["nat-met-sto-tor"],
162162
"CYCLONE": ["nat-met-sto-tro"],
163163
"TSUNAMI": ["MH0029", "nat-geo-ear-tsu"],
164-
"VOLCANO": ["GH0020"],
164+
"VOLCANO": ["GH0020", "nat-geo-vol-vol"],
165165
"WILDFIRE": ["EN0013", "nat-cli-wil-for"],
166166
"WINTERSTORM": ["nat-met-sto-bli"],
167167
"STORMSURGE": ["MH0027", "nat-met-sto-sur"],

0 commit comments

Comments
 (0)