Skip to content

Commit

Permalink
Merge branch 'develop' into 153-create-a-one-main-plotting-for-hazard…
Browse files Browse the repository at this point in the history
…-dataset
  • Loading branch information
ywkim312 authored Jan 25, 2024
2 parents 15883e7 + 88561e2 commit 489ceb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Plot method for local hazard [#153](https://github.com/IN-CORE/pyincore-viz/issues/153)

### Changed
- Refactor tornado and eq visualization due to hazard datasets added to model [#154](https://github.com/IN-CORE/pyincore-viz/issues/154)


## [1.9.0] - 2023-12-13
### Added
- Local hazard visualization [#143](https://github.com/IN-CORE/pyincore-viz/issues/143)
Expand Down
8 changes: 4 additions & 4 deletions pyincore_viz/geoutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def plot_tornado(tornado_id, client, category=False, basemap=True, source=ctx.pr
# it needs descartes package for polygon plotting
# getting tornado dataset should be part of Tornado Hazard code
tornado_dataset_id = HazardService(
client).get_tornado_hazard_metadata(tornado_id)['datasetId']
client).get_tornado_hazard_metadata(tornado_id)["hazardDatasets"][0].get('datasetId')
tornado_dataset = Dataset.from_data_service(
tornado_dataset_id, DataService(client))
tornado_gdf = gpd.read_file(tornado_dataset.local_file_path)
Expand All @@ -195,9 +195,9 @@ def plot_earthquake(earthquake_id, client, demand=None):
eq_dataset_id = None

if eq_metadata['eqType'] == 'model':
eq_dataset_id = eq_metadata['rasterDataset']['datasetId']
demand_type = eq_metadata['rasterDataset']['demandType']
period = eq_metadata['rasterDataset']['period']
eq_dataset_id = eq_metadata['hazardDatasets'][0].get('datasetId')
demand_type = eq_metadata['hazardDatasets'][0].get('demandType')
period = eq_metadata['hazardDatasets'][0].get('period', "NA")
else:
if demand is None: # get first dataset
if len(eq_metadata['hazardDatasets']) > 0 and eq_metadata['hazardDatasets'][0]['datasetId']:
Expand Down
8 changes: 5 additions & 3 deletions tests/pyincore_viz/test_pyincore_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def test_visualize_joplin_tornado_building(client):

viz.plot_tornado(tornado_hazard_id, client, basemap=False)

tornado_dataset_id = HazardService(client).get_tornado_hazard_metadata(tornado_hazard_id)['datasetId']
tornado_dataset_id = HazardService(client).get_tornado_hazard_metadata(tornado_hazard_id)[
'hazardDatasets'][0].get('datasetId')
tornado_dataset = Dataset.from_data_service(tornado_dataset_id, DataService(client))

viz.get_gdf_map([tornado_dataset])
Expand Down Expand Up @@ -242,7 +243,7 @@ def test_overay_gdf_with_raster(client):
memphis_water_pipeline = "5a284f28c7d30d13bc081d14"
memphis_eq = "5b902cb273c3371e1236b36b"

eq_dataset_id = HazardService(client).get_earthquake_hazard_metadata(memphis_eq)['rasterDataset']['datasetId']
eq_dataset_id = HazardService(client).get_earthquake_hazard_metadata(memphis_eq)['hazardDatasets'][0].get('datasetId')
raster_dataset = Dataset.from_data_service(eq_dataset_id, DataService(client))

dataset = Dataset.from_data_service(shelby_hospital_inv_id, DataService(client))
Expand Down Expand Up @@ -276,7 +277,8 @@ def test_multiple_vector_visualization(client):
centerville_epn_link = '5b1fdc2db1cf3e336d7cecc9'
tornado_metadata = HazardService(client).get_tornado_hazard_metadata(centerville_model_tornado)
dataset1 = Dataset.from_data_service(centerville_epn_link, DataService(client))
dataset2 = Dataset.from_data_service(tornado_metadata["datasetId"], DataService(client))
dataset2 = Dataset.from_data_service(tornado_metadata["hazardDatasets"][0].get("datasetId"),
DataService(client))
viz.plot_multiple_vector_dataset([dataset1, dataset2])

assert True

0 comments on commit 489ceb3

Please sign in to comment.