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


Python FlowRouter.run_one_step方法代码示例

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


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

示例1: test_voronoi_closedinternal

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_voronoi_closedinternal():
    """Test routing on a (radial) voronoi, but with a closed interior node."""
    vmg = RadialModelGrid(2, dr=2.)
    z = np.full(20, 10., dtype=float)
    all_bounds_but_one = np.array((0, 1, 2, 3, 4, 7, 11, 15, 16, 17, 18, 19))
    vmg.status_at_node[all_bounds_but_one] = CLOSED_BOUNDARY
    vmg.status_at_node[8] = CLOSED_BOUNDARY  # new internal closed
    z[12] = 0.  # outlet
    inner_elevs = (8., 7., 1., 6., 4., 5.)
    z[vmg.core_nodes] = np.array(inner_elevs)
    vmg.add_field("node", "topographic__elevation", z, units="-")
    with pytest.deprecated_call():
        fr = FlowRouter(vmg)

    cells_contributing = [
        np.array([0]),
        np.array([1]),
        np.array([0, 1, 3, 4, 5, 6]),
        np.array([1, 4]),
        np.array([1, 4, 5, 6]),
        np.array([1, 4, 6]),
    ]

    A_target_internal = np.zeros(vmg.number_of_core_nodes, dtype=float)
    for i in range(6):
        A_target_internal[i] = vmg.area_of_cell[cells_contributing[i]].sum()
    A_target_outlet = vmg.area_of_cell[vmg.cell_at_node[vmg.core_nodes]].sum()
    fr.run_one_step()

    assert vmg.at_node["drainage_area"][vmg.core_nodes] == pytest.approx(
        A_target_internal
    )
    assert vmg.at_node["drainage_area"][12] == pytest.approx(A_target_outlet)
开发者ID:cmshobe,项目名称:landlab,代码行数:35,代码来源:test_flow_routing.py

示例2: test_variable_Qin

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_variable_Qin(dans_grid1):
    """Test variable Qin field."""
    Qin_local = np.zeros(25, dtype=float)
    Qin_local[13] = 2.
    dans_grid1.mg.add_field("node", "water__unit_flux_in", Qin_local, units="m**3/s")
    with pytest.deprecated_call():
        fr = FlowRouter(dans_grid1.mg)
    fr.run_one_step()
    Qout_local = np.zeros_like(Qin_local)
    Qout_local[10:14] = 200.
    assert_array_equal(Qout_local, dans_grid1.mg.at_node["surface_water__discharge"])
    assert_array_equal(dans_grid1.A_target, dans_grid1.mg.at_node["drainage_area"])
开发者ID:cmshobe,项目名称:landlab,代码行数:14,代码来源:test_flow_routing.py

示例3: test_voronoi

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_voronoi():
    """Test routing on a (radial) voronoi."""
    vmg = RadialModelGrid(2, dr=2.)
    z = np.full(20, 10., dtype=float)
    # vmg.status_at_node[8:] = CLOSED_BOUNDARY
    all_bounds_but_one = np.array((0, 1, 2, 3, 4, 7, 11, 15, 16, 17, 18, 19))
    vmg.status_at_node[all_bounds_but_one] = CLOSED_BOUNDARY
    # z[7] = 0.  # outlet
    z[12] = 0.  # outlet
    # inner_elevs = (3., 1., 4., 5., 6., 7., 8.)
    inner_elevs = (8., 7., 3., 1., 6., 4., 5.)
    # z[:7] = np.array(inner_elevs)
    z[vmg.core_nodes] = np.array(inner_elevs)
    vmg.add_field("node", "topographic__elevation", z, units="-")
    with pytest.deprecated_call():
        fr = FlowRouter(vmg)

    #    nodes_contributing = [np.array([0, 3, 4, 5]),
    #                          np.array([0, 1, 2, 3, 4, 5, 6]),
    #                          np.array([2, ]),
    #                          np.array([3, ]),
    #                          np.array([4, ]),
    #                          np.array([5, ]),
    #                          np.array([6, ])]

    # The follow list contains arrays with the IDs of cells contributing flow
    # to nodes 5, 6, 8, 9, 10, 13, and 14, respectively (which correspond to
    # cells 0-6)
    cells_contributing = [
        np.array([0]),
        np.array([1]),
        np.array([1, 2, 4, 6]),
        np.array([0, 1, 2, 3, 4, 5, 6]),
        np.array([4]),
        np.array([5]),
        np.array([6]),
    ]

    A_target_core = np.zeros(vmg.number_of_core_nodes)
    for i in range(7):
        A_target_core[i] = vmg.area_of_cell[cells_contributing[i]].sum()
    A_target_outlet = vmg.area_of_cell.sum()
    fr.run_one_step()
    assert vmg.at_node["drainage_area"][vmg.core_nodes] == pytest.approx(A_target_core)
    assert vmg.at_node["drainage_area"][12] == pytest.approx(A_target_outlet)
