Skip to content

Commit 944f9aa

Browse files
committed
update set_sigmoid_impf
update of parameter naming and docsting. no change to the logic of the function
1 parent decad35 commit 944f9aa

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

climada/entity/impact_funcs/base.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ def set_step_impf(self, intensity, mdd=(0, 1), paa=(1, 1), impf_id=1):
158158
mdd_min, mdd_max = mdd
159159
self.mdd = np.array([mdd_min, mdd_min, mdd_max, mdd_max])
160160

161-
def set_sigmoid_impf(self, sig_mid, sig_shape, sig_max,
162-
inten_min, inten_max, inten_step=5, if_id=1):
161+
def set_sigmoid_impf(self, intensity, L, k, x0, if_id=1):
163162

164163
""" Sigmoid type impact function hinging on three parameter.
165164
166-
This type of impact function is very flexible for any sort of study/resolution.
167-
Parameters can be thought of as intercept (sig_mid), slope (sig_shape)
168-
and top (sig_max) of a sigmoid. More precisely, sig_mid refers to the
169-
intensity value where MDD equals 50% of sig_max.
165+
This type of impact function is very flexible for any sort of study,
166+
hazard and resolution. The sigmoid is defined as:
167+
168+
.. math::
169+
f(x) = \frac{L}{1+exp^{-k(x-x0)}}
170170
171171
For more information: https://en.wikipedia.org/wiki/Logistic_function
172172
@@ -175,23 +175,20 @@ def set_sigmoid_impf(self, sig_mid, sig_shape, sig_max,
175175
176176
Parameters
177177
----------
178-
sig_mid : float
179-
"intercept" of sigmoid
180-
sig_shape : float
181-
"slope" of sigmoid
182-
sig_max : float
178+
intensity: tuple(float, float, float)
179+
tuple of 3 intensity numbers along np.arange(min, max, step)
180+
L : float
183181
"top" of sigmoid
184-
inten_min : float
185-
minimum value of intensity range
186-
inten_min : float
187-
maximum value of intensity range
188-
inten_step : float, optional, default=5
189-
Spacing between intensity values
182+
k : float
183+
"slope" of sigmoid
184+
x0 : float
185+
intensity value where f(x)==L/2
190186
if_id : int, optional, default=1
191187
impact function id
192188
193189
"""
194190
self.id = if_id
191+
inten_min, inten_max, inten_step = intensity
195192
self.intensity = np.arange(inten_min, inten_max, inten_step)
196193
self.paa = np.ones(len(self.intensity))
197-
self.mdd = sig_max / (1 + np.exp(-sig_shape * (self.intensity - sig_mid)))
194+
self.mdd = L / (1 + np.exp(-k * (self.intensity - x0)))

0 commit comments

Comments
 (0)