Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Global Dynamic Exposure
losscalculator
Commits
07bf071b
Commit
07bf071b
authored
Nov 28, 2021
by
Danijel Schorlemmer
Browse files
Implemented the summing up of probabilities per damage state per building (aggregation)
parent
4da4c24c
Pipeline
#35378
passed with stage
in 2 minutes and 2 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
losscalculator/damage_calculator.py
View file @
07bf071b
...
...
@@ -40,6 +40,7 @@ def damage_calculator(
interpolation_method
=
"linear"
,
result_filepath
=
"damage_result.csv"
,
use_xml_fragilities
=
True
,
aggregation
=
True
,
):
"""
This function computes the probabilities of occurrence (PoO) of damage states for a scenario
...
...
@@ -104,7 +105,22 @@ def damage_calculator(
row
[(
i
+
1
)]
for
row
in
damage_by_assets
]
exposure
.
to_csv
(
result_filepath
,
index
=
False
)
if
aggregation
:
aggregated
=
exposure
.
groupby
([
"id"
,
"building_geometry"
,
"tile_id"
,
"tile_geometry"
])[
[
"number"
,
"structural"
,
"night"
,
"structural_no_damage"
,
"structural_slight"
,
"structural_moderate"
,
"structural_extensive"
,
"structural_complete"
,
]
].
sum
()
aggregated
.
to_csv
(
result_filepath
)
else
:
exposure
.
to_csv
(
result_filepath
,
index
=
False
)
def
main
():
...
...
@@ -184,8 +200,14 @@ def main():
"--overwrite"
,
required
=
False
,
action
=
"store_true"
,
help
=
"Result file exists. Choose another name or set --overwrite"
+
"to overwrite the existing result file."
,
help
=
"overwrite result file if it already exists"
,
)
parser
.
add_argument
(
"-a"
,
"--no-aggregation"
,
required
=
False
,
action
=
"store_true"
,
help
=
"do not aggregate the results for each building (detailed results for debugging)"
,
)
parser
.
add_argument
(
"-t"
,
...
...
@@ -209,6 +231,7 @@ def main():
exposure_filepath
=
args
.
exposure
result_filepath
=
args
.
results
overwrite_result_file
=
args
.
overwrite
aggregation
=
not
args
.
no_aggregation
taxonomy_map_filepath
=
args
.
taxonomy_map
if
command
==
"version"
:
...
...
@@ -265,6 +288,7 @@ def main():
interpolation_method
,
result_filepath
,
use_xml_fragilities
,
aggregation
,
)
print
(
"Execution time of the script"
,
(
datetime
.
datetime
.
now
()
-
startTime
))
else
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment