当前位置: 首页>>代码示例>>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;未经允许,请勿转载。