Skip to content

Commit 6f6df11

Browse files
committed
add set_sigmoid_ImpF
new generic sigmoid impact function
1 parent c982fdd commit 6f6df11

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

climada/entity/impact_funcs/base.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,38 @@ def set_step_ImpF(self, threshold, inten_min, inten_max, if_id=1):
153153
self.paa = np.array([1, 1, 1, 1])
154154
self.mdd = np.array([0, 0, 1, 1])
155155

156+
def set_sigmoid_ImpF(self, sig_mid, sig_shape, sig_max,
157+
inten_min, inten_max, inten_step=5, if_id=1):
158+
159+
""" Sigmoid type impact function hinging on three parameter. This type
160+
of impact function is very flexible for any sort of study/resolution.
161+
Parameters can be thought of as intercept (sig_mid), slope (sig_shape)
162+
and top (sig_max) of a sigmoid.
163+
164+
For more information: https://en.wikipedia.org/wiki/Logistic_function
165+
166+
This method modifies self (climada.entity.impact_funcs instance)
167+
by assining an id, intensity, mdd and paa to the impact function.
168+
169+
Parameters
170+
----------
171+
sig_mid : float
172+
"intercept" of sigmoid
173+
sig_shape : float
174+
"slope" of sigmoid
175+
sig_max : float
176+
"top" of sigmoid
177+
inten_min : float
178+
minimum value of intensity range
179+
inten_min : float
180+
maximum value of intensity range
181+
inten_step : float, optional, default=5
182+
Spacing between intensity values
183+
if_id : int, optional, default=1
184+
impact function id
185+
186+
"""
187+
self.id = if_id
188+
self.intensity = np.arange(inten_min, inten_max, inten_step)
189+
self.paa = np.ones(len(self.intensity))
190+
self.mdd = sig_max / (1 + np.exp(-sig_shape * (self.intensity - sig_mid)))

0 commit comments

Comments
 (0)