Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Descriptions of the analyses, inputs and parameters. [#646](https://github.com/IN-CORE/pyincore/issues/646)
- Descriptions of the analyses to be more verbose. [#647](https://github.com/IN-CORE/pyincore/issues/647)
- Hazard service earthquake post method to allow user to specify soil type dataset [#654](https://github.com/IN-CORE/pyincore/issues/654)
- Capital Shocks analysis to also output Sectors in building to sector mappings with no guids as unit shocks. [#671](https://github.com/IN-CORE/pyincore/issues/671)

### Fixed
- Building retrofit fails with local building dataset. [#617](https://github.com/IN-CORE/pyincore/issues/617)
Expand Down
16 changes: 9 additions & 7 deletions pyincore/analyses/capitalshocks/capitalshocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ def run(self):
sector_values = inventory_failure.loc[
(inventory_failure["sector"] == sector)
]
sector_cap = sector_values["cap_rem"].sum()
sector_total = sector_values["appr_bldg"].sum()
if sector_total == 0:
continue
sector_shock = np.divide(sector_cap, sector_total)
sector_shocks[sector] = sector_shock

if sector_values.empty:
sector_shocks[sector] = 1.0
else:
sector_cap = sector_values["cap_rem"].sum()
sector_total = sector_values["appr_bldg"].sum()
if sector_total == 0:
continue
sector_shock = np.divide(sector_cap, sector_total)
sector_shocks[sector] = sector_shock
sector_shocks = pd.DataFrame(sector_shocks.items(), columns=["sector", "shock"])
result_name = self.get_parameter("result_name")
self.set_result_csv_data(
Expand Down
Loading