Skip to content

Commit 4bb02cd

Browse files
author
Chahan Kropf
committed
Add docstring in impact calc
1 parent bd87a0f commit 4bb02cd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climada/engine/impact_calc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def impact(
9292
Default: True
9393
assign_centroids : bool, optional
9494
indicates whether centroids are assigned to the self.exposures object.
95+
Recommendation: assign the centroids directly with control
96+
over the distance metric and the distance threshold using
97+
`exposure.assign_centroids(hazard)`. In this case, set assign_centroids to ``False``.
9598
Centroids assignment is an expensive operation; set this to ``False`` to save
9699
computation time if the hazards' centroids are already assigned to the exposures
97100
object.
@@ -114,10 +117,19 @@ def impact(
114117
>>> imp = impcalc.impact(insured=True)
115118
>>> imp.aai_agg
116119
120+
>>> haz = Hazard.from_hdf5(HAZ_DEMO_H5) # Set hazard
121+
>>> impfset = ImpactFuncSet.from_excel(ENT_TEMPLATE_XLS)
122+
>>> exp = Exposures(pd.read_excel(ENT_TEMPLATE_XLS))
123+
>>> exp.assign_centroids(hazard, threshold=1.5, distance='haversine')
124+
>>> impcalc = ImpactCal(exp, impfset, haz)
125+
>>> imp = impcalc.impact(insured=True, assign_centroids=False)
126+
>>> imp.aai_agg
127+
117128
See also
118129
--------
119130
apply_deductible_to_mat : apply deductible to impact matrix
120131
apply_cover_to_mat : apply cover to impact matrix
132+
climada.exposures.assign_centroids : assign centroids to exposures explicitly
121133
"""
122134
# TODO: consider refactoring, making use of Exposures.hazard_impf
123135
# check for compatibility of exposures and hazard type

0 commit comments

Comments
 (0)