예제 #1
0
    def test_runEarthquakeBuildingImpactFunction(self):
        """Earthquake function runs in GUI with An earthquake in Yogyakarta
        like in 2006 hazard data uses OSM Building Polygons exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='An earthquake in Yogyakarta like in 2006',
            exposure='OSM Building Polygons',
            function='Be affected',
            function_id='Earthquake Building Impact Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([101, -12, 119, -4])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of building might be affected
        assert format_int(786) in myResult, myMessage
        assert format_int(15528) in myResult, myMessage
        assert format_int(177) in myResult, myMessage
예제 #2
0
    def test_runEarthquakeBuildingImpactFunction(self):
        """Earthquake function runs in GUI with An earthquake in Yogyakarta
        like in 2006 hazard data uses OSM Building Polygons exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='An earthquake in Yogyakarta like in 2006',
            exposure='OSM Building Polygons',
            function='Be affected',
            function_id='Earthquake Building Impact Function')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([101, -12, 119, -4])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of building might be affected
        assert format_int(786) in myResult, myMessage
        assert format_int(15528) in myResult, myMessage
        assert format_int(177) in myResult, myMessage
예제 #3
0
파일: test_dock.py 프로젝트: D2KG/FLOOgin
    def test_runEarthquakeFatalityFunction_Padang_full(self):
        """Padang 2009 fatalities estimated correctly (large extent)"""

        # Push OK with the left mouse button

        button = DOCK.pbnRunStop
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([96, -5, 105, 2])  # This covers all of the 2009 shaking
        message = 'Run button was not enabled'
        self.assertTrue(button.isEnabled(), message)

        # Hazard layers
        index = DOCK.cboHazard.findText(PADANG2009_title)
        self.assertTrue(
            index != -1, 'Padang 2009 scenario hazard layer not found')
        DOCK.cboHazard.setCurrentIndex(index)

        # Exposure layers
        index = DOCK.cboExposure.findText('People')
        self.assertTrue(index != -1, 'People')
        DOCK.cboExposure.setCurrentIndex(index)

        # Choose impact function
        index = DOCK.cboFunction.findText('Earthquake Fatality Function')
        message = (
            'Earthquake Fatality Function not '
            'found: ' + combos_to_string(DOCK))
        self.assertTrue(index != -1, message)
        DOCK.cboFunction.setCurrentIndex(index)

        actual_dict = get_ui_state(DOCK)
        expected_dict = {
            'Hazard': PADANG2009_title,
            'Exposure': 'People',
            'Impact Function Id': 'Earthquake Fatality Function',
            'Impact Function Title': 'Earthquake Fatality Function',
            'Run Button Enabled': True}
        message = 'Got unexpected state: %s\nExpected: %s\n%s' % (
            actual_dict, expected_dict, combos_to_string(DOCK))
        self.assertTrue(actual_dict == expected_dict, message)

        DOCK.accept()

        result = DOCK.wvResults.page_to_text()

        # Check against expected output
        message = (
            'Unexpected result returned for Earthquake Fatality '
            'Function Expected: fatality count of '
            '500 , received: \n %s' % result)
        self.assertTrue(format_int(500) in result, message)

        message = (
            'Unexpected result returned for Earthquake Fatality '
            'Function Expected: total population count of '
            '31374747 , received: \n %s' % result)
        self.assertTrue(format_int(31374747) in result, message)
예제 #4
0
    def test_runEarthquakeFatalityFunction_Padang_full(self):
        """Padang 2009 fatalities estimated correctly (large extent)"""

        # Push OK with the left mouse button

        myButton = DOCK.pbnRunStop
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([96, -5, 105, 2])  # This covers all of the 2009 shaking
        myMessage = 'Run button was not enabled'
        assert myButton.isEnabled(), myMessage

        # Hazard layers
        myIndex = DOCK.cboHazard.findText(PADANG2009_title)
        assert myIndex != -1, 'Padang 2009 scenario hazard layer not found'
        DOCK.cboHazard.setCurrentIndex(myIndex)

        # Exposure layers
        myIndex = DOCK.cboExposure.findText('People')
        assert myIndex != -1, 'People'
        DOCK.cboExposure.setCurrentIndex(myIndex)

        # Choose impact function
        myIndex = DOCK.cboFunction.findText('Earthquake Fatality Function')
        myMessage = ('Earthquake Fatality Function not '
                     'found: ' + combos_to_string(DOCK))
        assert myIndex != -1, myMessage
        DOCK.cboFunction.setCurrentIndex(myIndex)

        myDict = get_ui_state(DOCK)
        myExpectedDict = {
            'Hazard': PADANG2009_title,
            'Exposure': 'People',
            'Impact Function Id': 'Earthquake Fatality Function',
            'Impact Function Title': 'Earthquake Fatality Function',
            'Run Button Enabled': True
        }
        myMessage = 'Got unexpected state: %s\nExpected: %s\n%s' % (
            myDict, myExpectedDict, combos_to_string(DOCK))
        assert myDict == myExpectedDict, myMessage

        DOCK.accept()

        myResult = DOCK.wvResults.page_to_text()

        # Check against expected output
        myMessage = ('Unexpected result returned for Earthquake Fatality '
                     'Function Expected: fatality count of '
                     '500 , received: \n %s' % myResult)
        assert format_int(500) in myResult, myMessage

        myMessage = ('Unexpected result returned for Earthquake Fatality '
                     'Function Expected: total population count of '
                     '31372262 , received: \n %s' % myResult)
        assert format_int(31372262) in myResult, myMessage
