@@ -143,4 +143,68 @@ def check(self):
143143 'origin of the intensity scale. In impact.calc '
144144 'the impact is always null at intensity = 0.' )
145145
146+ def set_step_impf (self , intensity , mdd = (0 , 1 ), paa = (1 , 1 ), impf_id = 1 ):
146147
148+ """ Step function type impact function.
149+
150+ By default, everything is destroyed above the step.
151+ Useful for high resolution modelling.
152+
153+ This method modifies self (climada.entity.impact_funcs instance)
154+ by assigning an id, intensity, mdd and paa to the impact function.
155+
156+ Parameters
157+ ----------
158+ intensity: tuple(float, float, float)
159+ tuple of 3-intensity numbers: (minimum, threshold, maximum)
160+ mdd: tuple(float, float)
161+ (min, max) mdd values. The default is (0, 1)
162+ paa: tuple(float, float)
163+ (min, max) paa values. The default is (1, 1)
164+ impf_id : int, optional, default=1
165+ impact function id
166+
167+ """
168+
169+ self .id = impf_id
170+ inten_min , threshold , inten_max = intensity
171+ self .intensity = np .array ([inten_min , threshold , threshold , inten_max ])
172+ paa_min , paa_max = paa
173+ self .paa = np .array ([paa_min , paa_min , paa_max , paa_max ])
174+ mdd_min , mdd_max = mdd
175+ self .mdd = np .array ([mdd_min , mdd_min , mdd_max , mdd_max ])
176+
177+ def set_sigmoid_impf (self , intensity , L , k , x0 , if_id = 1 ):
178+
179+ """ Sigmoid type impact function hinging on three parameter.
180+
181+ This type of impact function is very flexible for any sort of study,
182+ hazard and resolution. The sigmoid is defined as:
183+
184+ .. math::
185+ f(x) = \f rac{L}{1+exp^{-k(x-x0)}}
186+
187+ For more information: https://en.wikipedia.org/wiki/Logistic_function
188+
189+ This method modifies self (climada.entity.impact_funcs instance)
190+ by assining an id, intensity, mdd and paa to the impact function.
191+
192+ Parameters
193+ ----------
194+ intensity: tuple(float, float, float)
195+ tuple of 3 intensity numbers along np.arange(min, max, step)
196+ L : float
197+ "top" of sigmoid
198+ k : float
199+ "slope" of sigmoid
200+ x0 : float
201+ intensity value where f(x)==L/2
202+ if_id : int, optional, default=1
203+ impact function id
204+
205+ """
206+ self .id = if_id
207+ inten_min , inten_max , inten_step = intensity
208+ self .intensity = np .arange (inten_min , inten_max , inten_step )
209+ self .paa = np .ones (len (self .intensity ))
210+ self .mdd = L / (1 + np .exp (- k * (self .intensity - x0 )))
0 commit comments