• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python impact_function_manager.ImpactFunctionManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_hazards_for_layer

    def test_hazards_for_layer(self):
        """Test for hazards_for_layer"""
        impact_function_manager = ImpactFunctionManager()
        hazards = impact_function_manager.hazards_for_layer(
            'polygon', 'single_event')
        # print [x['key'] for x in hazards]
        expected = [
            hazard_flood,
            hazard_tsunami,
            hazard_earthquake,
            hazard_volcano,
            hazard_volcanic_ash,
            hazard_generic
        ]
        self.assertItemsEqual(hazards, expected)

        hazards = impact_function_manager.hazards_for_layer('polygon')
        expected = [hazard_flood, hazard_tsunami, hazard_earthquake,
                    hazard_volcano, hazard_volcanic_ash, hazard_generic]
        self.assertItemsEqual(hazards, expected)

        hazards = impact_function_manager.hazards_for_layer(
            'point', 'single_event')
        expected = [hazard_volcano]
        self.assertItemsEqual(hazards, expected)
开发者ID:easmetz,项目名称:inasafe,代码行数:25,代码来源:test_impact_function_manager.py


示例2: test_available_hazards

    def test_available_hazards(self):
        """Test available_hazards API."""
        impact_function_manager = ImpactFunctionManager()

        result = impact_function_manager.available_hazards(
            'single_event')
        print [x['key'] for x in result]
开发者ID:tomkralidis,项目名称:inasafe,代码行数:7,代码来源:test_impact_function_manager.py


示例3: test_functions_for_constraint

    def test_functions_for_constraint(self):
        """Test functions_for_constraint."""
        ifm = ImpactFunctionManager()
        impact_functions = ifm.functions_for_constraint(
            'earthquake',
            'population',
            'raster',
            'raster',
            'continuous',
            'continuous',
        )
        expected = [
            ITBFatalityFunction.metadata().as_dict(),
            ITBBayesianFatalityFunction.metadata().as_dict(),
            PAGFatalityFunction.metadata().as_dict(),
            ContinuousHazardPopulationFunction.metadata().as_dict()]

        for key in impact_functions[0].keys():
            if key == 'parameters':
                # We do not check the parameters since they are mutable.
                continue
            result = [x[key] for x in impact_functions]
            hope = [x[key] for x in expected]
            message = key
            self.assertItemsEqual(result, hope, message)
开发者ID:easmetz,项目名称:inasafe,代码行数:25,代码来源:test_impact_function_manager.py


