def evacuated_population_weekly_needs( population, minimum_needs=None): """Calculate estimated needs using minimum needs as specified or the default. :param population: The number of evacuated population. :type: int, float :param minimum_needs: Ratios used to calculate weekly needs in parameter form. :type minimum_needs: list, :returns: The needs for the evacuated population. :rtype: dict """ if not minimum_needs: minimum_needs = default_minimum_needs() minimum_needs = filter_needs_parameters(minimum_needs) population_needs = OrderedDict() for resource in minimum_needs: resource = resource.serialize() amount = resource['value'] name = resource['name'] population_needs[name] = int(ceil(population * float(amount))) return population_needs
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'PAGFatalityFunction', 'name': tr('Earthquake PAGER fatality function'), 'impact': tr('Die or be displaced according Pager model'), 'title': tr('Die or be displaced according Pager model'), 'function_type': 'old-style', 'author': 'Helen Crowley', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impact of an earthquake on population based ' 'on the Population Vulnerability Pager Model.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'citations': [ tr('Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). ' 'Estimating casualties for large worldwide earthquakes ' 'using an empirical approach. U.S. Geological Survey ' 'Open-File Report 2009-1136.') ], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_earthquake], 'units': [unit_mmi], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance())]) } return dict_meta
def setUp(self): """Run before each test.""" params = { 'impact_total': 146458, 'function_params': { 'minimum needs': default_minimum_needs() } } POSTPROCESSOR.setup(params)
def test_default_needs(self): """default calculated needs are as expected """ minimum_needs = [ parameter.serialize() for parameter in default_minimum_needs()] # 20 Happens to be the smallest number at which integer rounding # won't make a difference to the result result = evacuated_population_needs(20, minimum_needs)['weekly'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert (result['Rice [kg]'] == 56 and result['Drinking Water [l]'] == 350 and result['Clean Water [l]'] == 1340 and result['Family Kits'] == 4) result = evacuated_population_needs(10, minimum_needs)['single'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert result['Toilets'] == 1
def test_default_needs(self): """default calculated needs are as expected """ minimum_needs = [ parameter.serialize() for parameter in default_minimum_needs() ] # 20 Happens to be the smallest number at which integer rounding # won't make a difference to the result result = evacuated_population_needs(20, minimum_needs)['weekly'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert (result['Rice [kg]'] == 56 and result['Drinking Water [l]'] == 350 and result['Clean Water [l]'] == 1340 and result['Family Kits'] == 4) result = evacuated_population_needs(10, minimum_needs)['single'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert result['Toilets'] == 1
def test_arbitrary_needs(self): """custom need ratios calculated are as expected """ minimum_needs = [ parameter.serialize() for parameter in default_minimum_needs()] minimum_needs[0]['value'] = 4 minimum_needs[1]['value'] = 3 minimum_needs[2]['value'] = 2 minimum_needs[3]['value'] = 1 minimum_needs[4]['value'] = 0.2 result = evacuated_population_needs(10, minimum_needs)['weekly'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert (result['Rice [kg]'] == 40 and result['Drinking Water [l]'] == 30 and result['Clean Water [l]'] == 20 and result['Family Kits'] == 10) result = evacuated_population_needs(10, minimum_needs)['single'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert result['Toilets'] == 2
def test_arbitrary_needs(self): """custom need ratios calculated are as expected """ minimum_needs = [ parameter.serialize() for parameter in default_minimum_needs() ] minimum_needs[0]['value'] = 4 minimum_needs[1]['value'] = 3 minimum_needs[2]['value'] = 2 minimum_needs[3]['value'] = 1 minimum_needs[4]['value'] = 0.2 result = evacuated_population_needs(10, minimum_needs)['weekly'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert (result['Rice [kg]'] == 40 and result['Drinking Water [l]'] == 30 and result['Clean Water [l]'] == 20 and result['Family Kits'] == 10) result = evacuated_population_needs(10, minimum_needs)['single'] result = OrderedDict([[r['table name'], r['amount']] for r in result]) assert result['Toilets'] == 2
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedPolygonHazardPolygonPeopleFunction', 'name': tr('Classified polygon hazard on polygon people'), 'impact': tr('Be affected'), 'title': tr('Be affected'), 'function_type': 'qgis2.0', 'author': 'Samweli Twesa Mwakisambwe([email protected])', 'date_implemented': '06/08/2015', 'overview': tr( 'To assess the impact of each hazard zone on polygon people.'), 'detailed_description': '', 'hazard_input': tr( 'The hazard layer must be a polygon layer. This layer ' 'must have an attribute representing the hazard ' 'zone that can be specified in the impact function options.'), 'exposure_input': tr( 'Vector polygon layer where each ' 'polygon represents a type of area where people lives.'), 'output': tr( 'A vector layer of areas polygons with each tagged ' 'according to the hazard zone in which it falls.'), 'actions': tr( 'Provide details about how big area fall within ' 'each hazard zone.'), 'limitations': [], 'citations': [ { 'text': None, 'link': None } ], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [ generic_vector_hazard_classes, flood_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_polygon], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [ area_id_field, area_name_field ] } }, 'parameters': OrderedDict([ ('minimum needs', default_minimum_needs())]) } return dict_meta
class ContinuousHazardPopulationImpactFunction(FunctionProvider): # noinspection PyUnresolvedReferences """Plugin for impact of population as derived by continuous hazard. :author AIFDR :rating 2 :param requires category=='hazard' and \ layertype=='raster' and \ data_type=='continuous' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for Continuous Hazard Population Impact Function. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ContinuousHazardPopulationImpactFunction', 'name': tr('Continuous Hazard Population Impact Function'), 'impact': tr('Be impacted'), 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of continuous hazards in raster ' 'format on population raster layer.'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': hazard_all, # already a list 'units': [], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } } } return dict_meta # Function documentation title = tr('Be impacted') synopsis = tr( 'To assess the impacts of continuous hazards in raster format on ' 'population raster layer.') actions = tr( 'Provide details about how many people would likely need to be ' 'impacted for each category.') hazard_input = tr( 'A hazard raster layer where each cell represents the level of the ' 'hazard. The hazard has continuous value of hazard level.') exposure_input = tr( 'An exposure raster layer where each cell represent population count.') output = tr( 'Map of population exposed to high category and a table with number ' 'of people in each category') detailed_description = tr( 'This function will categorised the continuous hazard level into 3 ' 'category based on the threshold that has been input by the user.' 'After that, this function will calculate how many people will be ' 'impacted per category for all categories in the hazard layer.') limitation = tr('The number of categories is three.') # Configurable parameters defaults = get_defaults() parameters = OrderedDict([ ('Categorical thresholds', [0.34, 0.67, 1]), ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) parameters = add_needs_parameters(parameters) def run(self, layers): """Plugin for impact of population as derived by categorised hazard. :param layers: List of layers expected to contain * hazard_layer: Raster layer of categorised hazard * exposure_layer: Raster layer of population data Counts number of people exposed to each category of the hazard :returns: Map of population exposed to high category Table with number of people in each category """ # The 3 category high_t = self.parameters['Categorical thresholds'][2] medium_t = self.parameters['Categorical thresholds'][1] low_t = self.parameters['Categorical thresholds'][0] # Identify hazard and exposure layers hazard_layer = get_hazard_layer(layers) # Categorised Hazard exposure_layer = get_exposure_layer(layers) # Population Raster question = get_question(hazard_layer.get_name(), exposure_layer.get_name(), self) # Extract data as numeric arrays C = hazard_layer.get_data(nan=0.0) # Category # Calculate impact as population exposed to each category P = exposure_layer.get_data(nan=0.0, scaling=True) H = numpy.where(C <= high_t, P, 0) M = numpy.where(C < medium_t, P, 0) L = numpy.where(C < low_t, P, 0) # Count totals total = int(numpy.sum(P)) high = int(numpy.sum(H)) - int(numpy.sum(M)) medium = int(numpy.sum(M)) - int(numpy.sum(L)) low = int(numpy.sum(L)) total_impact = high + medium + low # Don't show digits less than a 1000 total = population_rounding(total) total_impact = population_rounding(total_impact) high = population_rounding(high) medium = population_rounding(medium) low = population_rounding(low) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map table_body = [ question, TableRow([tr('People impacted '), '%s' % format_int(total_impact)], header=True), TableRow( [tr('People in high hazard area '), '%s' % format_int(high)], header=True), TableRow([ tr('People in medium hazard area '), '%s' % format_int(medium) ], header=True), TableRow([tr('People in low hazard area'), '%s' % format_int(low)], header=True) ] impact_table = Table(table_body).toNewlineFreeString() # Extend impact report for on-screen display table_body.extend([ TableRow(tr('Notes'), header=True), tr('Map shows population count in high or medium hazard area'), tr('Total population: %s') % format_int(total), TableRow( tr('Table below shows the minimum needs for all ' 'affected people')) ]) total_needs = evacuated_population_needs(total_impact, minimum_needs) for frequency, needs in total_needs.items(): table_body.append( TableRow([ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append( TableRow([ tr(resource['table name']), format_int(resource['amount']) ])) impact_summary = Table(table_body).toNewlineFreeString() map_title = tr('People in high hazard areas') # Generate 8 equidistant classes across the range of flooded population # 8 is the number of classes in the predefined flood population style # as imported # noinspection PyTypeChecker classes = numpy.linspace(numpy.nanmin(M.flat[:]), numpy.nanmax(M.flat[:]), 8) # Modify labels in existing flood style to show quantities style_classes = style_info['style_classes'] style_classes[1]['label'] = tr('Low [%i people/cell]') % classes[1] style_classes[4]['label'] = tr('Medium [%i people/cell]') % classes[4] style_classes[7]['label'] = tr('High [%i people/cell]') % classes[7] style_info['legend_title'] = tr('Population Count') # Create raster object and return raster_layer = Raster(M, projection=hazard_layer.get_projection(), geotransform=hazard_layer.get_geotransform(), name=tr('Population which %s') % (get_function_title(self).lower()), keywords={ 'impact_summary': impact_summary, 'impact_table': impact_table, 'map_title': map_title, 'total_needs': total_needs }, style_info=style_info) return raster_layer
class ClassifiedHazardPopulationImpactFunction(FunctionProvider): # noinspection PyUnresolvedReferences """Plugin for impact of population as derived by classified hazard. :author ESSC :rating 3 :param requires category=='hazard' and \ layertype=='raster' and \ data_type=='classified' and \ unit=='classes' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for Classified Hazard Population Impact Function. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedHazardPopulationImpactFunction', 'name': tr('Classified Hazard Population Impact Function'), 'impact': tr('Be impacted by each class'), 'author': 'Dianne Bencito', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of classified hazards in raster ' 'format on population raster layer.'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': hazard_all, 'units': [unit_classified], 'layer_constraints': [layer_raster_classified] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } } } return dict_meta # Function documentation title = tr('Be affected by each hazard class') synopsis = tr( 'To assess the impacts of classified hazards in raster format on ' 'population raster layer.') actions = tr( 'Provide details about how many people would likely be affected for ' 'each hazard class.') hazard_input = tr( 'A hazard raster layer where each cell represents the class of the ' 'hazard. There should be 3 classes: e.g. 1, 2, and 3.') exposure_input = tr( 'An exposure raster layer where each cell represent population count.') output = tr( 'Map of population exposed to high class and a table with number ' 'of people in each class') detailed_description = tr( 'This function will use the class from the hazard layer that has been ' 'identified by the user which one is low, medium, or high from the ' 'parameter that user input. After that, this impact function will ' 'calculate the people will be affected per each class for class in ' 'the hazard layer. Finally, it will show the result and the total of ' 'people that will be affected for the hazard given.') limitation = tr('The number of classes is three.') # Configurable parameters defaults = get_defaults() parameters = OrderedDict([ ('low_hazard_class', 1.0), ('medium_hazard_class', 2.0), ('high_hazard_class', 3.0), ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) parameters = add_needs_parameters(parameters) def run(self, layers): """Plugin for impact of population as derived by classified hazard. Input :param layers: List of layers expected to contain * hazard_layer: Raster layer of classified hazard * exposure_layer: Raster layer of population data Counts number of people exposed to each class of the hazard Return Map of population exposed to high class Table with number of people in each class """ # The 3 classes low_t = self.parameters['low_hazard_class'] medium_t = self.parameters['medium_hazard_class'] high_t = self.parameters['high_hazard_class'] # Identify hazard and exposure layers hazard_layer = get_hazard_layer(layers) # Classified Hazard exposure_layer = get_exposure_layer(layers) # Population Raster question = get_question(hazard_layer.get_name(), exposure_layer.get_name(), self) # Extract data as numeric arrays data = hazard_layer.get_data(nan=0.0) # Class # Calculate impact as population exposed to each class population = exposure_layer.get_data(nan=0.0, scaling=True) if high_t == 0: hi = numpy.where(0, population, 0) else: hi = numpy.where(data == high_t, population, 0) if medium_t == 0: med = numpy.where(0, population, 0) else: med = numpy.where(data == medium_t, population, 0) if low_t == 0: lo = numpy.where(0, population, 0) else: lo = numpy.where(data == low_t, population, 0) if high_t == 0: impact = numpy.where((data == low_t) + (data == medium_t), population, 0) elif medium_t == 0: impact = numpy.where((data == low_t) + (data == high_t), population, 0) elif low_t == 0: impact = numpy.where((data == medium_t) + (data == high_t), population, 0) else: impact = numpy.where( (data == low_t) + (data == medium_t) + (data == high_t), population, 0) # Count totals total = int(numpy.sum(population)) high = int(numpy.sum(hi)) medium = int(numpy.sum(med)) low = int(numpy.sum(lo)) total_impact = int(numpy.sum(impact)) # Perform population rounding based on number of people no_impact = population_rounding(total - total_impact) total = population_rounding(total) total_impact = population_rounding(total_impact) high = population_rounding(high) medium = population_rounding(medium) low = population_rounding(low) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map table_body = [ question, TableRow([ tr('Total Population Affected '), '%s' % format_int(total_impact) ], header=True), TableRow([ tr('Population in High hazard class areas '), '%s' % format_int(high) ]), TableRow([ tr('Population in Medium hazard class areas '), '%s' % format_int(medium) ]), TableRow([ tr('Population in Low hazard class areas '), '%s' % format_int(low) ]), TableRow( [tr('Population Not Affected'), '%s' % format_int(no_impact)]), TableRow( tr('Table below shows the minimum needs for all ' 'evacuated people')) ] total_needs = evacuated_population_needs(total_impact, minimum_needs) for frequency, needs in total_needs.items(): table_body.append( TableRow([ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append( TableRow([ tr(resource['table name']), format_int(resource['amount']) ])) impact_table = Table(table_body).toNewlineFreeString() table_body.append(TableRow(tr('Action Checklist:'), header=True)) table_body.append(TableRow(tr('How will warnings be disseminated?'))) table_body.append(TableRow(tr('How will we reach stranded people?'))) table_body.append(TableRow(tr('Do we have enough relief items?'))) table_body.append( TableRow( tr('If yes, where are they located and how will we distribute ' 'them?'))) table_body.append( TableRow( tr('If no, where can we obtain additional relief items from ' 'and how will we transport them to here?'))) # Extend impact report for on-screen display table_body.extend([ TableRow(tr('Notes'), header=True), tr('Map shows the numbers of people in high, medium, and low ' 'hazard class areas'), tr('Total population: %s') % format_int(total) ]) impact_summary = Table(table_body).toNewlineFreeString() # Create style colours = [ '#FFFFFF', '#38A800', '#79C900', '#CEED00', '#FFCC00', '#FF6600', '#FF0000', '#7A0000' ] classes = create_classes(impact.flat[:], len(colours)) interval_classes = humanize_class(classes) style_classes = [] for i in xrange(len(colours)): style_class = dict() if i == 1: label = create_label(interval_classes[i], 'Low') elif i == 4: label = create_label(interval_classes[i], 'Medium') elif i == 7: label = create_label(interval_classes[i], 'High') else: label = create_label(interval_classes[i]) style_class['label'] = label style_class['quantity'] = classes[i] if i == 0: transparency = 30 else: transparency = 30 style_class['transparency'] = transparency style_class['colour'] = colours[i] style_classes.append(style_class) style_info = dict(target_field=None, style_classes=style_classes, style_type='rasterStyle') # For printing map purpose map_title = tr('Population affected by each class') legend_notes = tr('Thousand separator is represented by %s' % get_thousand_separator()) legend_units = tr('(people per cell)') legend_title = tr('Number of People') # Create raster object and return raster_layer = Raster(impact, projection=hazard_layer.get_projection(), geotransform=hazard_layer.get_geotransform(), name=tr('Population which %s') % (get_function_title(self).lower()), keywords={ 'impact_summary': impact_summary, 'impact_table': impact_table, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'total_needs': total_needs }, style_info=style_info) return raster_layer
class TsunamiEvacuationFunction(FunctionProvider): # noinspection PyUnresolvedReferences """Impact function for tsunami evacuation. :author AIFDR :rating 4 :param requires category=='hazard' and \ subcategory=='tsunami' and \ layertype=='raster' and \ unit=='m' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for TsunamiEvacuationFunction. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'TsunamiEvacuationFunction', 'name': tr('Tsunami Evacuation Function'), 'impact': tr('Need evacuation'), 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of tsunami inundation ' 'in raster format on population.'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_tsunami], 'units': [unit_feet_depth, unit_metres_depth], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } } } return dict_meta title = tr('Need evacuation') defaults = get_defaults() # Function documentation synopsis = tr('To assess the impacts of tsunami inundation in raster ' 'format on population.') actions = tr( 'Provide details about how many people would likely need to be ' 'evacuated, where they are located and what resources would be ' 'required to support them.') detailed_description = tr( 'The population subject to inundation exceeding a threshold ' '(default 0.7m) is calculated and returned as a raster layer. In ' 'addition the total number and the required needs in terms of the ' 'BNPB (Perka 7) are reported. The threshold can be changed and even ' 'contain multiple numbers in which case evacuation and needs are ' 'calculated using the largest number with population breakdowns ' 'provided for the smaller numbers. The population raster is resampled ' 'to the resolution of the hazard raster and is rescaled so that the ' 'resampled population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the same ' 'resolution and reflects population count per cell which are affected ' 'by inundation.') hazard_input = tr( 'A hazard raster layer where each cell represents tsunami depth ' '(in meters).') exposure_input = tr( 'An exposure raster layer where each cell represent population count.') output = tr( 'Raster layer contains population affected and the minimum needs ' 'based on the population affected.') limitation = tr( 'The default threshold of 0.7 meter was selected based on consensus, ' 'not hard evidence.') # Configurable parameters # TODO: Share the mimimum needs and make another default value parameters = OrderedDict([ ('thresholds [m]', [0.7]), ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) parameters = add_needs_parameters(parameters) def run(self, layers): """Risk plugin for tsunami population evacuation. :param layers: List of layers expected to contain hazard_layer: Raster layer of tsunami depth exposure_layer: Raster layer of population data on the same grid as hazard_layer Counts number of people exposed to tsunami levels exceeding specified threshold. :returns: Map of population exposed to tsunami levels exceeding the threshold. Table with number of people evacuated and supplies required. :rtype: tuple """ # Identify hazard and exposure layers hazard_layer = get_hazard_layer(layers) # Tsunami inundation [m] exposure_layer = get_exposure_layer(layers) question = get_question(hazard_layer.get_name(), exposure_layer.get_name(), self) # Determine depths above which people are regarded affected [m] # Use thresholds from inundation layer if specified thresholds = self.parameters['thresholds [m]'] verify(isinstance(thresholds, list), 'Expected thresholds to be a list. Got %s' % str(thresholds)) # Extract data as numeric arrays data = hazard_layer.get_data(nan=0.0) # Depth # Calculate impact as population exposed to depths > max threshold population = exposure_layer.get_data(nan=0.0, scaling=True) # Calculate impact to intermediate thresholds counts = [] # merely initialize impact = None for i, lo in enumerate(thresholds): if i == len(thresholds) - 1: # The last threshold impact = medium = numpy.where(data >= lo, population, 0) else: # Intermediate thresholds hi = thresholds[i + 1] medium = numpy.where((data >= lo) * (data < hi), population, 0) # Count val = int(numpy.sum(medium)) # Sensible rounding val, rounding = population_rounding_full(val) counts.append([val, rounding]) # Count totals evacuated, rounding = counts[-1] total = int(numpy.sum(population)) # Don't show digits less than a 1000 total = population_rounding(total) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map # noinspection PyListCreation table_body = [ question, TableRow([(tr('People in %.1f m of water') % thresholds[-1]), '%s*' % format_int(evacuated)], header=True), TableRow( tr('* Number is rounded up to the nearest %s') % rounding), TableRow(tr('Map shows the numbers of people needing evacuation')) ] total_needs = evacuated_population_needs(evacuated, minimum_needs) for frequency, needs in total_needs.items(): table_body.append( TableRow([ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append( TableRow([ tr(resource['table name']), format_int(resource['amount']) ])) table_body.append(TableRow(tr('Action Checklist:'), header=True)) table_body.append(TableRow(tr('How will warnings be disseminated?'))) table_body.append(TableRow(tr('How will we reach stranded people?'))) table_body.append(TableRow(tr('Do we have enough relief items?'))) table_body.append( TableRow( tr('If yes, where are they located and how ' 'will we distribute them?'))) table_body.append( TableRow( tr('If no, where can we obtain additional relief items from and how ' 'will we transport them to here?'))) # Extend impact report for on-screen display table_body.extend([ TableRow(tr('Notes'), header=True), tr('Total population: %s') % format_int(total), tr('People need evacuation if tsunami levels exceed %(eps).1f m') % { 'eps': thresholds[-1] }, tr('Minimum needs are defined in BNPB regulation 7/2008'), tr('All values are rounded up to the nearest integer in order to ' 'avoid representing human lives as fractions.') ]) if len(counts) > 1: table_body.append(TableRow(tr('Detailed breakdown'), header=True)) for i, val in enumerate(counts[:-1]): s = (tr('People in %(lo).1f m to %(hi).1f m of water: %(val)i') % { 'lo': thresholds[i], 'hi': thresholds[i + 1], 'val': format_int(val[0]) }) table_body.append(TableRow(s)) # Result impact_summary = Table(table_body).toNewlineFreeString() impact_table = impact_summary # check for zero impact if numpy.nanmax(impact) == 0 == numpy.nanmin(impact): table_body = [ question, TableRow([(tr('People in %.1f m of water') % thresholds[-1]), '%s' % format_int(evacuated)], header=True) ] my_message = Table(table_body).toNewlineFreeString() raise ZeroImpactException(my_message) # Create style colours = [ '#FFFFFF', '#38A800', '#79C900', '#CEED00', '#FFCC00', '#FF6600', '#FF0000', '#7A0000' ] classes = create_classes(impact.flat[:], len(colours)) interval_classes = humanize_class(classes) style_classes = [] for i in xrange(len(colours)): style_class = dict() if i == 1: label = create_label(interval_classes[i], 'Low') elif i == 4: label = create_label(interval_classes[i], 'Medium') elif i == 7: label = create_label(interval_classes[i], 'High') else: label = create_label(interval_classes[i]) style_class['label'] = label style_class['quantity'] = classes[i] if i == 0: transparency = 100 else: transparency = 0 style_class['transparency'] = transparency style_class['colour'] = colours[i] style_classes.append(style_class) style_info = dict(target_field=None, style_classes=style_classes, style_type='rasterStyle') # For printing map purpose map_title = tr('People in need of evacuation') legend_notes = tr('Thousand separator is represented by %s' % get_thousand_separator()) legend_units = tr('(people per cell)') legend_title = tr('Population') # Create raster object and return raster = Raster(impact, projection=hazard_layer.get_projection(), geotransform=hazard_layer.get_geotransform(), name=tr('Population which %s') % (get_function_title(self).lower()), keywords={ 'impact_summary': impact_summary, 'impact_table': impact_table, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'evacuated': evacuated, 'total_needs': total_needs }, style_info=style_info) return raster
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedPolygonHazardPopulationFunction', 'name': tr('Classified polygon hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'Akbar Gumbira ([email protected])', 'date_implemented': 'N/A', 'hazard_input': tr( 'A hazard vector layer must be a polygon layer that has a ' 'hazard zone attribute.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents ' 'the population count for that cell.'), 'output': tr( 'A vector layer containing polygons matching the hazard areas' 'and an attribute representing the number of people affected ' 'for each area.'), 'actions': tr( 'Provide details about the number of people that are ' 'within each hazard zone.'), 'limitations': [], 'citations': [ { 'text': None, 'link': None } ], 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'overview': tr( 'To assess the number of people that may be impacted by ' 'each hazard zone.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [ generic_vector_hazard_classes ], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { "id": "ClassifiedRasterHazardPopulationFunction", "name": tr("Classified raster hazard on population"), "impact": tr("Be affected by each class"), "title": tr("Be affected by each hazard class"), "function_type": "old-style", "author": "Dianne Bencito", "date_implemented": "N/A", "overview": tr( "To assess the impacts of classified hazards in raster " "format on a population raster layer." ), "detailed_description": tr( "This function will treat the values in the hazard raster " "layer as classes representing low, medium and high " "impact. You need to ensure that the keywords for the hazard " "layer have been set appropriately to define these classes." "The number of people that will be affected will be " "calculated for each class. The report will show the total " "number of people that will be affected for each " "hazard class." ), "hazard_input": tr( "A hazard raster layer where each cell represents the " "class of the hazard. There should be three classes: e.g. " "1, 2, and 3." ), "exposure_input": tr( "An exposure raster layer where each cell represents the" "population count for that cell." ), "output": tr( "Map of population exposed to the highest class and a table " "with the number of people in each class" ), "actions": tr("Provide details about how many people would likely be " "affected for each hazard class."), "limitations": [tr("The number of classes is three.")], "citations": [], "categories": { "hazard": { "definition": hazard_definition, "subcategories": hazard_all, "units": [unit_classified], "layer_constraints": [layer_raster_classified], }, "exposure": { "definition": exposure_definition, "subcategories": [exposure_population], "units": [unit_people_per_pixel], "layer_constraints": [layer_raster_continuous], }, }, "parameters": OrderedDict( [ ("low_hazard_class", 1.0), ("medium_hazard_class", 2.0), ("high_hazard_class", 3.0), ( "postprocessors", OrderedDict( [ ("Gender", default_gender_postprocessor()), ("Age", age_postprocessor()), ("MinimumNeeds", minimum_needs_selector()), ] ), ), ("minimum needs", default_minimum_needs()), ("provenance", default_provenance()), ] ), } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationRasterHazardFunction', 'name': tr('Raster flood on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of flood inundation in raster ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation exceeding a ' 'threshold (default 1m) is calculated and returned as a ' 'raster layer. In addition the total number of affected ' 'people and the required needs based on the user ' 'defined minimum needs are reported. The threshold can be ' 'changed and even contain multiple numbers in which case ' 'evacuation and needs are calculated using the largest number ' 'with population breakdowns provided for the smaller numbers. ' 'The population raster is resampled to the resolution of the ' 'hazard raster and is rescaled so that the resampled ' 'population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the ' 'same resolution and reflects population count per cell ' 'which are affected by inundation.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents flood ' 'depth (in meters).'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Raster layer contains population affected and the minimum ' 'needs based on number of the population affected.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [ tr('The default threshold of 1 meter was selected based ' 'on consensus, not hard evidence.') ], 'citations': [ { 'text': None, 'link': None } ], 'map_title': tr('People in need of evacuation'), 'legend_title': tr('Population Count'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_name': tr('Population which need evacuation'), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_flood], 'continuous_hazard_units': [unit_feet, unit_metres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('thresholds', threshold()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'TsunamiEvacuationFunction', 'name': tr('Tsunami evacuation'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of tsunami inundation in raster ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation exceeding a ' 'threshold (default 0.7m) is calculated and returned as ' 'a raster layer. In addition the total number and the ' 'required needs in terms of the BNPB (Perka 7) are ' 'reported. The threshold can be changed and even contain ' 'multiple numbers in which case evacuation and needs are ' 'calculated using the largest number with population ' 'breakdowns provided for the smaller numbers. The ' 'population raster is resampled to the resolution of the ' 'hazard raster and is rescaled so that the resampled ' 'population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the ' 'same resolution and reflects population count per cell ' 'which are affected by inundation.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents tsunami ' 'depth (in meters).'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Raster layer contains population affected and the minimum ' 'needs based on number of the population affected.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [tr( 'The default threshold of 0.7 meter was selected based on ' 'consensus, not hard evidence.')], 'citations': [ tr('Papadopoulos, Gerassimos A., and Fumihiko Imamura. ' '"A proposal for a new tsunami intensity scale." ' 'ITS 2001 proceedings, no. 5-1, pp. 569-577. 2001.'), tr('Hamza Latief. pers com. Default impact threshold for ' 'tsunami impact on people should be 0.7m. This is less ' 'than a flood threshold because in a tsunami, the water is ' 'moving with force.'), ], 'map_title': tr('People in need of evacuation'), 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_name': tr('Population which need evacuation'), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_tsunami], 'continuous_hazard_units': [unit_feet, unit_metres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('thresholds', threshold()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'PAGFatalityFunction', 'name': tr('Earthquake PAGER fatality function'), 'impact': tr('Die or be displaced according Pager model'), 'title': tr('Die or be displaced according Pager model'), 'function_type': 'old-style', 'author': 'Helen Crowley', 'date_implemented': 'N/A', 'overview': tr( 'Estimates the number of fatalities resulting from an ' 'earthquake. Uses data from a global database of earthquake ' 'events to calculate fatality rates. Based on the ' 'Population Vulnerability PAGER Model.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'citations': [ { 'text': tr( 'Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). ' 'Estimating casualties for large worldwide ' 'earthquakes using an empirical approach. U.S. ' 'Geological Survey Open-File Report 2009-1136.'), 'link': None } ], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPointPopulationFunction', 'name': tr('Point volcano on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr('A point vector layer.'), 'exposure_input': tr('An exposure raster layer where each cell represent ' 'population count.'), 'output': tr('Vector layer contains people affected and the minimum ' 'needs based on the number of people affected.'), 'actions': tr('Provide details about how many people would likely ' 'be affected by each hazard zone.'), 'limitations': [], 'citations': [{ 'text': None, 'link': None }], 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr('Thousand separator is represented by %s' % get_thousand_separator()), 'overview': tr('To assess the impacts of volcano eruption on ' 'population.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_point], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': [hazard_volcano], 'continuous_hazard_units': [], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [volcano_name_field] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ # The radii ('distances', distance()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationVectorHazardFunction', 'name': tr('Polygon flood on people'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of flood inundation in vector ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation is determined by ' 'whether they are in a flood affected area or not. You can ' 'also set an evacuation percentage to calculate what ' 'percentage of the affected population should be ' 'evacuated. This number will be used to estimate needs ' 'based on the user defined minimum needs file.'), 'hazard_input': tr( 'A hazard vector layer which has an affected attribute. If ' 'it does not have that attribute, all polygons will be ' 'considered as affected.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count.'), 'output': tr( 'A vector layer containing the number of people affected ' 'per flood area and the minimum needs based on ' 'evacuation percentage.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [], 'citations': [], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_flood], 'continuous_hazard_units': [], 'vector_hazard_classifications': [ flood_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ # Percent of affected needing evacuation ('evacuation_percentage', parameter_definitions.evacuation_percentage()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonPopulationFunction', 'name': tr('Polygon volcano on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'The hazard layer must be a polygon layer. This layer ' 'must have an attribute representing the volcano hazard ' 'zone that can be specified in the impact function option. ' 'There are three classes low, medium, and high. The default ' 'values are "Kawasan Rawan Bencana I" for low, "Kawasan Rawan ' 'Bencana II" for medium, and "Kawasan Rawan Bencana III for ' 'high." If you want to see the name of the volcano in the ' 'result, you need to specify the volcano name attribute in ' 'the Impact Function options.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count for that cell.'), 'output': tr( 'A vector layer containing people affected per hazard zone ' 'and the minimum needs based on the number of people ' 'affected.'), 'actions': tr( 'Provide details about the number of people that are within ' 'each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr( 'To assess the impact of a volcano eruption on people.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': [hazard_volcano], 'continuous_hazard_units': [], 'vector_hazard_classifications': [ volcano_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [ volcano_name_field] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedPolygonHazardPopulationFunction', 'name': tr('Classified polygon hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'Akbar Gumbira ([email protected])', 'date_implemented': 'N/A', 'hazard_input': tr('A hazard vector layer must be a polygon layer that has a ' 'hazard zone attribute.'), 'exposure_input': tr('An exposure raster layer where each cell represents ' 'the population count for that cell.'), 'output': tr('A vector layer containing polygons matching the hazard areas' 'and an attribute representing the number of people affected ' 'for each area.'), 'actions': tr('Provide details about the number of people that are ' 'within each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr('To assess the number of people that may be impacted by ' 'each hazard zone.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [generic_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationRasterHazardFunction', 'name': tr('Raster flood on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of flood inundation in raster ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation exceeding a ' 'threshold (default 1m) is calculated and returned as a ' 'raster layer. In addition the total number of affected ' 'people and the required needs based on the user ' 'defined minimum needs are reported. The threshold can be ' 'changed and even contain multiple numbers in which case ' 'evacuation and needs are calculated using the largest number ' 'with population breakdowns provided for the smaller numbers. ' 'The population raster is resampled to the resolution of the ' 'hazard raster and is rescaled so that the resampled ' 'population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the ' 'same resolution and reflects population count per cell ' 'which are affected by inundation.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents flood ' 'depth (in meters).'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Raster layer contains population affected and the minimum ' 'needs based on number of the population affected.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [ tr('The default threshold of 1 meter was selected based ' 'on consensus, not hard evidence.') ], 'citations': [ { 'text': None, 'link': None } ], 'legend_title': tr('Population Count'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_flood], 'continuous_hazard_units': [unit_feet, unit_metres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('thresholds', threshold()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonPopulationFunction', 'name': tr('Polygon volcano on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'The hazard layer must be a polygon layer. This layer ' 'must have an attribute representing the volcano hazard ' 'zone that can be specified in the impact function option. ' 'There are three classes low, medium, and high. The default ' 'values are "Kawasan Rawan Bencana I" for low, "Kawasan Rawan ' 'Bencana II" for medium, and "Kawasan Rawan Bencana III for ' 'high." If you want to see the name of the volcano in the ' 'result, you need to specify the volcano name attribute in ' 'the Impact Function options.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count for that cell.'), 'output': tr( 'A vector layer containing people affected per hazard zone ' 'and the minimum needs based on the number of people ' 'affected.'), 'actions': tr( 'Provide details about the number of people that are within ' 'each hazard zone.'), 'limitations': [], 'citations': [ { 'text': None, 'link': None } ], 'map_title': tr('People affected by Volcano Hazard Zones'), 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_name': tr('People affected by volcano hazard zones'), 'overview': tr( 'To assess the impact of a volcano eruption on people.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': [hazard_volcano], 'continuous_hazard_units': [], 'vector_hazard_classifications': [ volcano_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [ volcano_name_field] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ITBBayesianFatalityFunction', 'name': tr('Earthquake ITB fatality function based on a Bayesian ' 'approach'), 'impact': tr('Die or be displaced according ITB bayesian model'), 'title': tr('Die or be displaced according ITB bayesian model'), 'function_type': 'old-style', 'author': 'ITB and GA', # FIXME 'date_implemented': 'N/A', 'overview': tr('To assess the impact of an earthquake on population based ' 'on the Population Vulnerability ITB bayesian Model.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'citations': [ tr('Sengara, W., Suarjana, M., Yulman, M.A., Ghasemi, H., and ' 'Ryu, H. (2015). ' 'An empirical fatality model for Indonesia based on ' 'a Bayesian approach. Submitted for Journal of the ' 'Geological Society') # FIXME ], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [hazard_category_single_event], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPointPopulationFunction', 'name': tr('Point volcano on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'A point vector layer.'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Vector layer contains people affected and the minimum ' 'needs based on the number of people affected.'), 'actions': tr( 'Provide details about how many people would likely ' 'be affected by each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr( 'To assess the impacts of volcano eruption on ' 'population.'), 'detailed_description': '', 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_volcano], 'units': [unit_volcano_categorical], 'layer_constraints': [ layer_vector_point ] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # The radii ('distance [km]', [3, 5, 10]), # The attribute for name of the volcano in hazard layer ('volcano name attribute', 'NAME'), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ContinuousHazardPopulationFunction', 'name': tr('Continuous raster hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of continuous hazards in raster ' 'format on population raster layer.'), 'detailed_description': tr( 'This function will categorised the continuous hazard ' 'level into 3 category based on the threshold that has ' 'been input by the user. After that, this function will ' 'calculate how many people will be impacted per category ' 'for all categories in the hazard layer.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents the ' 'level of the hazard. The hazard has continuous value of ' 'hazard level.'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Map of population exposed to high category and a table ' 'with number of people in each category'), 'actions': tr( 'Provide details about how many people would likely ' 'be impacted in each category.'), 'limitations': [tr('Only three categories can be used.')], 'citations': [], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [unit_generic], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [ count_exposure_unit, density_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, # Configurable parameters 'parameters': OrderedDict([ ('Categorical thresholds', categorical_thresholds()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ITBFatalityFunction', 'name': tr('Earthquake ITB fatality function'), 'impact': tr('Die or be displaced'), 'title': tr('Die or be displaced'), 'function_type': 'old-style', 'author': 'Hadi Ghasemi', 'date_implemented': 'N/A', 'overview': tr('To assess the impact of earthquake on population based ' 'on the earthquake model for Indonesia developed by ITB.'), 'detailed_description': tr('This model was developed by Institut Teknologi Bandung ' '(ITB) and implemented by Dr. Hadi Ghasemi, Geoscience ' 'Australia\n' 'Algorithm:\n' 'In this study, the same functional form as Allen (2009) ' 'is adopted o express fatality rate as a function of ' 'intensity (see Eq. 10 in the report). The Matlab ' 'built-in function (fminsearch) for Nelder-Mead algorithm ' 'was used to estimate the model parameters. The objective ' 'function (L2G norm) that is minimized during the ' 'optimisation is the same as the one used by Jaiswal ' 'et al. (2010).\n' 'The coefficients used in the indonesian model are ' 'x=0.62275231, y=8.03314466, zeta=2.15'), 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': tr('Provide details about the population including ' 'estimates for mortalities and displaced persons.'), 'limitations': [ tr('The model is based on a limited number of observed ' 'fatality rates during four previous fatal events.'), tr('The model clearly over-predicts the fatality rates at ' 'intensities higher than VIII.'), tr('The model only estimates the expected fatality rate ' 'for a given intensity level. The associated ' 'uncertainty for the proposed model is not addressed.'), tr('There are few known issues in the current model:\n\n' '* rounding MMI values to the nearest 0.5,\n' '* Implemention of Finite-Fault models of candidate ' ' events, and\n' '* consistency between selected GMPEs with those in ' ' use by BMKG.\n') ], 'citations': [ tr('Indonesian Earthquake Building-Damage and Fatality ' 'Models and Post Disaster Survey Guidelines ' 'Development Bali, 27-28 February 2012, 54pp.'), tr('Allen, T. I., Wald, D. J., Earle, P. S., Marano, K. ' 'D., Hotovec, A. J., Lin, K., and Hearne, M., 2009. An ' 'Atlas of ShakeMaps and population exposure catalog ' 'for earthquake loss modeling, Bull. Earthq. Eng. 7, ' '701-718.'), tr('Jaiswal, K., and Wald, D., 2010. An empirical model ' 'for global earthquake fatality estimation, Earthq. ' 'Spectra 26, 1017-1037.') ], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonPopulationFunction', 'name': tr('Polygon volcano on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr('The hazard vector layer must be a polygon that has a ' 'specific hazard zone attribute.'), 'exposure_input': tr('An exposure raster layer where each cell represents a ' 'population count for that cell.'), 'output': tr('A vector layer containing people affected per hazard zone ' 'and the minimum needs based on the number of people ' 'affected.'), 'actions': tr('Provide details about the number of people that are within ' 'each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr('To assess the impact of a volcano eruption on people.'), 'detailed_description': '', 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_volcano], 'units': [unit_volcano_categorical], 'layer_constraints': [layer_vector_polygon] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # The attribute of hazard zone in hazard layer ('hazard zone attribute', 'KRB'), # The attribute for name of the volcano in hazard layer ('volcano name attribute', 'NAME'), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
class ITBFatalityFunction(FunctionProvider): # noinspection PyUnresolvedReferences """Indonesian Earthquake Fatality Model. This model was developed by Institut Teknologi Bandung (ITB) and implemented by Dr. Hadi Ghasemi, Geoscience Australia. Reference: Indonesian Earthquake Building-Damage and Fatality Models and Post Disaster Survey Guidelines Development, Bali, 27-28 February 2012, 54pp. Algorithm: In this study, the same functional form as Allen (2009) is adopted to express fatality rate as a function of intensity (see Eq. 10 in the report). The Matlab built-in function (fminsearch) for Nelder-Mead algorithm was used to estimate the model parameters. The objective function (L2G norm) that is minimised during the optimisation is the same as the one used by Jaiswal et al. (2010). The coefficients used in the indonesian model are x=0.62275231, y=8.03314466, zeta=2.15 Allen, T. I., Wald, D. J., Earle, P. S., Marano, K. D., Hotovec, A. J., Lin, K., and Hearne, M., 2009. An Atlas of ShakeMaps and population exposure catalog for earthquake loss modeling, Bull. Earthq. Eng. 7, 701-718. Jaiswal, K., and Wald, D., 2010. An empirical model for global earthquake fatality estimation, Earthq. Spectra 26, 1017-1037. Caveats and limitations: The current model is the result of the above mentioned workshop and reflects the best available information. However, the current model has a number of issues listed below and is expected to evolve further over time. 1 - The model is based on limited number of observed fatality rates during 4 past fatal events. 2 - The model clearly over-predicts the fatality rates at intensities higher than VIII. 3 - The model only estimates the expected fatality rate for a given intensity level; however the associated uncertainty for the proposed model is not addressed. 4 - There are few known mistakes in developing the current model: - rounding MMI values to the nearest 0.5, - Implementing Finite-Fault models of candidate events, and - consistency between selected GMPEs with those in use by BMKG. These issues will be addressed by ITB team in the final report. Note: Because of these caveats, decisions should not be made solely on the information presented here and should always be verified by ground truthing and other reliable information sources. :author Hadi Ghasemi :rating 3 :param requires category=='hazard' and \ subcategory=='earthquake' and \ layertype=='raster' and \ unit=='MMI' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for ITB Fatality function. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ITBFatalityFunction', 'name': tr('ITB Fatality Function'), 'impact': tr('Die or be displaced'), 'author': 'Hadi Ghasemi', 'date_implemented': 'N/A', 'overview': tr('To assess the impact of earthquake on population based ' 'on earthquake model developed by ITB'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_earthquake], 'units': [unit_mmi], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } } } return dict_meta title = tr('Die or be displaced') synopsis = tr( 'To assess the impact of earthquake on population based on earthquake ' 'model developed by ITB') citations = tr( ' * Indonesian Earthquake Building-Damage and Fatality Models and ' ' Post Disaster Survey Guidelines Development Bali, 27-28 ' ' February 2012, 54pp.\n' ' * Allen, T. I., Wald, D. J., Earle, P. S., Marano, K. D., ' ' Hotovec, A. J., Lin, K., and Hearne, M., 2009. An Atlas ' ' of ShakeMaps and population exposure catalog for ' ' earthquake loss modeling, Bull. Earthq. Eng. 7, 701-718.\n' ' * Jaiswal, K., and Wald, D., 2010. An empirical model for ' ' global earthquake fatality estimation, Earthq. Spectra ' ' 26, 1017-1037.\n') limitation = tr( ' - The model is based on limited number of observed fatality ' ' rates during 4 past fatal events. \n' ' - The model clearly over-predicts the fatality rates at ' ' intensities higher than VIII.\n' ' - The model only estimates the expected fatality rate ' ' for a given intensity level; however the associated ' ' uncertainty for the proposed model is not addressed.\n' ' - There are few known mistakes in developing the current ' ' model:\n\n' ' * rounding MMI values to the nearest 0.5,\n' ' * Implementing Finite-Fault models of candidate events, and\n' ' * consistency between selected GMPEs with those in use by ' ' BMKG.\n') actions = tr( 'Provide details about the population will be die or displaced') detailed_description = tr( 'This model was developed by Institut Teknologi Bandung (ITB) ' 'and implemented by Dr. Hadi Ghasemi, Geoscience Australia\n' 'Algorithm:\n' 'In this study, the same functional form as Allen (2009) is ' 'adopted o express fatality rate as a function of intensity ' '(see Eq. 10 in the report). The Matlab built-in function ' '(fminsearch) for Nelder-Mead algorithm was used to estimate ' 'the model parameters. The objective function (L2G norm) that ' 'is minimized during the optimisation is the same as the one ' 'used by Jaiswal et al. (2010).\n' 'The coefficients used in the indonesian model are x=0.62275231, ' 'y=8.03314466, zeta=2.15') defaults = get_defaults() parameters = OrderedDict([ ('x', 0.62275231), ('y', 8.03314466), # Model coefficients # Rates of people displaced for each MMI level ('displacement_rate', { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 1.0, 7: 1.0, 8: 1.0, 9: 1.0, 10: 1.0 }), ('mmi_range', range(2, 10)), ('step', 0.5), # Threshold below which layer should be transparent ('tolerance', 0.01), ('calculate_displaced_people', True), ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }) ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) parameters = add_needs_parameters(parameters) def fatality_rate(self, mmi): """ITB method to compute fatality rate. :param mmi: """ # As per email discussion with Ole, Trevor, Hadi, mmi < 4 will have # a fatality rate of 0 - Tim if mmi < 4: return 0 x = self.parameters['x'] y = self.parameters['y'] # noinspection PyUnresolvedReferences return numpy.power(10.0, x * mmi - y) def run(self, layers): """Indonesian Earthquake Fatality Model. Input: :param layers: List of layers expected to contain, hazard: Raster layer of MMI ground shaking exposure: Raster layer of population count """ displacement_rate = self.parameters['displacement_rate'] # Tolerance for transparency tolerance = self.parameters['tolerance'] # Extract input layers intensity = get_hazard_layer(layers) population = get_exposure_layer(layers) question = get_question(intensity.get_name(), population.get_name(), self) # Extract data grids hazard = intensity.get_data() # Ground Shaking exposure = population.get_data(scaling=True) # Population Density # Calculate people affected by each MMI level # FIXME (Ole): this range is 2-9. Should 10 be included? mmi_range = self.parameters['mmi_range'] number_of_exposed = {} number_of_displaced = {} number_of_fatalities = {} # Calculate fatality rates for observed Intensity values (hazard # based on ITB power model mask = numpy.zeros(hazard.shape) for mmi in mmi_range: # Identify cells where MMI is in class i and # count people affected by this shake level mmi_matches = numpy.where( (hazard > mmi - self.parameters['step']) * (hazard <= mmi + self.parameters['step']), exposure, 0) # Calculate expected number of fatalities per level fatality_rate = self.fatality_rate(mmi) fatalities = fatality_rate * mmi_matches # Calculate expected number of displaced people per level try: displacements = displacement_rate[mmi] * mmi_matches except KeyError, e: msg = 'mmi = %i, mmi_matches = %s, Error msg: %s' % ( mmi, str(mmi_matches), str(e)) # noinspection PyExceptionInherit raise InaSAFEError(msg) # Adjust displaced people to disregard fatalities. # Set to zero if there are more fatalities than displaced. displacements = numpy.where(displacements > fatalities, displacements - fatalities, 0) # Sum up numbers for map mask += displacements # Displaced # Generate text with result for this study # This is what is used in the real time system exposure table number_of_exposed[mmi] = numpy.nansum(mmi_matches.flat) number_of_displaced[mmi] = numpy.nansum(displacements.flat) # noinspection PyUnresolvedReferences number_of_fatalities[mmi] = numpy.nansum(fatalities.flat) # Set resulting layer to NaN when less than a threshold. This is to # achieve transparency (see issue #126). mask[mask < tolerance] = numpy.nan # Total statistics total, rounding = population_rounding_full(numpy.nansum(exposure.flat)) # Compute number of fatalities fatalities = population_rounding( numpy.nansum(number_of_fatalities.values())) # As per email discussion with Ole, Trevor, Hadi, total fatalities < 50 # will be rounded down to 0 - Tim if fatalities < 50: fatalities = 0 # Compute number of people displaced due to building collapse displaced = population_rounding( numpy.nansum(number_of_displaced.values())) # Generate impact report table_body = [question] # Add total fatality estimate s = format_int(fatalities) table_body.append( TableRow([tr('Number of fatalities'), s], header=True)) if self.parameters['calculate_displaced_people']: # Add total estimate of people displaced s = format_int(displaced) table_body.append( TableRow([tr('Number of people displaced'), s], header=True)) else: displaced = 0 # Add estimate of total population in area s = format_int(int(total)) table_body.append( TableRow([tr('Total number of people'), s], header=True)) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map table_body = [ question, TableRow([tr('Fatalities'), '%s' % format_int(fatalities)], header=True), TableRow([tr('People displaced'), '%s' % format_int(displaced)], header=True), TableRow(tr('Map shows the estimation of displaced population')) ] total_needs = evacuated_population_needs(displaced, minimum_needs) for frequency, needs in total_needs.items(): table_body.append( TableRow([ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append( TableRow([ tr(resource['table name']), format_int(resource['amount']) ])) table_body.append(TableRow(tr('Provenance'), header=True)) table_body.append(TableRow(self.parameters['provenance'])) table_body.append(TableRow(tr('Action Checklist:'), header=True)) if fatalities > 0: table_body.append( tr('Are there enough victim identification ' 'units available for %s people?') % format_int(fatalities)) if displaced > 0: table_body.append( tr('Are there enough shelters and relief items ' 'available for %s people?') % format_int(displaced)) table_body.append( TableRow( tr('If yes, where are they located and ' 'how will we distribute them?'))) table_body.append( TableRow( tr('If no, where can we obtain ' 'additional relief items from and ' 'how will we transport them?'))) # Extend impact report for on-screen display table_body.extend([ TableRow(tr('Notes'), header=True), tr('Total population: %s') % format_int(total), tr('People are considered to be displaced if ' 'they experience and survive a shake level' 'of more than 5 on the MMI scale '), tr('Minimum needs are defined in BNPB ' 'regulation 7/2008'), tr('The fatality calculation assumes that ' 'no fatalities occur for shake levels below 4 ' 'and fatality counts of less than 50 are ' 'disregarded.'), tr('All values are rounded up to the nearest ' 'integer in order to avoid representing human ' 'lives as fractions.') ]) table_body.append(TableRow(tr('Notes'), header=True)) table_body.append( tr('Fatality model is from ' 'Institute of Teknologi Bandung 2012.')) table_body.append( tr('Population numbers rounded up to the nearest %s.') % rounding) # Result impact_summary = Table(table_body).toNewlineFreeString() impact_table = impact_summary # check for zero impact if numpy.nanmax(mask) == 0 == numpy.nanmin(mask): table_body = [ question, TableRow([tr('Fatalities'), '%s' % format_int(fatalities)], header=True) ] my_message = Table(table_body).toNewlineFreeString() raise ZeroImpactException(my_message) # Create style colours = ['#EEFFEE', '#FFFF7F', '#E15500', '#E4001B', '#730000'] classes = create_classes(mask.flat[:], len(colours)) interval_classes = humanize_class(classes) style_classes = [] for i in xrange(len(colours)): style_class = dict() style_class['label'] = create_label(interval_classes[i]) style_class['quantity'] = classes[i] if i == 0: transparency = 100 else: transparency = 30 style_class['transparency'] = transparency style_class['colour'] = colours[i] style_classes.append(style_class) style_info = dict(target_field=None, style_classes=style_classes, style_type='rasterStyle') # For printing map purpose map_title = tr('Earthquake impact to population') legend_notes = tr('Thousand separator is represented by %s' % get_thousand_separator()) legend_units = tr('(people per cell)') legend_title = tr('Population Count') # Create raster object and return raster = Raster(mask, projection=population.get_projection(), geotransform=population.get_geotransform(), keywords={ 'impact_summary': impact_summary, 'total_population': total, 'total_fatalities': fatalities, 'fatalities_per_mmi': number_of_fatalities, 'exposed_per_mmi': number_of_exposed, 'displaced_per_mmi': number_of_displaced, 'impact_table': impact_table, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'total_needs': total_needs }, name=tr('Estimated displaced population per cell'), style_info=style_info) return raster
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'TsunamiEvacuationFunction', 'name': tr('Tsunami evacuation'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of tsunami inundation in raster ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation exceeding a ' 'threshold (default 0.7m) is calculated and returned as ' 'a raster layer. In addition the total number and the ' 'required needs in terms of the BNPB (Perka 7) are ' 'reported. The threshold can be changed and even contain ' 'multiple numbers in which case evacuation and needs are ' 'calculated using the largest number with population ' 'breakdowns provided for the smaller numbers. The ' 'population raster is resampled to the resolution of the ' 'hazard raster and is rescaled so that the resampled ' 'population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the ' 'same resolution and reflects population count per cell ' 'which are affected by inundation.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents tsunami ' 'depth (in meters).'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Raster layer contains population affected and the ' 'minimum needs based on the population affected.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [tr( 'The default threshold of 0.7 meter was selected based on ' 'consensus, not hard evidence.')], 'citations': [], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_tsunami], 'units': [ unit_feet_depth, unit_metres_depth ], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ ('thresholds [m]', [0.7]), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ContinuousHazardPopulationFunction', 'name': tr('Continuous raster hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of continuous hazards in raster ' 'format on population raster layer.'), 'detailed_description': tr( 'This function will categorised the continuous hazard ' 'level into 3 category based on the threshold that has ' 'been input by the user. After that, this function will ' 'calculate how many people will be impacted per category ' 'for all categories in the hazard layer.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents the ' 'level of the hazard. The hazard has continuous value of ' 'hazard level.'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Map of population exposed to high category and a table ' 'with number of people in each category'), 'actions': tr( 'Provide details about how many people would likely ' 'be impacted in each category.'), 'limitations': [tr('Only three categories can be used.')], 'citations': [], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': hazard_all, # already a list 'units': [], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, # Configurable parameters 'parameters': OrderedDict([ ('Categorical thresholds', [0.34, 0.67, 1]), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'PAGFatalityFunction', 'name': tr('Earthquake PAGER fatality function'), 'impact': tr('Die or be displaced according Pager model'), 'title': tr('Die or be displaced according Pager model'), 'function_type': 'old-style', 'author': 'Helen Crowley', 'date_implemented': 'N/A', 'overview': tr('Estimates the number of fatalities resulting from an ' 'earthquake. Uses data from a global database of earthquake ' 'events to calculate fatality rates. Based on the ' 'Population Vulnerability PAGER Model.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'citations': [{ 'text': tr('Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). ' 'Estimating casualties for large worldwide ' 'earthquakes using an empirical approach. U.S. ' 'Geological Survey Open-File Report 2009-1136.'), 'link': None }], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { "id": "VolcanoPolygonPopulationFunction", "name": tr("Polygon volcano on population"), "impact": tr("Need evacuation"), "title": tr("Need evacuation"), "function_type": "old-style", "author": "AIFDR", "date_implemented": "N/A", "hazard_input": tr( "The hazard layer must be a polygon layer. This layer " "must have an attribute representing the volcano hazard " "zone that can be specified in the impact function option. " "There are three classes low, medium, and high. The default " 'values are "Kawasan Rawan Bencana I" for low, "Kawasan Rawan ' 'Bencana II" for medium, and "Kawasan Rawan Bencana III for ' 'high." If you want to see the name of the volcano in the ' "result, you need to specify the volcano name attribute in " "the Impact Function options." ), "exposure_input": tr( "An exposure raster layer where each cell represents a " "population count for that cell." ), "output": tr( "A vector layer containing people affected per hazard zone " "and the minimum needs based on the number of people " "affected." ), "actions": tr("Provide details about the number of people that are within " "each hazard zone."), "limitations": [], "citations": [{"text": None, "link": None}], "legend_title": tr("Population"), "legend_units": tr("(people per cell)"), "legend_notes": tr("Thousand separator is represented by %s" % get_thousand_separator()), "overview": tr("To assess the impact of a volcano eruption on people."), "detailed_description": "", "layer_requirements": { "hazard": { "layer_mode": layer_mode_classified, "layer_geometries": [layer_geometry_polygon], "hazard_categories": [hazard_category_multiple_event, hazard_category_single_event], "hazard_types": [hazard_volcano], "continuous_hazard_units": [], "vector_hazard_classifications": [volcano_vector_hazard_classes], "raster_hazard_classifications": [], "additional_keywords": [volcano_name_field], }, "exposure": { "layer_mode": layer_mode_continuous, "layer_geometries": [layer_geometry_raster], "exposure_types": [exposure_population], "exposure_units": [count_exposure_unit], "exposure_class_fields": [], "additional_keywords": [], }, }, "parameters": OrderedDict( [ ( "postprocessors", OrderedDict( [ ("Gender", default_gender_postprocessor()), ("Age", age_postprocessor()), ("MinimumNeeds", minimum_needs_selector()), ] ), ), ("minimum needs", default_minimum_needs()), ] ), } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationVectorHazardFunction', 'name': tr('Polygon flood on people'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of flood inundation in vector ' 'format on population.'), 'detailed_description': tr('The population subject to inundation is determined by ' 'whether they are in a flood affected area or not. You can ' 'also set an evacuation percentage to calculate what ' 'percentage of the affected population should be ' 'evacuated. This number will be used to estimate needs ' 'based on the user defined minimum needs file.'), 'hazard_input': tr('A hazard vector layer which has an affected attribute. If ' 'it does not have that attribute, all polygons will be ' 'considered as affected.'), 'exposure_input': tr('An exposure raster layer where each cell represents a ' 'population count.'), 'output': tr('A vector layer containing the number of people affected ' 'per flood area and the minimum needs based on ' 'evacuation percentage.'), 'actions': tr('Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [], 'citations': [], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_flood], 'units': [unit_wetdry, unit_metres_depth, unit_feet_depth], 'layer_constraints': [layer_vector_polygon] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # This field of the hazard layer contains information # about inundated areas ('affected_field', 'FLOODPRONE'), # This value in 'affected_field' of the hazard layer # marks the areas as inundated ('affected_value', 'YES'), # Percent of affected needing evacuation ('evacuation_percentage', 1), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ContinuousHazardPopulationFunction', 'name': tr('Continuous raster hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of continuous hazards in raster ' 'format on population raster layer.'), 'detailed_description': tr('This function will categorised the continuous hazard ' 'level into 3 category based on the threshold that has ' 'been input by the user. After that, this function will ' 'calculate how many people will be impacted per category ' 'for all categories in the hazard layer.'), 'hazard_input': tr('A hazard raster layer where each cell represents the ' 'level of the hazard. The hazard has continuous value of ' 'hazard level.'), 'exposure_input': tr('An exposure raster layer where each cell represent ' 'population count.'), 'output': tr('Map of population exposed to high category and a table ' 'with number of people in each category'), 'actions': tr('Provide details about how many people would likely ' 'be impacted in each category.'), 'limitations': [tr('Only three categories can be used.')], 'citations': [{ 'text': None, 'link': None }], 'legend_title': tr('Number of People'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr('Thousand separator is represented by %s' % get_thousand_separator()), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [unit_generic], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit, density_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, # Configurable parameters 'parameters': OrderedDict([('Categorical thresholds', categorical_thresholds()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedRasterHazardPopulationFunction', 'name': tr('Classified raster hazard on population'), 'impact': tr('Be affected'), 'title': tr('Be affected'), 'function_type': 'old-style', 'author': 'Dianne Bencito', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of classified hazards in raster ' 'format on a population raster layer.'), 'detailed_description': tr('This function will treat the values in the hazard raster ' 'layer as classes representing low, medium and high ' 'impact. You need to ensure that the keywords for the hazard ' 'layer have been set appropriately to define these classes.' 'The number of people that will be affected will be ' 'calculated for each class. The report will show the total ' 'number of people that will be affected for each ' 'hazard class.'), 'hazard_input': tr('A hazard raster layer where each cell represents the ' 'class of the hazard. There should be three classes: e.g. ' '1, 2, and 3.'), 'exposure_input': tr('An exposure raster layer where each cell represents the ' 'population count for that cell.'), 'output': tr('Map of population exposed to the highest class and a table ' 'with the number of people in each class'), 'actions': tr('Provide details about how many people would likely be ' 'affected for each hazard class.'), 'limitations': [tr('The number of classes is three.')], 'citations': [{ 'text': None, 'link': None }], 'legend_title': tr('Number of People'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr('Thousand separator is represented by %s' % get_thousand_separator()), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [generic_raster_hazard_classes], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit, density_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('Categorical hazards', categorical_hazards()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationVectorHazardFunction', 'name': tr('Polygon flood on people'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of flood inundation in vector ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation is determined by ' 'whether they are in a flood affected area or not. You can ' 'also set an evacuation percentage to calculate what ' 'percentage of the affected population should be ' 'evacuated. This number will be used to estimate needs ' 'based on the user defined minimum needs file.'), 'hazard_input': tr( 'A hazard vector layer which has an affected attribute. If ' 'it does not have that attribute, all polygons will be ' 'considered as affected.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count.'), 'output': tr( 'A vector layer containing the number of people affected ' 'per flood area and the minimum needs based on ' 'evacuation percentage.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [], 'citations': [], 'map_title': tr('People affected by flood prone areas'), 'legend_title': tr('Population Count'), 'legend_units': tr('(people per polygon)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_name': tr('People affected by flood prone areas'), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_flood], 'continuous_hazard_units': [], 'vector_hazard_classifications': [ flood_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ # Percent of affected needing evacuation ('evacuation_percentage', parameter_definitions.evacuation_percentage()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedRasterHazardPopulationFunction', 'name': tr('Classified raster hazard on population'), 'impact': tr('Be affected by each class'), 'title': tr('Be affected by each hazard class'), 'function_type': 'old-style', 'author': 'Dianne Bencito', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of classified hazards in raster ' 'format on a population raster layer.'), 'detailed_description': tr('This function will treat the values in the hazard raster ' 'layer as classes representing low, medium and high ' 'impact. You need to ensure that the keywords for the hazard ' 'layer have been set appropriately to define these classes.' 'The number of people that will be affected will be ' 'calculated for each class. The report will show the total ' 'number of people that will be affected for each ' 'hazard class.'), 'hazard_input': tr('A hazard raster layer where each cell represents the ' 'class of the hazard. There should be three classes: e.g. ' '1, 2, and 3.'), 'exposure_input': tr('An exposure raster layer where each cell represents the' 'population count for that cell.'), 'output': tr('Map of population exposed to the highest class and a table ' 'with the number of people in each class'), 'actions': tr('Provide details about how many people would likely be ' 'affected for each hazard class.'), 'limitations': [tr('The number of classes is three.')], 'citations': [], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': hazard_all, 'units': [unit_classified], 'layer_constraints': [layer_raster_classified] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([('low_hazard_class', 1.0), ('medium_hazard_class', 2.0), ('high_hazard_class', 3.0), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ITBBayesianFatalityFunction', 'name': tr( 'Earthquake ITB fatality function based on a Bayesian ' 'approach'), 'impact': tr('Die or be displaced according ITB bayesian model'), 'title': tr('Die or be displaced according ITB bayesian model'), 'function_type': 'old-style', 'author': 'ITB and GA', # FIXME 'date_implemented': 'N/A', 'overview': tr( 'Estimates the number of fatalities resulting from an ' 'earthquake. Uses data from an Indonesian database of ' 'earthquake events to calculate fatality rates. Based on the ' 'Population Vulnerability ITB Bayesian Model. This model is ' 'better at capturing uncertainty in the results.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'citations': [ { 'text': tr( 'Sengara, W., Suarjana, M., Yulman, M.A., Ghasemi, ' 'H., and Ryu, H. (2015). An empirical fatality model ' 'for Indonesia based on a Bayesian approach. ' 'Submitted for Journal of the Geological Society'), 'link': None } ], 'map_title': 'Earthquake impact to population', 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'layer_name': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [hazard_category_single_event], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPointPopulationFunction', 'name': tr('Point volcano on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'A point vector layer.'), 'exposure_input': tr( 'An exposure raster layer where each cell represent ' 'population count.'), 'output': tr( 'Vector layer contains people affected and the minimum ' 'needs based on the number of people affected.'), 'actions': tr( 'Provide details about how many people would likely ' 'be affected by each hazard zone.'), 'limitations': [], 'citations': [], 'map_title': tr('People affected by the buffered point volcano'), 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr( 'Thousand separator is represented by %s' % get_thousand_separator()), 'layer_name': tr('People affected by the buffered point volcano'), 'overview': tr( 'To assess the impacts of volcano eruption on ' 'population.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_point], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': [hazard_volcano], 'continuous_hazard_units': [], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [volcano_name_field] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ # The radii ('distances', distance()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'PAGFatalityFunction', 'name': tr('Earthquake PAGER fatality function'), 'impact': tr('Die or be displaced according Pager model'), 'title': tr('Die or be displaced according Pager model'), 'function_type': 'old-style', 'author': 'Helen Crowley', 'date_implemented': 'N/A', 'overview': tr('To assess the impact of an earthquake on population based ' 'on the Population Vulnerability Pager Model.'), 'detailed_description': '', 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': '', 'limitations': [], 'citations': [ tr('Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). ' 'Estimating casualties for large worldwide earthquakes ' 'using an empirical approach. U.S. Geological Survey ' 'Open-File Report 2009-1136.') ], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_earthquake], 'units': [unit_mmi], 'layer_constraints': [layer_raster_continuous] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'AshRasterHazardPopulationFunctionMetadata', 'name': tr('Ash raster on population'), 'impact': tr('Be affected'), 'title': tr('Be affected'), 'function_type': 'old-style', 'author': 'Ismail Sunni', 'date_implemented': '13/07/2016', 'overview': tr( 'To assess the impact of each hazard zone on population.'), 'detailed_description': '', 'hazard_input': tr( 'The hazard layer must be an ash raster layer.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents the ' 'population count for that cell.'), 'output': tr( 'Map of population exposed to the highest hazard zone and a ' 'table with the number of population in each hazard zone'), 'actions': tr( 'Provide details about how big area fall within ' 'each hazard zone.'), 'limitations': [], 'citations': [ { 'text': None, 'link': None } ], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'map_title': tr('Affected Population'), 'layer_name': tr('Population affected'), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_volcanic_ash], 'continuous_hazard_units': [unit_centimetres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict( [ ('group_threshold', threshold_group_parameter()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonPopulationFunction', 'name': tr('Polygon volcano on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'The hazard vector layer must be a polygon that has a ' 'specific hazard zone attribute.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count for that cell.'), 'output': tr( 'A vector layer containing people affected per hazard zone ' 'and the minimum needs based on the number of people ' 'affected.'), 'actions': tr( 'Provide details about the number of people that are within ' 'each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr( 'To assess the impact of a volcano eruption on people.'), 'detailed_description': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_multiple_event, hazard_category_single_event ], 'hazard_types': [hazard_volcano], 'continuous_hazard_units': [], 'vector_hazard_classifications': [ volcano_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [ volcano_name_field] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'TsunamiEvacuationFunction', 'name': tr('Tsunami evacuation'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of tsunami inundation in raster ' 'format on population.'), 'detailed_description': tr('The population subject to inundation exceeding a ' 'threshold (default 0.7m) is calculated and returned as ' 'a raster layer. In addition the total number and the ' 'required needs in terms of the BNPB (Perka 7) are ' 'reported. The threshold can be changed and even contain ' 'multiple numbers in which case evacuation and needs are ' 'calculated using the largest number with population ' 'breakdowns provided for the smaller numbers. The ' 'population raster is resampled to the resolution of the ' 'hazard raster and is rescaled so that the resampled ' 'population counts reflect estimates of population count ' 'per resampled cell. The resulting impact layer has the ' 'same resolution and reflects population count per cell ' 'which are affected by inundation.'), 'hazard_input': tr('A hazard raster layer where each cell represents tsunami ' 'depth (in meters).'), 'exposure_input': tr('An exposure raster layer where each cell represent ' 'population count.'), 'output': tr('Raster layer contains population affected and the minimum ' 'needs based on number of the population affected.'), 'actions': tr('Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [ tr('The default threshold of 0.7 meter was selected based on ' 'consensus, not hard evidence.') ], 'citations': [{ 'text': tr('Papadopoulos, Gerassimos A., and Fumihiko Imamura. ' '"A proposal for a new tsunami intensity scale." ' 'ITS 2001 proceedings, no. 5-1, pp. 569-577. 2001.'), 'link': None }, { 'text': tr('Hamza Latief. pers com. Default impact threshold for ' 'tsunami impact on people should be 0.7m. This is ' 'less than a flood threshold because in a tsunami, ' 'the water is moving with force.'), 'link': None }], 'legend_title': tr('Population'), 'legend_units': tr('(people per cell)'), 'legend_notes': tr('Thousand separator is represented by %s' % get_thousand_separator()), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_tsunami], 'continuous_hazard_units': [unit_feet, unit_metres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('thresholds', threshold()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonPopulationFunction', 'name': tr('Polygon volcano on population'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'hazard_input': tr( 'The hazard vector layer must be a polygon that has a ' 'specific hazard zone attribute.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count for that cell.'), 'output': tr( 'A vector layer containing people affected per hazard zone ' 'and the minimum needs based on the number of people ' 'affected.'), 'actions': tr( 'Provide details about the number of people that are within ' 'each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr( 'To assess the impact of a volcano eruption on people.'), 'detailed_description': '', 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_volcano], 'units': [unit_volcano_categorical], 'layer_constraints': [ layer_vector_polygon ] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # The attribute of hazard zone in hazard layer ('hazard zone attribute', 'KRB'), # The attribute for name of the volcano in hazard layer ('volcano name attribute', 'NAME'), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ITBFatalityFunction', 'name': tr('Earthquake ITB fatality function'), 'impact': tr('Die or be displaced'), 'title': tr('Die or be displaced'), 'function_type': 'old-style', 'author': 'Hadi Ghasemi', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impact of earthquake on population based ' 'on the earthquake model for Indonesia developed by ITB.'), 'detailed_description': tr( 'This model was developed by Institut Teknologi Bandung ' '(ITB) and implemented by Dr. Hadi Ghasemi, Geoscience ' 'Australia\n' 'Algorithm:\n' 'In this study, the same functional form as Allen (2009) ' 'is adopted o express fatality rate as a function of ' 'intensity (see Eq. 10 in the report). The Matlab ' 'built-in function (fminsearch) for Nelder-Mead algorithm ' 'was used to estimate the model parameters. The objective ' 'function (L2G norm) that is minimized during the ' 'optimisation is the same as the one used by Jaiswal ' 'et al. (2010).\n' 'The coefficients used in the indonesian model are ' 'x=0.62275231, y=8.03314466, zeta=2.15'), 'hazard_input': '', 'exposure_input': '', 'output': '', 'actions': tr( 'Provide details about the population including ' 'estimates for mortalities and displaced persons.'), 'limitations': [ tr('The model is based on a limited number of observed ' 'fatality rates during four previous fatal events.'), tr('The model clearly over-predicts the fatality rates at ' 'intensities higher than VIII.'), tr('The model only estimates the expected fatality rate ' 'for a given intensity level. The associated ' 'uncertainty for the proposed model is not addressed.'), tr('There are few known issues in the current model:\n\n' '* rounding MMI values to the nearest 0.5,\n' '* Implemention of Finite-Fault models of candidate ' ' events, and\n' '* consistency between selected GMPEs with those in ' ' use by BMKG.\n') ], 'citations': [ tr('Indonesian Earthquake Building-Damage and Fatality ' 'Models and Post Disaster Survey Guidelines ' 'Development Bali, 27-28 February 2012, 54pp.'), tr('Allen, T. I., Wald, D. J., Earle, P. S., Marano, K. ' 'D., Hotovec, A. J., Lin, K., and Hearne, M., 2009. An ' 'Atlas of ShakeMaps and population exposure catalog ' 'for earthquake loss modeling, Bull. Earthq. Eng. 7, ' '701-718.'), tr('Jaiswal, K., and Wald, D., 2010. An empirical model ' 'for global earthquake fatality estimation, Earthq. ' 'Spectra 26, 1017-1037.') ], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_earthquake], 'continuous_hazard_units': [unit_mmi], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedRasterHazardPopulationFunction', 'name': tr('Classified raster hazard on population'), 'impact': tr('Be affected in each class'), 'title': tr('Be affected in each hazard class'), 'function_type': 'old-style', 'author': 'Dianne Bencito', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of classified hazards in raster ' 'format on a population raster layer.'), 'detailed_description': tr( 'This function will treat the values in the hazard raster ' 'layer as classes representing low, medium and high ' 'impact. You need to ensure that the keywords for the hazard ' 'layer have been set appropriately to define these classes.' 'The number of people that will be affected will be ' 'calculated for each class. The report will show the total ' 'number of people that will be affected for each ' 'hazard class.'), 'hazard_input': tr( 'A hazard raster layer where each cell represents the ' 'class of the hazard. There should be three classes: e.g. ' '1, 2, and 3.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents the' 'population count for that cell.'), 'output': tr( 'Map of population exposed to the highest class and a table ' 'with the number of people in each class'), 'actions': tr( 'Provide details about how many people would likely be ' 'affected for each hazard class.'), 'limitations': [tr('The number of classes is three.')], 'citations': [], 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [ generic_raster_hazard_classes ], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [ count_exposure_unit, density_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([ ('Categorical hazards', categorical_hazards()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedPolygonHazardPopulationFunction', 'name': tr('Classified polygon hazard on population'), 'impact': tr('Be impacted'), 'title': tr('Be impacted'), 'function_type': 'old-style', 'author': 'Akbar Gumbira ([email protected])', 'date_implemented': 'N/A', 'hazard_input': tr( 'A hazard vector layer must be a polygon layer that has a ' 'hazard zone attribute.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents ' 'the population count for that cell.'), 'output': tr( 'A vector layer containing polygons matching the hazard areas' 'and an attribute representing the number of people affected ' 'for each area.'), 'actions': tr( 'Provide details about the number of people that are ' 'within each hazard zone.'), 'limitations': [], 'citations': [], 'overview': tr( 'To assess the the number of people that may be impacted by ' 'each hazard zone.'), 'detailed_description': '', 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': hazard_all, 'units': [unit_classified], 'layer_constraints': [ layer_vector_polygon ] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # The attribute of hazard zone in hazard layer ('hazard zone attribute', 'KRB'), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
class VolcanoPolygonHazardPopulation(FunctionProvider): # noinspection PyUnresolvedReferences """Impact function for volcano hazard zones impact on population. :author AIFDR :rating 4 :param requires category=='hazard' and \ subcategory in ['volcano'] and \ layertype=='vector' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for Volcano Polygon Hazard Population. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'VolcanoPolygonHazardPopulation', 'name': tr('Volcano Polygon Hazard Population'), 'impact': tr('Need evacuation'), 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of volcano eruption ' 'on population.'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_volcano], 'units': [unit_volcano_categorical], 'layer_constraints': [ layer_vector_polygon, layer_vector_point ] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } } } return dict_meta title = tr('Need evacuation') target_field = 'population' defaults = get_defaults() # Function documentation synopsis = tr('To assess the impacts of volcano eruption on population.') actions = tr( 'Provide details about how many population would likely be affected ' 'by each hazard zones.') hazard_input = tr( 'A hazard vector layer can be polygon or point. If polygon, it must ' 'have "KRB" attribute and the valuefor it are "Kawasan Rawan ' 'Bencana I", "Kawasan Rawan Bencana II", or "Kawasan Rawan Bencana ' 'III."If you want to see the name of the volcano in the result, you ' 'need to add "NAME" attribute for point data or "GUNUNG" attribute ' 'for polygon data.') exposure_input = tr( 'An exposure raster layer where each cell represent population count.') output = tr( 'Vector layer contains people affected and the minimum needs ' 'based on the number of people affected.') parameters = OrderedDict([ ('distance [km]', [3, 5, 10]), ('minimum needs', default_minimum_needs()), ('postprocessors', OrderedDict([ ('Gender', {'on': True}), ('Age', { 'on': True, 'params': OrderedDict([ ('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])])}), ('MinimumNeeds', {'on': True}) ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) parameters = add_needs_parameters(parameters) def run(self, layers): """Risk plugin for volcano population evacuation. :param layers: List of layers expected to contain where two layers should be present. * hazard_layer: Vector polygon layer of volcano impact zones * exposure_layer: Raster layer of population data on the same grid as hazard_layer Counts number of people exposed to volcano event. :returns: Map of population exposed to the volcano hazard zone. The returned dict will include a table with number of people evacuated and supplies required. :rtype: dict :raises: * Exception - When hazard layer is not vector layer * RadiiException - When radii are not valid (they need to be monotonically increasing) """ # Identify hazard and exposure layers hazard_layer = get_hazard_layer(layers) # Volcano KRB exposure_layer = get_exposure_layer(layers) question = get_question( hazard_layer.get_name(), exposure_layer.get_name(), self) # Input checks if not hazard_layer.is_vector: msg = ('Input hazard %s was not a vector layer as expected ' % hazard_layer.get_name()) raise Exception(msg) msg = ('Input hazard must be a polygon or point layer. I got %s with ' 'layer type %s' % (hazard_layer.get_name(), hazard_layer.get_geometry_name())) if not (hazard_layer.is_polygon_data or hazard_layer.is_point_data): raise Exception(msg) data_table = hazard_layer.get_data() if hazard_layer.is_point_data: # Use concentric circles radii = self.parameters['distance [km]'] category_title = 'Radius' category_header = tr('Distance [km]') category_names = radii name_attribute = 'NAME' # As in e.g. the Smithsonian dataset centers = hazard_layer.get_geometry() rad_m = [x * 1000 for x in radii] # Convert to meters hazard_layer = buffer_points( centers, rad_m, category_title, data_table=data_table) else: # Use hazard map category_title = 'KRB' category_header = tr('Category') # FIXME (Ole): Change to English and use translation system category_names = ['Kawasan Rawan Bencana III', 'Kawasan Rawan Bencana II', 'Kawasan Rawan Bencana I'] name_attribute = 'GUNUNG' # As in e.g. BNPB hazard map # Get names of volcanoes considered if name_attribute in hazard_layer.get_attribute_names(): volcano_name_list = [] # Run through all polygons and get unique names for row in data_table: volcano_name_list.append(row[name_attribute]) volcano_names = '' for name in volcano_name_list: volcano_names += '%s, ' % name volcano_names = volcano_names[:-2] # Strip trailing ', ' else: volcano_names = tr('Not specified in data') # Check if category_title exists in hazard_layer if category_title not in hazard_layer.get_attribute_names(): msg = ('Hazard data %s did not contain expected ' 'attribute %s ' % (hazard_layer.get_name(), category_title)) # noinspection PyExceptionInherit raise InaSAFEError(msg) # Find the target field name that has no conflict with default target attribute_names = hazard_layer.get_attribute_names() new_target_field = get_non_conflicting_attribute_name( self.target_field, attribute_names) self.target_field = new_target_field # Run interpolation function for polygon2raster interpolated_layer = assign_hazard_values_to_exposure_data( hazard_layer, exposure_layer, attribute_name=self.target_field) # Initialise data_table of output dataset with all data_table # from input polygon and a population count of zero new_data_table = hazard_layer.get_data() categories = {} for row in new_data_table: row[self.target_field] = 0 category = row[category_title] categories[category] = 0 # Count affected population per polygon and total for row in interpolated_layer.get_data(): # Get population at this location population = float(row[self.target_field]) # Update population count for associated polygon poly_id = row['polygon_id'] new_data_table[poly_id][self.target_field] += population # Update population count for each category category = new_data_table[poly_id][category_title] categories[category] += population # Count totals total_population = population_rounding( int(numpy.sum(exposure_layer.get_data(nan=0)))) # Count number and cumulative for each zone cumulative = 0 all_categories_population = {} all_categories_cumulative = {} for name in category_names: if category_title == 'Radius': key = name * 1000 # Convert to meters else: key = name # prevent key error population = int(categories.get(key, 0)) cumulative += population # I'm not sure whether this is the best place to apply rounding? all_categories_population[name] = population_rounding(population) all_categories_cumulative[name] = population_rounding(cumulative) # Use final accumulation as total number needing evacuation evacuated = population_rounding(cumulative) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map blank_cell = '' table_body = [question, TableRow([tr('Volcanoes considered'), '%s' % volcano_names, blank_cell], header=True), TableRow([tr('People needing evacuation'), '%s' % format_int(evacuated), blank_cell], header=True), TableRow([category_header, tr('Total'), tr('Cumulative')], header=True)] for name in category_names: table_body.append( TableRow([name, format_int(all_categories_population[name]), format_int(all_categories_cumulative[name])])) table_body.extend([ TableRow(tr( 'Map shows the number of people affected in each of volcano ' 'hazard polygons.'))]) total_needs = evacuated_population_needs( evacuated, minimum_needs) for frequency, needs in total_needs.items(): table_body.append(TableRow( [ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append(TableRow([ tr(resource['table name']), format_int(resource['amount'])])) impact_table = Table(table_body).toNewlineFreeString() # Extend impact report for on-screen display table_body.extend( [TableRow(tr('Notes'), header=True), tr('Total population %s in the exposure layer') % format_int( total_population), tr('People need evacuation if they are within the ' 'volcanic hazard zones.')]) population_counts = [x[self.target_field] for x in new_data_table] impact_summary = Table(table_body).toNewlineFreeString() # check for zero impact if numpy.nanmax(population_counts) == 0 == numpy.nanmin( population_counts): table_body = [ question, TableRow([tr('People needing evacuation'), '%s' % format_int(evacuated), blank_cell], header=True)] my_message = Table(table_body).toNewlineFreeString() raise ZeroImpactException(my_message) # Create style colours = ['#FFFFFF', '#38A800', '#79C900', '#CEED00', '#FFCC00', '#FF6600', '#FF0000', '#7A0000'] classes = create_classes(population_counts, len(colours)) interval_classes = humanize_class(classes) # Define style info for output polygons showing population counts style_classes = [] for i in xrange(len(colours)): style_class = dict() style_class['label'] = create_label(interval_classes[i]) if i == 0: transparency = 100 style_class['min'] = 0 else: transparency = 30 style_class['min'] = classes[i - 1] style_class['transparency'] = transparency style_class['colour'] = colours[i] style_class['max'] = classes[i] style_classes.append(style_class) # Override style info with new classes and name style_info = dict(target_field=self.target_field, style_classes=style_classes, style_type='graduatedSymbol') # For printing map purpose map_title = tr('People affected by volcanic hazard zone') legend_notes = tr('Thousand separator is represented by %s' % get_thousand_separator()) legend_units = tr('(people per cell)') legend_title = tr('Population') # Create vector layer and return impact_layer = Vector( data=new_data_table, projection=hazard_layer.get_projection(), geometry=hazard_layer.get_geometry(as_geometry_objects=True), name=tr('People affected by volcanic hazard zone'), keywords={'impact_summary': impact_summary, 'impact_table': impact_table, 'target_field': self.target_field, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'total_needs': total_needs}, style_info=style_info) return impact_layer
class FloodEvacuationFunctionVectorHazard(FunctionProvider): # noinspection PyUnresolvedReferences """Impact function for vector flood evacuation. :author AIFDR :rating 4 :param requires category=='hazard' and \ subcategory=='flood' and \ layertype=='vector' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ImpactFunctionMetadata): """Metadata for FloodEvacuationFunctionVectorHazard. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationFunctionVectorHazard', 'name': tr('Flood Evacuation Function Vector Hazard'), 'impact': tr('Need evacuation'), 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr('To assess the impacts of flood inundation ' 'in vector format on population.'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategory': [hazard_flood], 'units': unit_wetdry, 'layer_constraints': [layer_vector_polygon] }, 'exposure': { 'definition': exposure_definition, 'subcategory': exposure_population, 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_numeric] } } } return dict_meta title = tr('Need evacuation') # Function documentation synopsis = tr('To assess the impacts of flood inundation in vector ' 'format on population.') actions = tr( 'Provide details about how many people would likely need to be ' 'evacuated, where they are located and what resources would be ' 'required to support them.') detailed_description = tr( 'The population subject to inundation is determined whether in an ' 'area which affected or not. You can also set an evacuation ' 'percentage to calculate how many percent of the total population ' 'affected to be evacuated. This number will be used to estimate needs' ' based on BNPB Perka 7/2008 minimum bantuan.') hazard_input = tr( 'A hazard vector layer which has attribute affected the value is ' 'either 1 or 0') exposure_input = tr( 'An exposure raster layer where each cell represent population count.') output = tr('Vector layer contains people affected and the minimum needs ' 'based on evacuation percentage.') target_field = 'population' defaults = get_defaults() # Configurable parameters # TODO: Share the mimimum needs and make another default value parameters = OrderedDict([ ('evacuation_percentage', 1), # Percent of affected needing evacuation ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) def run(self, layers): """Risk plugin for flood population evacuation. :param layers: List of layers expected to contain * hazard_layer : Vector polygon layer of flood depth * exposure_layer : Raster layer of population data on the same grid as hazard_layer Counts number of people exposed to areas identified as flood prone :returns: Map of population exposed to flooding Table with number of people evacuated and supplies required. :rtype: tuple """ # Identify hazard and exposure layers hazard_layer = get_hazard_layer(layers) # Flood inundation exposure_layer = get_exposure_layer(layers) question = get_question(hazard_layer.get_name(), exposure_layer.get_name(), self) # Check that hazard is polygon type if not hazard_layer.is_vector: message = ('Input hazard %s was not a vector layer as expected ' % hazard_layer.get_name()) raise Exception(message) message = ( 'Input hazard must be a polygon layer. I got %s with layer type ' '%s' % (hazard_layer.get_name(), hazard_layer.get_geometry_name())) if not hazard_layer.is_polygon_data: raise Exception(message) # Run interpolation function for polygon2raster P = assign_hazard_values_to_exposure_data(hazard_layer, exposure_layer, attribute_name='population') # Initialise attributes of output dataset with all attributes # from input polygon and a population count of zero new_attributes = hazard_layer.get_data() category_title = 'affected' # FIXME: Should come from keywords deprecated_category_title = 'FLOODPRONE' categories = {} for attr in new_attributes: attr[self.target_field] = 0 try: cat = attr[category_title] except KeyError: try: cat = attr['FLOODPRONE'] categories[cat] = 0 except KeyError: pass # Count affected population per polygon, per category and total affected_population = 0 for attr in P.get_data(): affected = False if 'affected' in attr: res = attr['affected'] if res is None: x = False else: x = bool(res) affected = x elif 'FLOODPRONE' in attr: # If there isn't an 'affected' attribute, res = attr['FLOODPRONE'] if res is not None: affected = res.lower() == 'yes' elif 'Affected' in attr: # Check the default attribute assigned for points # covered by a polygon res = attr['Affected'] if res is None: x = False else: x = res affected = x else: # assume that every polygon is affected (see #816) affected = True # there is no flood related attribute # message = ('No flood related attribute found in %s. ' # 'I was looking for either "Flooded", "FLOODPRONE" ' # 'or "Affected". The latter should have been ' # 'automatically set by call to ' # 'assign_hazard_values_to_exposure_data(). ' # 'Sorry I can\'t help more.') # raise Exception(message) if affected: # Get population at this location pop = float(attr['population']) # Update population count for associated polygon poly_id = attr['polygon_id'] new_attributes[poly_id][self.target_field] += pop # Update population count for each category if len(categories) > 0: try: cat = new_attributes[poly_id][category_title] except KeyError: cat = new_attributes[poly_id][ deprecated_category_title] categories[cat] += pop # Update total affected_population += pop # Estimate number of people in need of evacuation evacuated = (affected_population * self.parameters['evacuation_percentage'] / 100.0) affected_population, rounding = population_rounding_full( affected_population) total = int(numpy.sum(exposure_layer.get_data(nan=0, scaling=False))) # Don't show digits less than a 1000 total = population_rounding(total) evacuated, rounding_evacuated = population_rounding_full(evacuated) minimum_needs = [ parameter.serialize() for parameter in self.parameters['minimum needs'] ] # Generate impact report for the pdf map table_body = [ question, TableRow([ tr('People affected'), '%s*' % (format_int(int(affected_population))) ], header=True), TableRow([ TableCell(tr('* Number is rounded up to the nearest %s') % (rounding), col_span=2) ]), TableRow([ tr('People needing evacuation'), '%s*' % (format_int(int(evacuated))) ], header=True), TableRow([ TableCell(tr('* Number is rounded up to the nearest %s') % (rounding_evacuated), col_span=2) ]), TableRow([ tr('Evacuation threshold'), '%s%%' % format_int(self.parameters['evacuation_percentage']) ], header=True), TableRow( tr('Map shows the number of people affected in each flood prone ' 'area')), TableRow( tr('Table below shows the weekly minimum needs for all ' 'evacuated people')) ] total_needs = evacuated_population_needs(evacuated, minimum_needs) for frequency, needs in total_needs.items(): table_body.append( TableRow([ tr('Needs should be provided %s' % frequency), tr('Total') ], header=True)) for resource in needs: table_body.append( TableRow([ tr(resource['table name']), format_int(resource['amount']) ])) impact_table = Table(table_body).toNewlineFreeString() table_body.append(TableRow(tr('Action Checklist:'), header=True)) table_body.append(TableRow(tr('How will warnings be disseminated?'))) table_body.append(TableRow(tr('How will we reach stranded people?'))) table_body.append(TableRow(tr('Do we have enough relief items?'))) table_body.append( TableRow( tr('If yes, where are they located and how will we distribute ' 'them?'))) table_body.append( TableRow( tr('If no, where can we obtain additional relief items from and ' 'how will we transport them to here?'))) # Extend impact report for on-screen display table_body.extend([ TableRow(tr('Notes'), header=True), tr('Total population: %s') % format_int(total), tr('People need evacuation if in the area identified as ' '"Flood Prone"'), tr('Minimum needs are defined in BNPB regulation 7/2008') ]) impact_summary = Table(table_body).toNewlineFreeString() # Create style # Define classes for legend for flooded population counts colours = [ '#FFFFFF', '#38A800', '#79C900', '#CEED00', '#FFCC00', '#FF6600', '#FF0000', '#7A0000' ] population_counts = [x['population'] for x in new_attributes] classes = create_classes(population_counts, len(colours)) interval_classes = humanize_class(classes) # Define style info for output polygons showing population counts style_classes = [] for i in xrange(len(colours)): style_class = dict() style_class['label'] = create_label(interval_classes[i]) if i == 0: transparency = 0 style_class['min'] = 0 else: transparency = 0 style_class['min'] = classes[i - 1] style_class['transparency'] = transparency style_class['colour'] = colours[i] style_class['max'] = classes[i] style_classes.append(style_class) # Override style info with new classes and name style_info = dict(target_field=self.target_field, style_classes=style_classes, style_type='graduatedSymbol') # For printing map purpose map_title = tr('People affected by flood prone areas') legend_notes = tr('Thousand separator is represented by \'.\'') legend_units = tr('(people per polygon)') legend_title = tr('Population Count') # Create vector layer and return vector_layer = Vector(data=new_attributes, projection=hazard_layer.get_projection(), geometry=hazard_layer.get_geometry(), name=tr('People affected by flood prone areas'), keywords={ 'impact_summary': impact_summary, 'impact_table': impact_table, 'target_field': self.target_field, 'map_title': map_title, 'legend_notes': legend_notes, 'legend_units': legend_units, 'legend_title': legend_title, 'affected_population': affected_population, 'total_population': total, 'total_needs': total_needs }, style_info=style_info) return vector_layer
class PAGFatalityFunction(ITBFatalityFunction): # noinspection PyUnresolvedReferences """Population Vulnerability Model Pager. Loss ratio(MMI) = standard normal distrib( 1 / BETA * ln(MMI/THETA)). Reference: Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). Estimating casualties for large worldwide earthquakes using an empirical approach. U.S. Geological Survey Open-File Report 2009-1136. :author Helen Crowley :rating 3 :param requires category=='hazard' and \ subcategory=='earthquake' and \ layertype=='raster' and \ unit=='MMI' :param requires category=='exposure' and \ subcategory=='population' and \ layertype=='raster' """ class Metadata(ITBFatalityFunction.Metadata): """Metadata for PAG Fatality Function. .. versionadded:: 2.1 We only need to re-implement get_metadata(), all other behaviours are inherited from the abstract base class. """ @staticmethod def get_metadata(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'PAGFatalityFunction.', 'name': tr('PAG Fatality Function.'), 'impact': tr('Die or be displaced according Pager model'), 'author': 'Helen Crowley', 'date_implemented': 'N/A', 'overview': tr('To assess the impact of earthquake on population based ' 'on Population Vulnerability Model Pager'), 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategory': hazard_earthquake, 'units': [unit_mmi], 'layer_constraints': [layer_raster_numeric] }, 'exposure': { 'definition': exposure_definition, 'subcategory': exposure_population, 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_numeric] } } } return dict_meta synopsis = tr('To assess the impact of earthquake on population based on ' 'Population Vulnerability Model Pager') citations = tr( ' * Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). ' ' Estimating casualties for large worldwide earthquakes using ' ' an empirical approach. U.S. Geological Survey Open-File ' ' Report 2009-1136.') limitation = '' detailed_description = '' title = tr('Die or be displaced according Pager model') defaults = get_defaults() parameters = OrderedDict([ ('Theta', 11.067), ('Beta', 0.106), # Model coefficients # Rates of people displaced for each MMI level ('displacement_rate', { 1: 0, 1.5: 0, 2: 0, 2.5: 0, 3: 0, 3.5: 0, 4: 0, 4.5: 0, 5: 0, 5.5: 0, 6: 1.0, 6.5: 1.0, 7: 1.0, 7.5: 1.0, 8: 1.0, 8.5: 1.0, 9: 1.0, 9.5: 1.0, 10: 1.0 }), ('mmi_range', list(numpy.arange(2, 10, 0.5))), ('step', 0.25), # Threshold below which layer should be transparent ('tolerance', 0.01), ('calculate_displaced_people', True), ('postprocessors', OrderedDict([ ('Gender', { 'on': True }), ('Age', { 'on': True, 'params': OrderedDict([('youth_ratio', defaults['YOUTH_RATIO']), ('adult_ratio', defaults['ADULT_RATIO']), ('elderly_ratio', defaults['ELDERLY_RATIO'])]) }), ('MinimumNeeds', { 'on': True }) ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) # noinspection PyPep8Naming def fatality_rate(self, mmi): """Pager method to compute fatality rate. :param mmi: MMI :returns: Fatality rate """ N = math.sqrt(2 * math.pi) THETA = self.parameters['Theta'] BETA = self.parameters['Beta'] x = math.log(mmi / THETA) / BETA return math.exp(-x * x / 2.0) / N
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'FloodEvacuationVectorHazardFunction', 'name': tr('Polygon flood on people'), 'impact': tr('Need evacuation'), 'title': tr('Need evacuation'), 'function_type': 'old-style', 'author': 'AIFDR', 'date_implemented': 'N/A', 'overview': tr( 'To assess the impacts of flood inundation in vector ' 'format on population.'), 'detailed_description': tr( 'The population subject to inundation is determined by ' 'whether they are in a flood affected area or not. You can ' 'also set an evacuation percentage to calculate what ' 'percentage of the affected population should be ' 'evacuated. This number will be used to estimate needs ' 'based on the user defined minimum needs file.'), 'hazard_input': tr( 'A hazard vector layer which has an affected attribute. If ' 'it does not have that attribute, all polygons will be ' 'considered as affected.'), 'exposure_input': tr( 'An exposure raster layer where each cell represents a ' 'population count.'), 'output': tr( 'A vector layer containing the number of people affected ' 'per flood area and the minimum needs based on ' 'evacuation percentage.'), 'actions': tr( 'Provide details about how many people would likely need ' 'to be evacuated, where they are located and what ' 'resources would be required to support them.'), 'limitations': [], 'citations': [], 'categories': { 'hazard': { 'definition': hazard_definition, 'subcategories': [hazard_flood], 'units': [unit_wetdry, unit_metres_depth, unit_feet_depth], 'layer_constraints': [layer_vector_polygon] }, 'exposure': { 'definition': exposure_definition, 'subcategories': [exposure_population], 'units': [unit_people_per_pixel], 'layer_constraints': [layer_raster_continuous] } }, 'parameters': OrderedDict([ # This field of the hazard layer contains information # about inundated areas ('affected_field', 'FLOODPRONE'), # This value in 'affected_field' of the hazard layer # marks the areas as inundated ('affected_value', 'YES'), # Percent of affected needing evacuation ('evacuation_percentage', 1), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs()), ('provenance', default_provenance()) ]) } return dict_meta
def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'AshRasterPopulationFunction', 'name': tr('Ash raster on population'), 'impact': tr('Be affected'), 'title': tr('Be affected'), 'function_type': 'old-style', 'author': 'Ismail Sunni', 'date_implemented': '13/07/2016', 'overview': tr('To assess the impact of each hazard zone on population.'), 'detailed_description': '', 'hazard_input': tr('The hazard layer must be an ash raster layer.'), 'exposure_input': tr('An exposure raster layer where each cell represents the ' 'population count for that cell.'), 'output': tr('Map of population exposed to the highest hazard zone and a ' 'table with the number of population in each hazard zone'), 'actions': tr('Provide details about how big area fall within ' 'each hazard zone.'), 'limitations': [], 'citations': [{ 'text': None, 'link': None }], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': [hazard_volcanic_ash], 'continuous_hazard_units': [unit_centimetres], 'vector_hazard_classifications': [], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_raster], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [] } }, 'parameters': OrderedDict([('group_threshold', threshold_group_parameter()), ('postprocessors', OrderedDict([ ('Gender', default_gender_postprocessor()), ('Age', age_postprocessor()), ('MinimumNeeds', minimum_needs_selector()), ])), ('minimum needs', default_minimum_needs())]) } return dict_meta