当前位置: 首页>>代码示例>>Python>>正文


Python core.population_rounding函数代码示例

本文整理汇总了Python中safe.impact_functions.core.population_rounding函数的典型用法代码示例。如果您正苦于以下问题:Python population_rounding函数的具体用法?Python population_rounding怎么用?Python population_rounding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了population_rounding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: action_checklist

    def action_checklist(self):
        """Action checklist for the itb earthquake fatality report.

        :returns: The action checklist
        :rtype: list
        """
        total_fatalities = self.total_fatalities
        total_displaced = self.total_evacuated
        rounded_displaced = format_int(population_rounding(total_displaced))

        fields = super(ITBFatalityFunction, self).action_checklist()
        if total_fatalities:
            fields.append(tr(
                'Are there enough victim identification units available '
                'for %s people?') % (
                    format_int(population_rounding(total_fatalities))))
        if total_displaced:
            fields.append(tr(
                'Are there enough shelters and relief items available for '
                '%s people?') % rounded_displaced)
        if rounded_displaced:
            fields.append(tr(
                'If yes, where are they located and how will we '
                'distribute them?'))
        if total_displaced:
            fields.append(tr(
                'If no, where can we obtain additional relief items '
                'from and how will we transport them?'))

        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:30,代码来源:impact_function.py

