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


Python HexModelGrid.add_field方法代码示例

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


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

示例1: test_flow__distance_irregular_grid_d4

# 需要导入模块: from landlab import HexModelGrid [as 别名]
# 或者: from landlab.HexModelGrid import add_field [as 别名]
def test_flow__distance_irregular_grid_d4():
    """Test to demonstrate that flow__distance utility works as expected with irregular grids"""

    # instantiate a model grid

    dx = 1.0
    hmg = HexModelGrid(5, 3, dx)

    # instantiate and add the elevation field

    hmg.add_field(
        "topographic__elevation", hmg.node_x + np.round(hmg.node_y), at="node"
    )

    # instantiate the expected flow__distance array

    flow__distance_expected = np.array(
        [
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
            dx,
            0.0,
            0.0,
            dx,
            dx,
            2.0 * dx,
            0.0,
            0.0,
            2.0 * dx,
            2.0 * dx,
            0.0,
            0.0,
            0.0,
            0.0,
        ]
    )

    # setting boundary conditions

    hmg.set_closed_nodes(hmg.boundary_nodes)

    # calculating flow directions with FlowAccumulator component: D4 algorithm

    fr = FlowAccumulator(hmg, flow_director="D4")
    fr.run_one_step()

    # calculating flow distance map

    flow__distance = calculate_flow__distance(hmg, add_to_grid=True, noclobber=False)

    # test that the flow__distance utility works as expected

    assert_almost_equal(flow__distance_expected, flow__distance, decimal=10)
开发者ID:landlab,项目名称:landlab,代码行数:58,代码来源:test_flow__distance.py

示例2: test_grid_type_testing

# 需要导入模块: from landlab import HexModelGrid [as 别名]
# 或者: from landlab.HexModelGrid import add_field [as 别名]
def test_grid_type_testing():
    """Test that only the right grids can be implemented."""
    dx = (2.0 / (3.0 ** 0.5)) ** 0.5
    hmg = HexModelGrid(3, 3, dx)
    hmg.add_field(
        "topographic__elevation", hmg.node_x + np.round(hmg.node_y), at="node"
    )

    # D8 is ONLY RASTER
    with pytest.raises(NotImplementedError):
        FlowDirectorD8(hmg)

    # DINF IS ONLY RASTER RASTER
    with pytest.raises(NotImplementedError):
        FlowDirectorDINF(hmg)
开发者ID:landlab,项目名称:landlab,代码行数:17,代码来源:test_flow_director.py

示例3: test_hex_mfd

# 需要导入模块: from landlab import HexModelGrid [as 别名]
# 或者: from landlab.HexModelGrid import add_field [as 别名]
def test_hex_mfd():
    mg = HexModelGrid(5, 3)
    mg.add_field("topographic__elevation", mg.node_x + mg.node_y, at="node")
    fa = LossyFlowAccumulator(mg, flow_director="MFD")
    fa.run_one_step()
开发者ID:cmshobe,项目名称:landlab,代码行数:7,代码来源:test_lossy_flow_accumulator.py


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