Commit 07bf071b authored by Danijel Schorlemmer's avatar 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
......@@ -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,6 +105,21 @@ def damage_calculator(
row[(i + 1)] for row in damage_by_assets
]
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)
......@@ -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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment