Skip to content

Commit 7da50f1

Browse files
committed
Return impactForecast object in _return_impact
1 parent 35f9517 commit 7da50f1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

climada/engine/impact_calc.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
from climada import CONFIG
3131
from climada.engine.impact import Impact
32+
from climada.engine.impact_forecast import ImpactForecast
33+
from climada.hazard.forecast import HazardForecast
3234

3335
LOGGER = logging.getLogger(__name__)
3436

@@ -217,7 +219,7 @@ def _return_impact(self, imp_mat_gen, save_mat):
217219
218220
Returns
219221
-------
220-
Impact
222+
Impact or ImpactForecast
221223
Impact Object initialize from the impact matrix
222224
223225
See Also
@@ -233,9 +235,18 @@ def _return_impact(self, imp_mat_gen, save_mat):
233235
else:
234236
imp_mat = None
235237
at_event, eai_exp, aai_agg = self.stitch_risk_metrics(imp_mat_gen)
236-
return Impact.from_eih(
238+
239+
impact = Impact.from_eih(
237240
self.exposures, self.hazard, at_event, eai_exp, aai_agg, imp_mat
238241
)
242+
if isinstance(self.hazard, HazardForecast):
243+
return ImpactForecast().from_impact(
244+
impact, self.hazard.ensemble_member, self.hazard.lead_time
245+
) # return ImpactForecast object
246+
else:
247+
return (
248+
impact # return normal impact object if hazard is not a HazardForecast
249+
)
239250

240251
def _return_empty(self, save_mat):
241252
"""

0 commit comments

Comments
 (0)