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


Python RasterMap.beach_elements方法代码示例

本文整理汇总了Python中gnome.map.RasterMap.beach_elements方法的典型用法代码示例。如果您正苦于以下问题:Python RasterMap.beach_elements方法的具体用法?Python RasterMap.beach_elements怎么用?Python RasterMap.beach_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnome.map.RasterMap的用法示例。


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

示例1: test_some_cross_array

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:37,代码来源:test_map.py

示例2: test_land_cross_array

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:33,代码来源:test_map.py

示例3: test_land_cross

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:27,代码来源:test_map.py

示例4: test_starts_on_land

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:32,代码来源:test_map.py

示例5: test_some_off_map

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:52,代码来源:test_map.py

示例6: test_outside_raster

# 需要导入模块: from gnome.map import RasterMap [as 别名]
# 或者: from gnome.map.RasterMap import beach_elements [as 别名]
    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,代码行数:42,代码来源:test_map.py


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