开发者ID:cmshobe,项目名称:landlab,代码行数:47,代码来源:test_flow_routing.py

示例4: test_irreg_topo

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_irreg_topo(dans_grid2):
    """Test D8 routing on a toy irregular topo."""
    with pytest.deprecated_call():
        fr = FlowRouter(dans_grid2.mg)
    fr.run_one_step()
    assert_array_equal(dans_grid2.A_target_D8, dans_grid2.mg.at_node["drainage_area"])
    assert_array_equal(
        dans_grid2.frcvr_target_D8, dans_grid2.mg.at_node["flow__receiver_node"]
    )
    assert_array_equal(
        dans_grid2.upids_target_D8, dans_grid2.mg.at_node["flow__upstream_node_order"]
    )
    assert_array_equal(
        dans_grid2.links2rcvr_target_D8,
        dans_grid2.mg.at_node["flow__link_to_receiver_node"],
    )
    assert dans_grid2.steepest_target_D8 == pytest.approx(
        dans_grid2.mg.at_node["topographic__steepest_slope"]
    )
开发者ID:cmshobe,项目名称:landlab,代码行数:21,代码来源:test_flow_routing.py

示例5: test_internal_closed

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_internal_closed(internal_closed):
    """Test closed nodes in the core of the grid."""
    with pytest.deprecated_call():
        fr = FlowRouter(internal_closed.mg)
    fr.run_one_step()
    assert internal_closed.A_target == pytest.approx(
        internal_closed.mg.at_node["drainage_area"]
    )
    assert_array_equal(
        internal_closed.frcvr_target, internal_closed.mg.at_node["flow__receiver_node"]
    )
    assert_array_equal(
        internal_closed.links2rcvr_target,
        internal_closed.mg.at_node["flow__link_to_receiver_node"],
    )
    assert internal_closed.A_target == pytest.approx(
        internal_closed.mg.at_node["surface_water__discharge"]
    )
    assert internal_closed.steepest_target == pytest.approx(
        internal_closed.mg.at_node["topographic__steepest_slope"]
    )
开发者ID:cmshobe,项目名称:landlab,代码行数:23,代码来源:test_flow_routing.py

示例6: test_accumulate_D8

# 需要导入模块: from landlab.components.flow_routing import FlowRouter [as 别名]
# 或者: from landlab.components.flow_routing.FlowRouter import run_one_step [as 别名]
def test_accumulate_D8(dans_grid1):
    """Test accumulation works for D8 in a simple scenario."""
    with pytest.deprecated_call():
        fr = FlowRouter(dans_grid1.mg)
    fr.run_one_step()
    assert_array_equal(dans_grid1.A_target, dans_grid1.mg.at_node["drainage_area"])
    assert_array_equal(
        dans_grid1.frcvr_target, dans_grid1.mg.at_node["flow__receiver_node"]
    )
    assert_array_equal(
        dans_grid1.upids_target, dans_grid1.mg.at_node["flow__upstream_node_order"]
    )
    assert_array_equal(
        dans_grid1.links2rcvr_target,
        dans_grid1.mg.at_node["flow__link_to_receiver_node"],
    )
    assert_array_equal(
        dans_grid1.A_target, dans_grid1.mg.at_node["surface_water__discharge"]
    )
    assert_array_equal(
        dans_grid1.steepest_target, dans_grid1.mg.at_node["topographic__steepest_slope"]
    )
开发者ID:cmshobe,项目名称:landlab,代码行数:24,代码来源:test_flow_routing.py


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