3434import pandas as pd
3535from scipy .sparse import csr_matrix
3636
37- from climada .engine .impact import Impact
37+ from climada .engine .impact import Impact , ImpactFreqCurve
3838from climada .engine .impact_calc import ImpactCalc
3939from climada .entity .measures .base import Measure
4040from climada .trajectories .constants import (
@@ -777,25 +777,37 @@ def per_date_aai_E0H0V1(self) -> np.ndarray:
777777 def per_date_return_periods_H0V0 (self , return_periods : list [int ]) -> np .ndarray :
778778 """Estimated impacts per dates for given return periods, with changing exposure, starting hazard and starting vulnerability."""
779779 return calc_per_date_rps (
780- self .imp_mats_H0V0 , self .snapshot_start .hazard .frequency , return_periods
780+ self .imp_mats_H0V0 ,
781+ self .snapshot_start .hazard .frequency ,
782+ self .date_idx .freqstr [0 ],
783+ return_periods ,
781784 )
782785
783786 def per_date_return_periods_H1V0 (self , return_periods : list [int ]) -> np .ndarray :
784787 """Estimated impacts per dates for given return periods, with changing exposure, future hazard and starting vulnerability."""
785788 return calc_per_date_rps (
786- self .imp_mats_H1V0 , self .snapshot_end .hazard .frequency , return_periods
789+ self .imp_mats_H1V0 ,
790+ self .snapshot_end .hazard .frequency ,
791+ self .date_idx .freqstr [0 ],
792+ return_periods ,
787793 )
788794
789795 def per_date_return_periods_H0V1 (self , return_periods : list [int ]) -> np .ndarray :
790796 """Estimated impacts per dates for given return periods, with changing exposure, starting hazard and future vulnerability."""
791797 return calc_per_date_rps (
792- self .imp_mats_H0V1 , self .snapshot_start .hazard .frequency , return_periods
798+ self .imp_mats_H0V1 ,
799+ self .snapshot_start .hazard .frequency ,
800+ self .date_idx .freqstr [0 ],
801+ return_periods ,
793802 )
794803
795804 def per_date_return_periods_H1V1 (self , return_periods : list [int ]) -> np .ndarray :
796805 """Estimated impacts per dates for given return periods, with changing exposure, future hazard and future vulnerability."""
797806 return calc_per_date_rps (
798- self .imp_mats_H1V1 , self .snapshot_end .hazard .frequency , return_periods
807+ self .imp_mats_H1V1 ,
808+ self .snapshot_end .hazard .frequency ,
809+ self .date_idx .freqstr [0 ],
810+ return_periods ,
799811 )
800812
801813 ##################################
@@ -1126,6 +1138,7 @@ def calc_per_date_aais(per_date_eai_exp: np.ndarray) -> np.ndarray:
11261138def calc_per_date_rps (
11271139 imp_mats : list [csr_matrix ],
11281140 frequency : np .ndarray ,
1141+ frequency_unit : str ,
11291142 return_periods : list [int ],
11301143) -> np .ndarray :
11311144 """Calculate per date return period impact values from a
@@ -1148,12 +1161,17 @@ def calc_per_date_rps(
11481161
11491162 """
11501163 rp = np .array (
1151- [calc_freq_curve (imp_mat , frequency , return_periods ) for imp_mat in imp_mats ]
1164+ [
1165+ calc_freq_curve (imp_mat , frequency , frequency_unit , return_periods ).impact
1166+ for imp_mat in imp_mats
1167+ ]
11521168 )
11531169 return rp
11541170
11551171
1156- def calc_freq_curve (imp_mat_intrpl , frequency , return_per = None ) -> np .ndarray :
1172+ def calc_freq_curve (
1173+ imp_mat_intrpl , frequency , frequency_unit , return_per = None
1174+ ) -> ImpactFreqCurve :
11571175 """Calculate the estimated impacts for given return periods.
11581176
11591177 Parameters
@@ -1188,4 +1206,9 @@ def calc_freq_curve(imp_mat_intrpl, frequency, return_per=None) -> np.ndarray:
11881206 ifc_return_per = return_per
11891207 ifc_impact = interp_imp
11901208
1191- return ifc_impact
1209+ return ImpactFreqCurve (
1210+ return_per = ifc_return_per ,
1211+ impact = ifc_impact ,
1212+ frequency_unit = frequency_unit ,
1213+ label = "Exceedance frequency curve" ,
1214+ )
0 commit comments