示例2: action_checklist

    def action_checklist(self):
        """Action checklist for the itb earthquake fatality report.

        :returns: The action checklist
        :rtype: list
        """
        total_fatalities = self.total_fatalities
        total_displaced = self.total_evacuated
        rounded_displaced = format_int(population_rounding(total_displaced))
        message = m.Message(style_class='container')
        message.add(m.Heading(tr('Action checklist'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        if total_fatalities:
            checklist.add(tr(
                'Are there enough victim identification units available '
                'for %s people?') % (
                    format_int(population_rounding(total_fatalities))))
        if total_displaced:
            checklist.add(tr(
                'Are there enough shelters and relief items available for '
                '%s people?') % rounded_displaced)
        if rounded_displaced:
            checklist.add(tr(
                'If yes, where are they located and how will we '
                'distribute them?'))
        if total_displaced:
            checklist.add(tr(
                'If no, where can we obtain additional relief items '
                'from and how will we transport them?'))
        message.add(checklist)
        return message
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:31,代码来源:impact_function.py

示例3: hazard_table

    def hazard_table(self, hazard_table):
        """ Return updated hazard table.

        :param hazard_table: hazard table.
        :type hazard_table: Table

        :returns hazard_table: Updated Hazard Table
        :rtype area_name: Table
        """
        hazard_table.caption = None

        for key, value in self.hazard_levels.iteritems():

            name = self.hazard_class_mapping[key][0]
            # This skips reporting people not affected in No zone
            if key == 'wet':
                row = m.Row()
                row.add(m.Cell(tr(
                    'People within hazard field ("%s") of value "%s"')
                               % (self.hazard_class_field, name),
                               header=True))
                value = format_int(population_rounding(value))
                row.add(m.Cell(value, align='right'))
            elif key == 'dry':
                continue
            else:
                row = m.Row()
                row.add(m.Cell(name, header=True))
                value = format_int(population_rounding(value))
                row.add(m.Cell(value, align='right'))
            hazard_table.add(row)

        # Total affected population
        row = m.Row()
        row.add(m.Cell(
            tr('Total affected people'),
            header=True))
        affected = format_int(
            population_rounding(self.total_affected_population))
        row.add(m.Cell(affected, align='right'))
        hazard_table.add(row)

        # Non affected population
        row = m.Row()
        unaffected = format_int(
            population_rounding(self.unaffected_population))
        row.add(m.Cell(tr('Unaffected people'), header=True))
        row.add(m.Cell(unaffected, align='right'))
        hazard_table.add(row)

        # Total Population
        row = m.Row()
        total_population = format_int(
            population_rounding(self.total_population))
        row.add(m.Cell(tr('Total people'), header=True))
        row.add(m.Cell(total_population, align='right'))
        hazard_table.add(row)

        return hazard_table
开发者ID:codeforresilience,项目名称:inasafe,代码行数:59,代码来源:polygon_population_exposure_report_mixin.py

示例4: test_itb_earthquake_fatality_estimation

    def test_itb_earthquake_fatality_estimation(self):
        """Fatalities from ground shaking can be computed correctly using the
            ITB fatality model (Test data from Hadi Ghasemi)."""
        # Name file names for hazard level, exposure and expected fatalities
        hazard_filename = '%s/itb_test_mmi.asc' % TESTDATA
        exposure_filename = '%s/itb_test_pop.asc' % TESTDATA

        # Calculate impact using API
        hazard_layer = read_layer(hazard_filename)
        exposure_layer = read_layer(exposure_filename)

        plugin_name = 'ITB Fatality Function'
        impact_function = get_plugin(plugin_name)

        # Call calculation engine
        impact_layer = calculate_impact(
            layers=[hazard_layer, exposure_layer], impact_fcn=impact_function)
        impact_filename = impact_layer.get_filename()

        impact_layer = read_layer(impact_filename)
        # calculated_result = I.get_data()
        # print calculated_result.shape
        keywords = impact_layer.get_keywords()
        # print "keywords", keywords
        population = float(keywords['total_population'])
        fatalities = float(keywords['total_fatalities'])

        # Check aggregated values
        expected_population = population_rounding(85424650.0)
        msg = ('Expected population was %f, I got %f'
               % (expected_population, population))
        assert population == expected_population, msg

        expected_fatalities = population_rounding(40871.3028)
        msg = ('Expected fatalities was %f, I got %f'
               % (expected_fatalities, fatalities))

        assert numpy.allclose(fatalities, expected_fatalities,
                              rtol=1.0e-5), msg

        # Check that aggregated number of fatilites is as expected
        all_numbers = int(numpy.sum([31.8937368131,
                                     2539.26369372,
                                     1688.72362573,
                                     17174.9261705,
                                     19436.834531]))
        msg = ('Aggregated number of fatalities not as expected: %i'
               % all_numbers)
        assert all_numbers == 40871, msg

        x = population_rounding(all_numbers)
        msg = ('Did not find expected fatality value %i in summary %s'
               % (x, keywords['impact_summary']))
        assert format_int(x) in keywords['impact_summary'], msg
开发者ID:severinmenard,项目名称:inasafe,代码行数:54,代码来源:test_itb_earthquake_fatality_model.py

示例5: impact_summary

    def impact_summary(self):
        """Create impact summary as data.

        :returns: Impact Summary in dictionary format.
        :rtype: dict
        """
        attributes = ['category', 'value']
        fields = []

        # Breakdown by hazard level (if available)
        if len(self.impact_category_ordering):
            for category in self.impact_category_ordering:
                population_in_category = self.lookup_category(category)
                population_in_category = format_int(population_rounding(
                    population_in_category
                ))
                row = [tr(category), population_in_category]
                fields.append(row)

        # Total affected population
        row = [
            tr('Total affected population'),
            format_int(population_rounding(self.total_affected_population))
        ]
        fields.append(row)

        # Non affected population
        row = [
            tr('Unaffected population'),
            format_int(population_rounding(self.unaffected_population))
        ]
        fields.append(row)

        # Total Population
        row = [
            tr('Total population'),
            format_int(population_rounding(self.total_population))
        ]
        fields.append(row)

        # Population needing evacuation
        row = [
            tr('Population needing evacuation <sup>1</sup>'),
            format_int(population_rounding(self.total_evacuated))
        ]
        fields.append(row)

        return {
            'attributes': attributes,
            'fields': fields
        }
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:51,代码来源:population_exposure_report_mixin.py

示例6: action_checklist

    def action_checklist(self):
        """Return the action check list section of the report.

        :return: The action check list as dict.
        :rtype: dict
        """
        title = tr('Action checklist')
        evacuated_people = format_int(
            population_rounding(self.total_affected_population))
        fields = [
            tr('Which group or population is most affected?'),
            tr('Who are the vulnerable people in the population and why?'),
            tr('How will warnings be disseminated?'),
            tr('What are people\'s likely movements?'),
            tr('What are the security factors for the affected population?'),
            tr('What are the security factors for relief responders?'),
            tr('How will we reach evacuated people?'),
            tr('What kind of food does the population normally consume?'),
            tr('What are the critical non-food items required by the affected '
               'population?'),
            tr('Are there enough water supply, sanitation, hygiene, food, '
               'shelter, medicines and relief items available for %s people?'
                % evacuated_people),
            tr('If yes, where are they located and how will we distribute '
               'them?'),
            tr('If no, where can we obtain additional relief items and how '
               'will we distribute them?'),
            tr('What are the related health risks?'),
            tr('Who are the key people responsible for coordination?')
        ]

        return {
            'title': title,
            'fields': fields
        }
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:35,代码来源:population_exposure_report_mixin.py

示例7: notes

    def notes(self):
        """Notes and caveats for the IF report.

        :returns: Dicts containing notes.
        :rtype: dict
        """
        title = tr('Notes and assumptions')
        fields = [
            tr('Total population in the analysis area: %s') %
            format_int(population_rounding(self.total_population)),
            tr('<sup>1</sup>People are displaced if they experience and '
               'survive a shake level of more than 5 on the MMI scale.'),
            tr('The fatality calculation assumes that no fatalities occur for '
               'shake levels below 4 and fatality counts of less than 50 are '
               'disregarded.')
        ]
        if self.__class__ != ITBFatalityFunction:
            fields.append(tr(
                'Fatality model is from Institut Teknologi Bandung 2012.'))
            fields.append(tr(
                'Fatality model is from the Population Vulnerability '
                'Pager Model.'))
        fields.extend([
            tr('Map shows the estimation of displaced population.'),
            tr('All values are rounded up to the nearest integer in order to '
               'avoid representing human lives as fractions.'),
            tr('Population rounding is applied to all population values, '
               'which may cause discrepancies when adding values.')
        ])

        return {
            'title': title,
            'fields': fields
        }
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:34,代码来源:impact_function.py

示例8: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: list
        """
        population = format_int(population_rounding(self.total_population))
        threshold = format_int(self.parameters['evacuation_percentage'].value)

        if get_needs_provenance_value(self.parameters) is None:
            needs_provenance = ''
        else:
            needs_provenance = tr(get_needs_provenance_value(self.parameters))

        fields = [
            tr('Total population in the analysis area: %s') % population,
            tr('<sup>1</sup>The evacuation threshold used to determine '
               'population needing evacuation is %s%%.') % threshold,
            needs_provenance,
        ]

        if self.no_data_warning:
            fields = fields + no_data_warning
        # include any generic exposure specific notes from definitions.py
        fields = fields + self.exposure_notes()
        # include any generic hazard specific notes from definitions.py
        fields = fields + self.hazard_notes()
        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:28,代码来源:impact_function.py

示例9: format_int

    def format_int(number):
        """Get the correct integer format.

        :param number: The number to format
        :type number: float or integer
        """
        return format_int(population_rounding(number))
开发者ID:easmetz,项目名称:inasafe,代码行数:7,代码来源:polygon_people_report_template.py

示例10: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class="container")
        message.add(m.Heading(tr("Notes and assumptions"), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        population = format_int(population_rounding(self.total_population))
        checklist.add(tr("Total population in the analysis area: %s") % population)
        checklist.add(tr("<sup>1</sup>People need evacuation if they are in a " "hazard zone."))
        checklist.add(tr("Map shows population count in high, medium, and low " "hazard areas."))
        checklist.add(
            tr(
                "All values are rounded up to the nearest integer in "
                "order to avoid representing human lives as fractions."
            )
        )
        checklist.add(
            tr(
                "Population rounding is applied to all population "
                "values, which may cause discrepancies when adding values."
            )
        )
        message.add(checklist)
        return message
开发者ID:codeforresilience,项目名称:inasafe,代码行数:27,代码来源:impact_function.py

示例11: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: dict
        """
        title = tr('Notes and assumptions')
        fields = [
            tr('Total population in the analysis area: %s') %
            population_rounding(self.total_population),
            tr('<sup>1</sup>People need evacuation if they are in a hazard '
               'zone.'),
            tr('Map shows the numbers of people in high, medium, and low '
               'hazard class areas.')
        ]

        if self.no_data_warning:
            fields.append(tr(
                'The layers contained "no data" values. This missing data '
                'was carried through to the impact layer.'))
            fields.append(tr(
                '"No data" values in the impact layer were treated as 0 '
                'when counting the affected or total population.'))

        fields.extend([
            tr('All values are rounded up to the nearest integer in order to '
               'avoid representing human lives as fractions.'),
            tr('Population rounding is applied to all population values, '
               'which may cause discrepancies when adding value.')
        ])

        return {
            'title': title,
            'fields': fields
        }
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:35,代码来源:impact_function.py

示例12: notes

    def notes(self):
        """Notes and caveats for the IF report.

        :returns: Dicts containing notes.
        :rtype: list
        """
        fields = [
            tr('Total population in the analysis area: %s') %
            format_int(population_rounding(self.total_population)),
            tr('<sup>1</sup>People are displaced if they experience and '
               'survive a shake level of more than 5 on the MMI scale.'),
            tr('The fatality calculation assumes that no fatalities occur for '
               'shake levels below 4 and fatality counts of less than 50 are '
               'disregarded.')
        ]
        if self.__class__ != ITBFatalityFunction:
            fields.append(tr(
                'Fatality model is from Institut Teknologi Bandung 2012.'))
            fields.append(tr(
                'Fatality model is from the Population Vulnerability '
                'Pager Model.'))
        fields.extend([
            tr('Map shows the estimation of displaced population.'),
        ])
        # include any generic exposure specific notes from definitions.py
        fields = fields + self.exposure_notes()
        # include any generic hazard specific notes from definitions.py
        fields = fields + self.hazard_notes()
        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:29,代码来源:impact_function.py

示例13: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: list
        """
        if get_needs_provenance_value(self.parameters) is None:
            needs_provenance = ''
        else:
            needs_provenance = tr(get_needs_provenance_value(self.parameters))
        fields = [
            tr('Map shows buildings affected in each of the volcano buffered '
               'zones.'),
            tr('Total population in the analysis area: %s') %
            population_rounding(self.total_population),
            tr('<sup>1</sup>People need evacuation if they are within the '
               'volcanic hazard zones.'),
            tr('Volcanoes considered: %s.') % self.volcano_names,
            needs_provenance
        ]

        if self.no_data_warning:
            fields = fields + no_data_warning
        # include any generic exposure specific notes from definitions.py
        fields = fields + self.exposure_notes()
        # include any generic hazard specific notes from definitions.py
        fields = fields + self.hazard_notes()
        return fields
开发者ID:easmetz,项目名称:inasafe,代码行数:28,代码来源:impact_function.py

示例14: notes

    def notes(self):
        """Return the notes section of the report.

        :return: The notes that should be attached to this impact report.
        :rtype: safe.messaging.Message
        """
        message = m.Message(style_class='container')

        message.add(
            m.Heading(tr('Notes and assumptions'), **styles.INFO_STYLE))
        checklist = m.BulletedList()
        checklist.add(tr(
            'Total population in the analysis area: %s'
            ) % population_rounding(self.total_population))
        checklist.add(tr(
            '<sup>1</sup>People need evacuation if they are in a '
            'hazard zone.'))

        if self.no_data_warning:
            checklist.add(tr(
                'The layers contained "no data" values. This missing data '
                'was carried through to the impact layer.'))
            checklist.add(tr(
                '"No data" values in the impact layer were treated as 0 '
                'when counting the affected or total population.'))
        checklist.add(tr(
            'All values are rounded up to the nearest integer in '
            'order to avoid representing human lives as fractions.'))
        checklist.add(tr(
            'Population rounding is applied to all population '
            'values, which may cause discrepancies when adding value.'))

        message.add(checklist)
        return message
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:34,代码来源:impact_function.py

示例15: test_volcano_population_evacuation_impact

    def test_volcano_population_evacuation_impact(self):
        """Population impact from volcanic hazard is computed correctly."""
        # Name file names for hazard level, exposure and expected fatalities
        hazard_filename = '%s/donut.shp' % TESTDATA
        exposure_filename = ('%s/pop_merapi_clip.tif' % TESTDATA)

        # Calculate impact using API
        hazard_layer = read_layer(hazard_filename)
        exposure_layer = read_layer(exposure_filename)

        plugin_name = 'Volcano Polygon Hazard Population'
        impact_function = get_plugin(plugin_name)

        impact_layer = calculate_impact(
            layers=[hazard_layer, exposure_layer], impact_fcn=impact_function)
        impact_filename = impact_layer.get_filename()

        impact_layer = read_layer(impact_filename)

        keywords = impact_layer.get_keywords()

        # Check for expected results:
        for value in ['Merapi', 192055, 56514, 68568, 66971]:
            if isinstance(value, int):
                x = format_int(population_rounding(value))
            else:
                x = value
            summary = keywords['impact_summary']
            msg = ('Did not find expected value %s in summary %s'
                   % (x, summary))
            assert x in summary, msg
开发者ID:severinmenard,项目名称:inasafe,代码行数:31,代码来源:test_volcano_population_evacuation_polygon.py


注:本文中的safe.impact_functions.core.population_rounding函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。