climada.entity.impact_funcs package¶
climada.entity.impact_funcs.base module¶
-
class
climada.entity.impact_funcs.base.
ImpactFunc
[source]¶ Bases:
object
Contains the definition of one impact function.
-
haz_type
¶ hazard type acronym (e.g. ‘TC’)
- Type
str
-
id
¶ id of the impact function. Exposures of the same type will refer to the same impact function id
- Type
int or str
-
name
¶ name of the ImpactFunc
- Type
str
-
intensity_unit
¶ unit of the intensity
- Type
str
-
intensity
¶ intensity values
- Type
np.array
-
mdd
¶ mean damage (impact) degree for each intensity (numbers in [0,1])
- Type
np.array
-
paa
¶ percentage of affected assets (exposures) for each intensity (numbers in [0,1])
- Type
np.array
-
calc_mdr
(inten)[source]¶ Interpolate impact function to a given intensity.
- Parameters
inten (float or np.array) – intensity, the x-coordinate of the interpolated values.
- Returns
np.array
-
plot
(axis=None, **kwargs)[source]¶ Plot the impact functions MDD, MDR and PAA in one graph, where MDR = PAA * MDD.
- Parameters
axis (matplotlib.axes._subplots.AxesSubplot, optional) – axis to use
kwargs (optional) – arguments for plot matplotlib function, e.g. marker=’x’
- Returns
matplotlib.axes._subplots.AxesSubplot
-
climada.entity.impact_funcs.impact_func_set module¶
-
class
climada.entity.impact_funcs.impact_func_set.
ImpactFuncSet
[source]¶ Bases:
object
Contains impact functions of type ImpactFunc. Loads from files with format defined in FILE_EXT.
-
_data
¶ contains ImpactFunc classes. It’s not suppossed to be directly accessed. Use the class methods instead.
- Type
dict
-
__init__
()[source]¶ Empty initialization.
Examples
Fill impact functions with values and check consistency data:
>>> fun_1 = ImpactFunc() >>> fun_1.haz_type = 'TC' >>> fun_1.id = 3 >>> fun_1.intensity = np.array([0, 20]) >>> fun_1.paa = np.array([0, 1]) >>> fun_1.mdd = np.array([0, 0.5]) >>> imp_fun = ImpactFuncSet() >>> imp_fun.append(fun_1) >>> imp_fun.check()
Read impact functions from file and checks consistency data.
>>> imp_fun = ImpactFuncSet() >>> imp_fun.read(ENT_TEMPLATE_XLS)
-
append
(func)[source]¶ Append a ImpactFunc. Overwrite existing if same id and haz_type.
- Parameters
func (ImpactFunc) – ImpactFunc instance
- Raises
ValueError –
-
remove_func
(haz_type=None, fun_id=None)[source]¶ Remove impact function(s) with provided hazard type and/or id. If no input provided, all impact functions are removed.
- Parameters
haz_type (str, optional) – all impact functions with this hazard
fun_id (int, optional) – all impact functions with this id
-
get_func
(haz_type=None, fun_id=None)[source]¶ Get ImpactFunc(s) of input hazard type and/or id. If no input provided, all impact functions are returned.
- Parameters
haz_type (str, optional) – hazard type
fun_id (int, optional) – ImpactFunc id
- Returns
ImpactFunc (if haz_type and fun_id), list(ImpactFunc) (if haz_type or fun_id), {ImpactFunc.haz_type: {ImpactFunc.id : ImpactFunc}} (if None)
-
get_hazard_types
(fun_id=None)[source]¶ Get impact functions hazard types contained for the id provided. Return all hazard types if no input id.
- Parameters
fun_id (int, optional) – id of an impact function
- Returns
list(str)
-
get_ids
(haz_type=None)[source]¶ Get impact functions ids contained for the hazard type provided. Return all ids for each hazard type if no input hazard type.
- Parameters
haz_type (str, optional) – hazard type from which to obtain the ids
- Returns
list(ImpactFunc.id) (if haz_type provided), {ImpactFunc.haz_type : list(ImpactFunc.id)} (if no haz_type)
-
size
(haz_type=None, fun_id=None)[source]¶ Get number of impact functions contained with input hazard type and /or id. If no input provided, get total number of impact functions.
- Parameters
haz_type (str, optional) – hazard type
fun_id (int, optional) – ImpactFunc id
- Returns
int
-
extend
(impact_funcs)[source]¶ Append impact functions of input ImpactFuncSet to current ImpactFuncSet. Overwrite ImpactFunc if same id and haz_type.
- Parameters
impact_funcs (ImpactFuncSet) – ImpactFuncSet instance to extend
- Raises
ValueError –
-
plot
(haz_type=None, fun_id=None, axis=None, **kwargs)[source]¶ Plot impact functions of selected hazard (all if not provided) and selected function id (all if not provided).
- Parameters
haz_type (str, optional) – hazard type
fun_id (int, optional) – id of the function
- Returns
matplotlib.axes._subplots.AxesSubplot
-
read_excel
(file_name, description='', var_names={'col_name': {'func_id': 'impact_fun_id', 'inten': 'intensity', 'mdd': 'mdd', 'name': 'name', 'paa': 'paa', 'peril': 'peril_id', 'unit': 'intensity_unit'}, 'sheet_name': 'impact_functions'})[source]¶ Read excel file following template and store variables.
- Parameters
file_name (str) – absolute file name
description (str, optional) – description of the data
var_names (dict, optional) – name of the variables in the file
-
read_mat
(file_name, description='', var_names={'field_name': 'damagefunctions', 'sup_field_name': 'entity', 'var_name': {'fun_id': 'DamageFunID', 'inten': 'Intensity', 'mdd': 'MDD', 'name': 'name', 'paa': 'PAA', 'peril': 'peril_ID', 'unit': 'Intensity_unit'}})[source]¶ Read MATLAB file generated with previous MATLAB CLIMADA version.
- Parameters
file_name (str) – absolute file name
description (str, optional) – description of the data
var_names (dict, optional) – name of the variables in the file
-
write_excel
(file_name, var_names={'col_name': {'func_id': 'impact_fun_id', 'inten': 'intensity', 'mdd': 'mdd', 'name': 'name', 'paa': 'paa', 'peril': 'peril_id', 'unit': 'intensity_unit'}, 'sheet_name': 'impact_functions'})[source]¶ Write excel file following template.
- Parameters
file_name (str) – absolute file name to write
var_names (dict, optional) – name of the variables in the file
-
climada.entity.impact_funcs.trop_cyclone module¶
-
class
climada.entity.impact_funcs.trop_cyclone.
IFTropCyclone
[source]¶ Bases:
climada.entity.impact_funcs.base.ImpactFunc
Impact functions for tropical cyclones.
-
set_emanuel_usa
(if_id=1, intensity=array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]), v_thresh=25.7, v_half=74.7, scale=1.0)[source]¶ Using the formula of Emanuele 2011.
- Parameters
if_id (int, optional) – impact function id. Default: 1
intensity (np.array, optional) – intensity array in m/s. Default: 5 m/s step array from 0 to 120m/s
v_thresh (float, optional) – first shape parameter, wind speed in m/s below which there is no damage. Default: 25.7(Emanuel 2011)
v_half (float, optional) – second shape parameter, wind speed in m/s at which 50% of max. damage is expected. Default: v_threshold + 49 m/s (mean value of Sealy & Strobl 2017)
scale (float, optional) – scale parameter, linear scaling of MDD. 0<=scale<=1. Default: 1.0
- Raises
ValueError –
-