climada.entity.measures package

climada.entity.measures.base module

class climada.entity.measures.base.Measure[source]

Bases: object

Contains the definition of one measure.

name

name of the measure

Type:

str

haz_type

related hazard type (peril), e.g. TC

Type:

str

color_rgb

integer array of size 3. Color code of this measure in RGB

Type:

np.array

cost

discounted cost (in same units as assets)

Type:

float

hazard_set

file name of hazard to use (in h5 format)

Type:

str

hazard_freq_cutoff

hazard frequency cutoff

Type:

float

exposures_set

file name of exposure to use (in h5 format) or Exposure instance

Type:

str or climada.entity.Exposure

imp_fun_map

change of impact function id of exposures, e.g. ‘1to3’

Type:

str

hazard_inten_imp

parameter a and b of hazard intensity change

Type:

tuple(float, float)

mdd_impact

parameter a and b of the impact over the mean damage degree

Type:

tuple(float, float)

paa_impact

parameter a and b of the impact over the percentage of affected assets

Type:

tuple(float, float)

exp_region_id

region id of the selected exposures to consider ALL the previous parameters

Type:

int

risk_transf_attach

risk transfer attachment

Type:

float

risk_transf_cover

risk transfer cover

Type:

float

risk_transf_cost_factor

factor to multiply to resulting insurance layer to get the total cost of risk transfer

Type:

float

__init__()[source]

Empty initialization.

check()[source]

Check consistent instance data.

Raises:

ValueError

calc_impact(exposures, imp_fun_set, hazard)[source]

Apply measure and compute impact and risk transfer of measure implemented over inputs.

Parameters:
  • exposures (climada.entity.Exposures) – exposures instance

  • imp_fun_set (climada.entity.ImpactFuncSet) – impact function set instance

  • hazard (climada.hazard.Hazard) – hazard instance

Returns:

  • climada.engine.Impact

  • resulting impact and risk transfer of measure

apply(exposures, imp_fun_set, hazard)[source]

Implement measure with all its defined parameters.

Parameters:
  • exposures (climada.entity.Exposures) – exposures instance

  • imp_fun_set (climada.entity.ImpactFuncSet) – impact function set instance

  • hazard (climada.hazard.Hazard) – hazard instance

Returns:

new_exp, new_ifs, new_haz – climada.entity.ImpactFuncSet,

climada.hazard.Hazard

Exposure, impact function set with implemented measure with all defined parameters.

Return type:

climada.entity.Exposure,

climada.entity.measures.measure_set module

class climada.entity.measures.measure_set.MeasureSet[source]

Bases: object

Contains measures of type Measure. Loads from files with format defined in FILE_EXT.

tag

information about the source data

Type:

Tag

_data

cotains Measure classes. It’s not suppossed to be directly accessed. Use the class methods instead.

Type:

dict

__init__()[source]

Empty initialization.

Examples

Fill MeasureSet with values and check consistency data:

>>> act_1 = Measure()
>>> act_1.name = 'Seawall'
>>> act_1.color_rgb = np.array([0.1529, 0.2510, 0.5451])
>>> act_1.hazard_intensity = (1, 0)
>>> act_1.mdd_impact = (1, 0)
>>> act_1.paa_impact = (1, 0)
>>> meas = MeasureSet()
>>> meas.append(act_1)
>>> meas.tag.description = "my dummy MeasureSet."
>>> meas.check()

Read measures from file and checks consistency data:

>>> meas = MeasureSet.from_excel(ENT_TEMPLATE_XLS)
clear()[source]

Reinitialize attributes.

append(meas)[source]

Append an Measure. Override if same name and haz_type.

Parameters:

meas (Measure) – Measure instance

Raises:

ValueError

remove_measure(haz_type=None, name=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

  • name (str, optional) – measure name

get_measure(haz_type=None, name=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

  • name (str, optional) – measure name

Returns:

  • Measure (if haz_type and name),

  • list(Measure) (if haz_type or name),

  • {Measure.haz_type ({Measure.name : Measure}} (if None))

get_hazard_types(meas=None)[source]

Get measures hazard types contained for the name provided. Return all hazard types if no input name.

Parameters:

name (str, optional) – measure name

Return type:

list(str)

get_names(haz_type=None)[source]

Get measures names contained for the hazard type provided. Return all names for each hazard type if no input hazard type.

Parameters:

haz_type (str, optional) – hazard type from which to obtain the names

Returns:

  • list(Measure.name) (if haz_type provided),

  • {Measure.haz_type (list(Measure.name)} (if no haz_type))

size(haz_type=None, name=None)[source]

Get number of measures 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

  • name (str, optional) – measure name

Return type:

int

check()[source]

Check instance attributes.

Raises:

ValueError

extend(meas_set)[source]

Extend measures of input MeasureSet to current MeasureSet. Overwrite Measure if same name and haz_type.

Parameters:

impact_funcs (MeasureSet) – ImpactFuncSet instance to extend

Raises:

ValueError

classmethod from_mat(file_name, description='', var_names=None)[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

Returns:

meas_set – Measure Set from matlab file

Return type:

climada.entity.MeasureSet()

read_mat(*args, **kwargs)[source]

This function is deprecated, use MeasureSet.from_mat instead.

classmethod from_excel(file_name, description='', var_names=None)[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

Returns:

meas_set – Measures set from Excel

Return type:

climada.entity.MeasureSet

read_excel(*args, **kwargs)[source]

This function is deprecated, use MeasureSet.from_excel instead.

write_excel(file_name, var_names=None)[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