예제 #5
0
    def test_runVolcanoCirclePopulation(self):
        """Volcano function runs in GUI with a circular evacuation zone.

        Uses population density grid as exposure."""

        # NOTE: We assume radii in impact function to be 3, 5 and 10 km

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='Merapi Alert',
            exposure='People',
            function='Need evacuation',
            function_id='Volcano Polygon Hazard Population')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        myMemoryString = 'not have sufficient memory'
        if myMemoryString in myResult:
            # Test host did not have enough memory to run the test
            # and user was given a nice message stating this
            return
            # This is the expected number of people affected
        # Jarak [km]	Jumlah	Kumulatif
        # 3	     15.000	15.000
        # 5	     17.000	32.000
        # 10	124.000	156.000
        assert format_int(15000) in myResult, myMessage
        assert format_int(17000) in myResult, myMessage
        assert format_int(124000) in myResult, myMessage
예제 #6
0
    def test_runVolcanoPopulationImpact(self):
        """Volcano function runs in GUI with a donut (merapi hazard map)
         hazard data uses population density grid."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='donut',
            exposure='People',
            function='Need evacuation',
            function_id='Volcano Polygon Hazard Population')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of people affected
        # Kategori	Jumlah	Kumulatif
        # Kawasan Rawan Bencana III	45.000	45.000
        # Kawasan Rawan Bencana II	84.000	129.000
        # Kawasan Rawan Bencana I	28.000	157.000

        # We could also get a memory error here so there are
        # two plausible outcomes:

        # Outcome 1: we ran out of memory
        if 'system does not have sufficient memory' in myResult:
            return
            # Outcome 2: It ran so check the results
        assert format_int(45) in myResult, myMessage
        assert format_int(84) in myResult, myMessage
        assert format_int(28) in myResult, myMessage
예제 #7
0
    def test_runVolcanoCirclePopulation(self):
        """Volcano function runs in GUI with a circular evacuation zone.

        Uses population density grid as exposure."""

        # NOTE: We assume radii in impact function to be 3, 5 and 10 km

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='Merapi Alert',
            exposure='People',
            function='Need evacuation',
            function_id='Volcano Polygon Hazard Population')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        myMemoryString = 'not have sufficient memory'
        if myMemoryString in myResult:
            # Test host did not have enough memory to run the test
            # and user was given a nice message stating this
            return
            # This is the expected number of people affected
        # Jarak [km]	Jumlah	Kumulatif
        # 3	     15.000	15.000
        # 5	     17.000	32.000
        # 10	124.000	156.000
        assert format_int(15000) in myResult, myMessage
        assert format_int(17000) in myResult, myMessage
        assert format_int(124000) in myResult, myMessage
예제 #8
0
    def test_runVolcanoPopulationImpact(self):
        """Volcano function runs in GUI with a donut (merapi hazard map)
         hazard data uses population density grid."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='donut',
            exposure='People',
            function='Need evacuation',
            function_id='Volcano Polygon Hazard Population')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of people affected
        # Kategori	Jumlah	Kumulatif
        # Kawasan Rawan Bencana III	45.000	45.000
        # Kawasan Rawan Bencana II	84.000	129.000
        # Kawasan Rawan Bencana I	28.000	157.000

        # We could also get a memory error here so there are
        # two plausible outcomes:

        # Outcome 1: we ran out of memory
        if 'system does not have sufficient memory' in myResult:
            return
            # Outcome 2: It ran so check the results
        assert format_int(45) in myResult, myMessage
        assert format_int(84) in myResult, myMessage
        assert format_int(28) in myResult, myMessage
예제 #9
0
    def test_runVolcanoBuildingImpact(self):
        """Volcano function runs in GUI with An donut (merapi hazard map)
         hazard data uses OSM Building Polygons exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='donut',
            exposure='OSM Building Polygons',
            function='Be affected',
            function_id='Volcano Building Impact')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of building might be affected
        assert format_int(288) in myResult, myMessage
예제 #10
0
    def test_runVolcanoBuildingImpact(self):
        """Volcano function runs in GUI with An donut (merapi hazard map)
         hazard data uses OSM Building Polygons exposure data."""

        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='donut',
            exposure='OSM Building Polygons',
            function='Be affected',
            function_id='Volcano Building Impact')
        assert myResult, myMessage

        # Enable on-the-fly reprojection
        set_canvas_crs(GEOCRS, True)
        set_geo_extent([110.01, -7.81, 110.78, -7.50])

        # Press RUN
        DOCK.accept()
        myResult = DOCK.wvResults.page_to_text()
        LOGGER.debug(myResult)

        myMessage = 'Result not as expected: %s' % myResult
        # This is the expected number of building might be affected
        assert format_int(288) in myResult, myMessage