@@ -96,7 +96,7 @@ def __init__(
9696 self .mdd = mdd if mdd is not None else np .array ([])
9797 self .paa = paa if paa is not None else np .array ([])
9898
99- def calc_mdr (self , inten ) :
99+ def calc_mdr (self , inten : Union [ float , np . ndarray ]) -> np . ndarray :
100100 """Interpolate impact function to a given intensity.
101101
102102 Parameters
@@ -162,7 +162,14 @@ def check(self):
162162 return
163163
164164 @classmethod
165- def from_step_impf (cls , intensity , mdd = (0 , 1 ), paa = (1 , 1 ), impf_id = 1 ):
165+ def from_step_impf (
166+ cls ,
167+ intensity : tuple [float , float , float ],
168+ haz_type : str ,
169+ mdd : tuple [float , float ] = (0 , 1 ),
170+ paa : tuple [float , float ] = (1 , 1 ),
171+ impf_id : int = 1 ,
172+ ** kwargs ):
166173
167174 """ Step function type impact function.
168175
@@ -176,12 +183,16 @@ def from_step_impf(cls, intensity, mdd=(0, 1), paa=(1, 1), impf_id=1):
176183 ----------
177184 intensity: tuple(float, float, float)
178185 tuple of 3-intensity numbers: (minimum, threshold, maximum)
186+ haz_type: str
187+ the reference string for the hazard (e.g., 'TC', 'RF', 'WS', ...)
179188 mdd: tuple(float, float)
180189 (min, max) mdd values. The default is (0, 1)
181190 paa: tuple(float, float)
182191 (min, max) paa values. The default is (1, 1)
183192 impf_id : int, optional, default=1
184193 impact function id
194+ kwargs :
195+ keyword arguments passed to ImpactFunc()
185196
186197 Return
187198 ------
@@ -196,7 +207,8 @@ def from_step_impf(cls, intensity, mdd=(0, 1), paa=(1, 1), impf_id=1):
196207 mdd_min , mdd_max = mdd
197208 mdd = np .array ([mdd_min , mdd_min , mdd_max , mdd_max ])
198209
199- return cls (id = impf_id , intensity = intensity , mdd = mdd , paa = paa )
210+ return cls (haz_type = haz_type , id = impf_id ,
211+ intensity = intensity , mdd = mdd , paa = paa , ** kwargs )
200212
201213 def set_step_impf (self , * args , ** kwargs ):
202214 """This function is deprecated, use ImpactFunc.from_step_impf instead."""
@@ -205,7 +217,15 @@ def set_step_impf(self, *args, **kwargs):
205217 self .__dict__ = ImpactFunc .from_step_impf (* args , ** kwargs ).__dict__
206218
207219 @classmethod
208- def from_sigmoid_impf (cls , intensity , L , k , x0 , if_id = 1 ):
220+ def from_sigmoid_impf (
221+ cls ,
222+ intensity : tuple [float , float , float ],
223+ L : float ,
224+ k : float ,
225+ x0 : float ,
226+ haz_type : str ,
227+ impf_id : int = 1 ,
228+ ** kwargs ):
209229 """Sigmoid type impact function hinging on three parameter.
210230
211231 This type of impact function is very flexible for any sort of study,
@@ -228,20 +248,25 @@ def from_sigmoid_impf(cls, intensity, L, k, x0, if_id=1):
228248 "slope" of sigmoid
229249 x0 : float
230250 intensity value where f(x)==L/2
231- if_id : int, optional, default=1
251+ haz_type: str
252+ the reference string for the hazard (e.g., 'TC', 'RF', 'WS', ...)
253+ impf_id : int, optional, default=1
232254 impact function id
255+ kwargs :
256+ keyword arguments passed to ImpactFunc()
233257
234258 Return
235259 ------
236260 impf : climada.entity.impact_funcs.ImpactFunc
237- Step impact function
261+ Sigmoid impact function
238262 """
239263 inten_min , inten_max , inten_step = intensity
240264 intensity = np .arange (inten_min , inten_max , inten_step )
241265 paa = np .ones (len (intensity ))
242266 mdd = L / (1 + np .exp (- k * (intensity - x0 )))
243267
244- return cls (id = if_id , intensity = intensity , paa = paa , mdd = mdd )
268+ return cls (haz_type = haz_type , id = impf_id , intensity = intensity ,
269+ paa = paa , mdd = mdd , ** kwargs )
245270
246271 def set_sigmoid_impf (self , * args , ** kwargs ):
247272 """This function is deprecated, use LitPop.from_countries instead."""
0 commit comments