示例4: test_get_functions_for_constraint

    def test_get_functions_for_constraint(self):
        """Test get_functions_for_constraint."""
        impact_function_manager = ImpactFunctionManager()
        hazard = hazard_earthquake
        exposure = exposure_structure

        expected_result = [
            EarthquakeBuildingImpactFunction.Metadata.get_metadata(),
            ClassifiedHazardBuildingImpactFunction.Metadata.get_metadata()]
        result = impact_function_manager.get_functions_for_constraint(
            hazard, exposure)
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertItemsEqual(expected_result, result, message)

        hazard_constraint = layer_raster_continuous
        exposure_constraint = None

        expected_result = [
            EarthquakeBuildingImpactFunction.Metadata.get_metadata()]
        result = impact_function_manager.get_functions_for_constraint(
            hazard, exposure, hazard_constraint, exposure_constraint)
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertItemsEqual(expected_result, result, message)

        hazard_constraint = layer_vector_polygon
        exposure_constraint = layer_vector_line

        expected_result = []
        result = impact_function_manager.get_functions_for_constraint(
            hazard, exposure, hazard_constraint, exposure_constraint)
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertItemsEqual(expected_result, result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:32,代码来源:test_impact_function_manager.py


示例5: test_exposure_units_for_layer

 def test_exposure_units_for_layer(self):
     """Test for exposure_units_for_layer"""
     impact_function_manager = ImpactFunctionManager()
     exposure_units = impact_function_manager.exposure_units_for_layer(
         'population', 'raster', 'continuous')
     expected = [count_exposure_unit, density_exposure_unit]
     self.assertItemsEqual(exposure_units, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:7,代码来源:test_impact_function_manager.py


示例6: test_available_hazard_layer_modes

    def test_available_hazard_layer_modes(self):
        """Test for available_hazard_layer_modes."""
        ifm = ImpactFunctionManager()
        hazard_layer_mode = ifm.available_hazard_layer_modes(
            'earthquake', 'raster', 'single_event')
        expected = [layer_mode_continuous, layer_mode_classified]

        self.assertItemsEqual(hazard_layer_mode, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:8,代码来源:test_impact_function_manager.py


示例7: test_available_exposures

 def test_available_exposures(self):
     """Test available_exposures API."""
     impact_function_manager = ImpactFunctionManager()
     result = impact_function_manager.available_exposures()
     expected_result = [
         exposure_structure, exposure_road, exposure_population]
     message = ('I expect %s but I got %s.' % (expected_result, result))
     self.assertItemsEqual(result, expected_result, message)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:8,代码来源:test_impact_function_manager.py


示例8: test_available_exposure_layer_modes

    def test_available_exposure_layer_modes(self):
        """Test for available_exposure_layer_modes."""
        ifm = ImpactFunctionManager()
        exposure_layer_mode = ifm.available_exposure_layer_modes(
            'population', 'raster')
        expected = [layer_mode_continuous]

        self.assertItemsEqual(exposure_layer_mode, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:8,代码来源:test_impact_function_manager.py


示例9: analysis_setup

def analysis_setup(command_line_arguments, hazard, exposure, aggregation=None):
    """Sets up an analysis object.

    .. versionadded:: 3.2

    :param command_line_arguments: User inputs.
    :type command_line_arguments: CommandLineArguments

    :param hazard: Hazard layer
    :type hazard: QgsLayer

    :param exposure: Exposure Layer
    :type exposure: QgsLayer

    :param aggregation: Aggregation Layer
    :type aggregation: QgsLayer

    :raises: Exception
    """
    # IF
    impact_function_manager = ImpactFunctionManager()
    impact_function = impact_function_manager.get(command_line_arguments.impact_function)
    keyword_io = KeywordIO()

    try:
        from safe.utilities.analysis import Analysis
    except ImportError as ie:
        LOGGER.debug("Import error for Analysis module")
        print ie.message
        raise ImportError
    analysis = Analysis()
    analysis.impact_function = impact_function
    analysis.hazard = hazard
    analysis.exposure = exposure
    analysis.aggregation = aggregation
    # analysis.hazard_keyword = keyword_io.read_keywords(hazard)
    # analysis.exposure_keyword = keyword_io.read_keywords(exposure)
    analysis.clip_hard = False
    analysis.show_intermediate_layers = False
    analysis.run_in_thread_flag = False
    analysis.map_canvas = CANVAS
    # QSetting context
    settings = QSettings()
    crs = settings.value("inasafe/analysis_extent_crs", "", type=str)
    analysis.user_extent_crs = QgsCoordinateReferenceSystem(crs)
    try:
        analysis.user_extent = QgsRectangle(
            float(command_line_arguments.extent[0]),
            float(command_line_arguments.extent[1]),
            float(command_line_arguments.extent[2]),
            float(command_line_arguments.extent[3]),
        )
    except AttributeError:
        print "No extents"
        pass
    analysis.setup_analysis()
    return analysis
开发者ID:codeforresilience,项目名称:inasafe,代码行数:57,代码来源:inasafe.py


示例10: test_available_exposure_constraints

    def test_available_exposure_constraints(self):
        """Test for available_exposure_constraints."""
        ifm = ImpactFunctionManager()
        exposure_constraints = ifm.available_exposure_constraints(
            'population')
        expected = [
            (layer_mode_continuous, layer_geometry_raster),
        ]

        self.assertItemsEqual(exposure_constraints, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:10,代码来源:test_impact_function_manager.py


示例11: test_exposure_class_fields

    def test_exposure_class_fields(self):
        """Test for exposure_class_fields."""
        ifm = ImpactFunctionManager()
        additional_keywords = ifm.exposure_class_fields(
            layer_mode_key='classified',
            layer_geometry_key='polygon',
            exposure_key='structure'
        )
        expected = [structure_class_field]

        self.assertItemsEqual(additional_keywords, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:11,代码来源:test_impact_function_manager.py


示例12: test_available_exposures

 def test_available_exposures(self):
     """Test available_exposures API."""
     impact_function_manager = ImpactFunctionManager()
     result = impact_function_manager.available_exposures()
     expected_result = [
         exposure_structure,
         exposure_road,
         exposure_population,
         exposure_place,
         exposure_land_cover]
     self.assertItemsEqual(result, expected_result)
开发者ID:easmetz,项目名称:inasafe,代码行数:11,代码来源:test_impact_function_manager.py


示例13: test_hazard_additional_keywords

    def test_hazard_additional_keywords(self):
        """Test for hazard_additional_keywords."""
        ifm = ImpactFunctionManager()
        additional_keywords = ifm.hazard_additional_keywords(
            layer_mode_key='classified',
            layer_geometry_key='polygon',
            hazard_category_key='single_event',
            hazard_key='flood'
        )
        expected = []

        self.assertItemsEqual(additional_keywords, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:12,代码来源:test_impact_function_manager.py


示例14: analysis_execution

def analysis_execution():

    from safe.test.utilities import get_qgis_app

    # get_qgis_app must be called before importing Analysis
    QGIS_APP, CANVAS, IFACE, PARENT = get_qgis_app()

    from safe.utilities.analysis import Analysis
    from safe.utilities.keyword_io import KeywordIO

    analysis = Analysis()

    arg = AnalysisArguments.read_arguments()

    register_impact_functions()

    registry = ImpactFunctionManager().registry

    function = registry.get_instance(arg.impact_function_name)

    hazard_layer = safe_to_qgis_layer(read_layer(arg.hazard_filename))
    exposure_layer = safe_to_qgis_layer(read_layer(arg.exposure_filename))
    if arg.aggregation_filename:
        aggregation_layer = safe_to_qgis_layer(read_layer(
            arg.aggregation_filename))

    keywords_io = KeywordIO()

    try:
        analysis.map_canvas = IFACE.mapCanvas()
        analysis.hazard_layer = hazard_layer
        analysis.hazard_keyword = keywords_io.read_keywords(hazard_layer)
        analysis.exposure_layer = exposure_layer
        analysis.exposure_keyword = keywords_io.read_keywords(exposure_layer)
        if aggregation_layer:
            analysis.aggregation_layer = aggregation_layer
            analysis.aggregation_keyword = keywords_io.read_keywords(
                aggregation_layer)
        analysis.impact_function = function

        analysis.setup_analysis()
        print 'Setup analysis done'
        analysis.run_analysis()
        print 'Analysis done'
    except Exception as e:
        print e.message

    impact = analysis.impact_layer
    qgis_impact = safe_to_qgis_layer(impact)

    generate_styles(impact, qgis_impact)

    copy_impact_layer(impact, arg.impact_filename)
开发者ID:inasafe,项目名称:inasafe-headless,代码行数:53,代码来源:run_analysis.py


示例15: test_available_hazard_constraints

    def test_available_hazard_constraints(self):
        """Test for available_hazard_constraints."""
        ifm = ImpactFunctionManager()
        hazard_constraints = ifm.available_hazard_constraints(
            'earthquake', 'single_event')
        expected = [
            (layer_mode_continuous, layer_geometry_raster),
            (layer_mode_classified, layer_geometry_raster),
            (layer_mode_classified, layer_geometry_polygon),
        ]

        print [(x[0]['key'], x[1]['key']) for x in hazard_constraints]
开发者ID:tomkralidis,项目名称:inasafe,代码行数:12,代码来源:test_impact_function_manager.py


示例16: test_exposures_for_layer

    def test_exposures_for_layer(self):
        """Test for exposures_for_layer"""
        impact_function_manager = ImpactFunctionManager()
        exposures = impact_function_manager.exposures_for_layer(
            'polygon')
        expected = [exposure_structure]
        self.assertItemsEqual(exposures, expected)

        exposures = impact_function_manager.exposures_for_layer(
            'line')
        expected = [exposure_road]
        self.assertItemsEqual(exposures, expected)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:12,代码来源:test_impact_function_manager.py


示例17: test_get_functions_for_hazard_id

 def test_get_functions_for_hazard_id(self):
     """Test get_functions_for_hazard_id API."""
     impact_function_manager = ImpactFunctionManager()
     result = impact_function_manager.get_functions_for_hazard_id(
         hazard_volcano['id'])
     expected_result = [
         VolcanoBuildingImpact.Metadata.get_metadata(),
         VolcanoPolygonHazardPopulation.Metadata.get_metadata(),
         ContinuousHazardPopulationImpactFunction.Metadata.get_metadata(),
         ClassifiedHazardBuildingImpactFunction.Metadata.get_metadata(),
         ClassifiedHazardPopulationImpactFunction.Metadata.get_metadata()]
     message = ('I expect %s but I got %s.' % (expected_result, result))
     self.assertItemsEqual(result, expected_result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:13,代码来源:test_impact_function_manager.py


示例18: test_get_available_hazards

    def test_get_available_hazards(self):
        """Test get_available_hazards API."""
        impact_function_manager = ImpactFunctionManager()

        result = impact_function_manager.get_available_hazards()
        expected_result = hazard_all
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertItemsEqual(result, expected_result, message)

        impact_function = EarthquakeBuildingImpactFunction()
        result = impact_function_manager.get_available_hazards(impact_function)
        expected_result = [hazard_earthquake]
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertItemsEqual(result, expected_result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:14,代码来源:test_impact_function_manager.py


示例19: test_get_functions_for_exposure_id

 def test_get_functions_for_exposure_id(self):
     """Test get_functions_for_exposure_id API."""
     impact_function_manager = ImpactFunctionManager()
     result = impact_function_manager.get_functions_for_exposure_id(
         exposure_structure['id'])
     expected_result = [
         VolcanoBuildingImpact.Metadata.get_metadata(),
         EarthquakeBuildingImpactFunction.Metadata.get_metadata(),
         FloodRasterBuildingImpactFunction.Metadata.get_metadata(),
         FloodVectorBuildingImpactFunction.Metadata.get_metadata(),
         FloodNativePolygonExperimentalFunction.Metadata.get_metadata(),
         ClassifiedHazardBuildingImpactFunction.Metadata.get_metadata()]
     message = ('I expect %s but I got %s.' % (expected_result, result))
     self.assertItemsEqual(result, expected_result, message)
开发者ID:severinmenard,项目名称:inasafe,代码行数:14,代码来源:test_impact_function_manager.py


示例20: show_impact_function_names

def show_impact_function_names(impact_functions):
    """Prints a list of impact functions.

    .. versionadded:: 3.2

    :param impact_functions: A list of impact function ids.
    :type: list of strings.
    """
    manager = ImpactFunctionManager()
    print ""
    print "Available Impact Function:"
    for impact_function in impact_functions:
        print manager.get_function_id(impact_function)
    print ""
开发者ID:codeforresilience,项目名称:inasafe,代码行数:14,代码来源:inasafe.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python registry.Registry类代码示例发布时间:2022-05-27
下一篇:
Python impact_function.ITBFatalityFunction类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap