當前位置: 首頁>>代碼示例>>Python>>正文


Python map.RasterMap類代碼示例

本文整理匯總了Python中gnome.map.RasterMap的典型用法代碼示例。如果您正苦於以下問題:Python RasterMap類的具體用法?Python RasterMap怎麽用?Python RasterMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RasterMap類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_some_cross_array

    def test_some_cross_array(self):
        """
        test a few LEs
        """

        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours

        # one left to right
        # one right to left
        # diagonal that doesn't hit
        # diagonal that does hit

        spill = sample_sc_release(4)

        spill['positions'] = np.array(((5.0, 5.0, 0.), (15.0, 5.0, 0.),
                (0., 0., 0.), (19.0, 0., 0.)), dtype=np.float64)

        spill['next_positions'] = np.array(((9.0, 5.0, 0.), (11.0, 5.0,
                0.), (9.0, 9.0, 0.), (0., 9.0, 0.)), dtype=np.float64)

        gmap.beach_elements(spill)

        assert np.array_equal(spill['next_positions'], ((9.0, 5.0, 0.),
                              (11.0, 5.0, 0.), (9.0, 9.0, 0.), (10.0,
                              4.0, 0.)))

        # just the beached ones

        assert np.array_equal((spill['last_water_positions'])[3:],
                              ((11.0, 4.0, 0.), ))

        assert np.array_equal((spill['status_codes'])[3:],
                              (oil_status.on_land, ))
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:35,代碼來源:test_map.py

示例2: test_land_cross

    def test_land_cross(self):
        """
        try a single LE that should be crossing land
        """

        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours

        spill = sample_sc_release(1)

        spill['positions'] = np.array(((5.0, 5.0, 0.), ),
                dtype=np.float64)
        spill['next_positions'] = np.array(((15.0, 5.0, 0.), ),
                dtype=np.float64)
        spill['status_codes'] = np.array((oil_status.in_water, ),
                dtype=status_code_type)

        gmap.beach_elements(spill)

        assert np.array_equal(spill['next_positions'][0], (10.0, 5.0,
                              0.))
        assert np.array_equal(spill['last_water_positions'][0], (9.0,
                              5.0, 0.))
        assert spill['status_codes'][0] == oil_status.on_land
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:25,代碼來源:test_map.py

示例3: test_land_cross_array

    def test_land_cross_array(self):
        """
        test a few LEs
        """

        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours

        # one left to right
        # one right to left
        # one diagonal upper left to lower right
        # one diagonal upper right to lower left

        spill = sample_sc_release(4)

        spill['positions'] = np.array(((5.0, 5.0, 0.), (15.0, 5.0, 0.),
                (0., 0., 0.), (19.0, 0., 0.)), dtype=np.float64)
        spill['next_positions'] = np.array(((15.0, 5.0, 0.), (5.0, 5.0,
                0.), (10.0, 5.0, 0.), (0., 9.0, 0.)), dtype=np.float64)
        gmap.beach_elements(spill)

        assert np.array_equal(spill['next_positions'], ((10.0, 5.0,
                              0.), (10.0, 5.0, 0.), (10.0, 5.0, 0.),
                              (10.0, 4.0, 0.)))

        assert np.array_equal(spill['last_water_positions'], ((9.0,
                              5.0, 0.), (11.0, 5.0, 0.), (9.0, 4.0,
                              0.), (11.0, 4.0, 0.)))

        assert np.alltrue(spill['status_codes'] == oil_status.on_land)
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:31,代碼來源:test_map.py

示例4: test_on_land

 def test_on_land(self):
     gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                      map_bounds=((-50, -30), (-50, 30), (50, 30),
                      (50, -30)), projection=NoProjection())  # hours
     assert gmap.on_land((10, 3, 0)) == 1
     assert gmap.on_land((9, 3, 0)) == 0
     assert gmap.on_land((11, 3, 0)) == 0
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:7,代碼來源:test_map.py

示例5: test_starts_on_land

    def test_starts_on_land(self):
        """
        try a single LE that starts on land

        it last water position should be the same point.
        """

        gmap = RasterMap(refloat_halflife=6,
                         bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)),
                         projection=NoProjection())  # hours

        spill = sample_sc_release(1)

        spill['positions'] = np.array(((10.0, 5.0, 0.), ),
                dtype=np.float64)
        spill['last_water_positions'] = np.array(((0.0, 0.0, 0.), ),
                dtype=np.float64)
        spill['next_positions'] = np.array(((15.0, 5.0, 0.), ),
                dtype=np.float64)
        spill['status_codes'] = np.array((oil_status.in_water, ),
                dtype=status_code_type)

        gmap.beach_elements(spill)
        
        ## next position gets set to land location
        assert np.array_equal(spill['next_positions'][0], (10.0, 5.0, 0.))
        assert np.array_equal(spill['last_water_positions'][0], (10.0, 5.0, 0.))
        assert spill['status_codes'][0] == oil_status.on_land
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:30,代碼來源:test_map.py

示例6: test_spillable_area2

    def test_spillable_area2(self):

        # a test with a polygon spillable area

        poly = ((5, 2), (15, 2), (15, 10), (10, 10), (10, 5))
        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection(),
                         spillable_area=[poly])  # hours

        # cases that are spillable

        assert gmap.allowable_spill_position((11.0, 3.0, 0.))
        assert gmap.allowable_spill_position((14.0, 9.0, 0.))

        # in polygon, but on land:

        assert not gmap.allowable_spill_position((11.0, 6.0, 0.))

        # outside polygon, on land:

        assert not gmap.allowable_spill_position((8.0, 6.0, 0.))

        # outside polygon, off land:

        assert not gmap.allowable_spill_position((3.0, 3.0, 0.))
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:26,代碼來源:test_map.py

示例7: test_on_map

    def test_on_map(self):
        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours
        assert gmap.on_map((0., 0., 0.))

        assert gmap.on_map((55.0, 0., 0.)) is False
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:7,代碼來源:test_map.py

示例8: test_save_as_image

    def test_save_as_image(self, dump):
        """
        only tests that it doesn't crash -- you need to look at the
        image to see if it's right
        """
        rmap = RasterMap(refloat_halflife=6,
                         bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),(50, -30)),
                         projection=NoProjection())

        rmap.save_as_image(os.path.join(dump, 'raster_map_image.png'))

        assert True
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:13,代碼來源:test_map.py

示例9: test_some_off_map

    def test_some_off_map(self):
        """
        Test LEs that go off the map

        should get off_map flag - no longer setting to_be_removed flag. map
        simply sets the off_maps flag.
        """

        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours

        spill = sample_sc_release(8)
        spill['positions'] = np.array((
            (45.0, 25.0, 0.),
            (45.0, 25.0, 0.),
            (45.0, -25.0, 0.),
            (45.0, -25.0, 0.),
            (-45.0, -25.0, 0.),
            (-45.0, -25.0, 0.),
            (-45.0, 25.0, 0.),
            (-45.0, 25.0, 0.),
            ), dtype=np.float64)

        spill['next_positions'] = np.array((  # off
                                              # still on
                                              # off
                                              # still on
                                              # off
                                              # still on
                                              # off
                                              # still on
            (55.0, 25.0, 0.),
            (49.0, 25.0, 0.),
            (45.0, -35.0, 0.),
            (45.0, -29.0, 0.),
            (-55.0, -25.0, 0.),
            (-49.0, -25.0, 0.),
            (-45.0, 35.0, 0.),
            (-45.0, 29.0, 0.),
            ), dtype=np.float64)

        gmap.beach_elements(spill)

        off = np.ones(4,) * oil_status.off_maps
        # off = np.ones(4) * oil_status.to_be_removed
        assert np.array_equal(spill['status_codes'][0::2], off)

        on = np.ones(4) * oil_status.in_water
        assert np.array_equal(spill['status_codes'][1::2], on)
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:50,代碼來源:test_map.py

示例10: test_spillable_area

    def test_spillable_area(self):
        # anywhere not on land is spillable...
        # in this case
        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30),
                                     (50, 30), (50, -30)),
                         projection=NoProjection())

        # right in the middle of land
        print 'testing a land point:'
        assert not gmap.allowable_spill_position((10, 6, 0.))

        print 'testing a water point:'
        assert gmap.allowable_spill_position((19.0, 11.0, 0.))
開發者ID:,項目名稱:,代碼行數:14,代碼來源:

示例11: test_outside_raster

    def test_outside_raster(self):
        """
        test LEs starting form outside the raster bounds
        """

        gmap = RasterMap(refloat_halflife=6, bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30), (50, 30),
                         (50, -30)), projection=NoProjection())  # hours

        # one left to right
        # one right to left
        # diagonal that doesn't hit
        # diagonal that does hit
        # spill = gnome.spill.Spill(num_LEs=4)

        spill = sample_sc_release(4)
        spill['positions'] = np.array(((30.0, 5.0, 0.), (-5.0, 5.0,
                0.), (5.0, -5.0, 0.), (-5.0, -5.0, 0.)),
                dtype=np.float64)  # outside right
                                   # outside left
                                   # outside top
                                   # outside upper left

        spill['next_positions'] = np.array(((15.0, 5.0, 0.), (5.0, 5.0,
                0.), (5.0, 15.0, 0.), (25.0, 15.0, 0.)),
                dtype=np.float64)

        gmap.beach_elements(spill)

        assert np.array_equal(spill['next_positions'], ((15.0, 5.0,
                              0.), (5.0, 5.0, 0.), (5.0, 15.0, 0.),
                              (10.0, 5.0, 0.)))

        # just the beached ones

        assert np.array_equal((spill['last_water_positions'])[3:],
                              ((9.0, 4.0, 0.), ))

        assert np.array_equal((spill['status_codes'])[3:],
                              (oil_status.on_land, ))
開發者ID:axiom-data-science,項目名稱:PyGnome,代碼行數:40,代碼來源:test_map.py

示例12: test__off_bitmap

    def test__off_bitmap(self):
        """
        test the _on_bitmap method
        """
        # overkill for just the bitmap..
        rmap = RasterMap(refloat_halflife=6,
                         bitmap_array=self.raster,
                         map_bounds=((-50, -30), (-50, 30),
                                     (50, 30), (50, -30)),
                         projection=NoProjection())

        # the corners
        assert not rmap._off_bitmap((0, 0))
        assert not rmap._off_bitmap((19, 0))
        assert not rmap._off_bitmap((19, 11))
        assert not rmap._off_bitmap((0, 11))

        # in the middle somewhere
        assert not rmap._off_bitmap((10, 6))

        # just off the edges
        assert rmap._off_bitmap((-1, 0))
        assert rmap._off_bitmap((19, -1))
        assert rmap._off_bitmap((20, 11))
        assert rmap._off_bitmap((0, 12))

        # way off -- just for the heck of it.
        assert rmap._off_bitmap((-1000, -2000))
        assert rmap._off_bitmap((1000, 2000))
開發者ID:,項目名稱:,代碼行數:29,代碼來源:


注:本文中的gnome.map.RasterMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。