safe.impact_functions.registry module

InaSAFE Disaster risk assessment tool developed by AusAid and World Bank - Impact Function Registry.

Contact :


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class safe.impact_functions.registry.Registry[source]

Bases: object

A simple registry for keeping track of all impact functions.

We will use a singleton pattern to ensure that there is only one canonical registry. The registry can be used by impact functions to register themselves and their GUID’s.

To get the impact functions, please do not use directly from this Registry, but rather user ImpactFunctionManager.

classmethod clear()[source]

Remove all registered impact functions in the registry.

classmethod filter(hazard_metadata=None, exposure_metadata=None)[source]

Filter impact function given the hazard and exposure metadata.

  • hazard_metadata (dict) – Dictionary represent hazard keywords
  • exposure_metadata (dict) – Dictionary represent exposure keywords

List of impact functions.

Return type:


static filter_by_exposure(impact_functions, exposure_keywords)[source]

Filter impact function by exposure_keywords.

  • impact_functions (list) – List of impact functions
  • exposure_keywords (dict) – Dictionary represent exposure keywords

List of impact functions.

Return type:


static filter_by_hazard(impact_functions, hazard_keywords)[source]

Filter impact function by hazard_keywords.

  • impact_functions (list) – List of impact functions.
  • hazard_keywords (dict) – Dictionary represent hazard keywords.

List of impact functions.

Return type:


classmethod filter_by_keyword_string(hazard_keywords=None, exposure_keywords=None)[source]

Get available impact functions from hazard and exposure keywords.

Disabled impact function will not be loaded.

  • hazard_keywords (dict) – The keywords of the hazard.
  • exposure_keywords (dict) – The keywords of the exposure.
classmethod filter_by_metadata(metadata_key, metadata_value)[source]

Return IF classes given its metadata key and value.

  • metadata_key (str) – The key of the metadata e.g ‘id’, ‘name’
  • metadata_value (str, dict) – The value of the metadata, e.g for the key ‘id’ the value is ‘FloodNativePolygonExperimentalFunction’

impact function classes

Return type:


classmethod get_class(name)[source]

Return the class of an impact function given its class name.

Parameters:name (str) – The class name of the IF.
Returns:impact function class
Return type:safe.impact_functions.base.ImpactFunction
classmethod get_instance(name)[source]

Return an instance of impact function given its class name.

Parameters:name (str) – the name of IF class
Returns:impact function instance
Return type:safe.impact_functions.base.ImpactFunction.instance()

Return all registered impact functions.

classmethod list()[source]

List of all registered impact functions by their name.

classmethod register(impact_function)[source]

Register an impact function to the Registry.

Impact Function that will be registered has to have a unique id that is not registered yet.

Parameters:impact_function (ImpactFunction.) – The impact function to register.