Skip to content

Commit c982fdd

Browse files
committed
add function set_step_ImpF
new generic impact function: step function that can be used for anything
1 parent 190e128 commit c982fdd

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

climada/entity/impact_funcs/base.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def plot(self, axis=None, **kwargs):
9696
axis.set_xlim((self.intensity.min(), self.intensity.max()))
9797
axis.legend()
9898
return axis
99-
99+
100100
def check(self):
101101
"""Check consistent instance data.
102102
@@ -127,4 +127,29 @@ def check(self):
127127
'origin of the intensity scale. In impact.calc '
128128
'the impact is always null at intensity = 0.')
129129

130+
def set_step_ImpF(self, threshold, inten_min, inten_max, if_id=1):
131+
132+
""" Step function type impact function. Everything is destroyed above
133+
threshold. Usefull for high resolution modelling.
134+
135+
This method modifies self (climada.entity.impact_funcs instance)
136+
by assining an id, intensity, mdd and paa to the impact function.
137+
138+
Parameters
139+
----------
140+
threshold : float
141+
threshold over which exposure is fully destroyed
142+
inten_min : float
143+
minimum value of intensity range
144+
inten_min : float
145+
maximum value of intensity range
146+
if_id : int, optional, default=1
147+
impact function id
148+
149+
"""
150+
151+
self.id = if_id
152+
self.intensity = np.array([inten_min, threshold, threshold, inten_max])
153+
self.paa = np.array([1, 1, 1, 1])
154+
self.mdd = np.array([0, 0, 1, 1])
130155

0 commit comments

Comments
 (0)