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 action

Type

str

haz_type

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

Type

str

color_rgb

integer array of size 3. Gives 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

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

mdd_impact

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

Type

tuple

paa_impact

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

Type

tuple

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 (Exposures) – exposures instance

  • imp_fun_set (ImpactFuncSet) – impact functions instance

  • hazard (Hazard) – hazard instance

Returns

Impact (resulting impact), Impact (insurance layer)

apply(exposures, imp_fun_set, hazard)[source]

Implement measure with all its defined parameters.

Parameters
  • exposures (Exposures) – exposures instance

  • imp_fun_set (ImpactFuncSet) – impact functions instance

  • hazard (Hazard) – hazard instance

Returns

Exposures, ImpactFuncSet, Hazard

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()
>>> meas.read_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

Returns

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

Returns

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

read_mat(file_name, description='', var_names={'field_name': 'measures', 'sup_field_name': 'entity', 'var_name': {'color': 'color', 'cost': 'cost', 'exp_reg': 'Region_ID', 'exp_set': 'assets_file', 'fun_map': 'damagefunctions_map', 'haz': 'peril_ID', 'haz_frq': 'hazard_high_frequency_cutoff', 'haz_int_a': 'hazard_intensity_impact_a', 'haz_int_b': 'hazard_intensity_impact_b', 'haz_set': 'hazard_event_set', 'mdd_a': 'MDD_impact_a', 'mdd_b': 'MDD_impact_b', 'name': 'name', 'paa_a': 'PAA_impact_a', 'paa_b': 'PAA_impact_b', 'risk_att': 'risk_transfer_attachement', 'risk_cov': 'risk_transfer_cover'}})[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

read_excel(file_name, description='', var_names={'col_name': {'color': 'color', 'cost': 'cost', 'exp_reg': 'Region_ID', 'exp_set': 'assets file', 'fun_map': 'damagefunctions map', 'haz': 'peril_ID', 'haz_frq': 'hazard high frequency cutoff', 'haz_int_a': 'hazard intensity impact a', 'haz_int_b': 'hazard intensity impact b', 'haz_set': 'hazard event set', 'mdd_a': 'MDD impact a', 'mdd_b': 'MDD impact b', 'name': 'name', 'paa_a': 'PAA impact a', 'paa_b': 'PAA impact b', 'risk_att': 'risk transfer attachement', 'risk_cov': 'risk transfer cover', 'risk_fact': 'risk transfer cost factor'}, 'sheet_name': 'measures'})[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

write_excel(file_name, var_names={'col_name': {'color': 'color', 'cost': 'cost', 'exp_reg': 'Region_ID', 'exp_set': 'assets file', 'fun_map': 'damagefunctions map', 'haz': 'peril_ID', 'haz_frq': 'hazard high frequency cutoff', 'haz_int_a': 'hazard intensity impact a', 'haz_int_b': 'hazard intensity impact b', 'haz_set': 'hazard event set', 'mdd_a': 'MDD impact a', 'mdd_b': 'MDD impact b', 'name': 'name', 'paa_a': 'PAA impact a', 'paa_b': 'PAA impact b', 'risk_att': 'risk transfer attachement', 'risk_cov': 'risk transfer cover', 'risk_fact': 'risk transfer cost factor'}, 'sheet_name': 'measures'})[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