'Carbon Glacier Raster Model Grid\nClosed boundaries in blue, Outlet in white', var_name='elevation', var_units='m', grid_units=('m', 'm')) # ### Flow routing # #### Without depression finder/filler flow_accum = FlowAccumulator(rmg, surface='topographic__elevation', flow_director='FlowDirectorD8', depression_finder=None, runoff_rate=None) da, q = flow_accum.accumulate_flow() imshow_grid(rmg, 'drainage_area', plot_name='Contributing Area', var_name='Contributing Area', var_units='m^2', grid_units=('m', 'm')) fig = plt.gcf().set_size_inches(18.5, 10.5) # #### With depression finder/filler from landlab.components import DepressionFinderAndRouter flow_accum = FlowAccumulator(rmg, surface='topographic__elevation',
def test_lateral_erosion_and_node(): """ Test that sets up a simple, pre-defined drainage network and compares the lateral node that is eroded, the volume of lateral eorsion, and the elevation of the landscape after one timestep to known values. """ nr = 5 nc = 5 dx = 1 mg = RasterModelGrid((nr, nc), xy_spacing=dx) for edge in ( mg.nodes_at_top_edge, mg.nodes_at_bottom_edge, mg.nodes_at_left_edge, mg.nodes_at_right_edge, ): mg.status_at_node[edge] = CLOSED_BOUNDARY for edge in mg.nodes_at_bottom_edge: mg.status_at_node[edge] = FIXED_VALUE_BOUNDARY z = mg.add_zeros("node", "topographic__elevation") loading_vector = np.linspace(1, 4, num=nr) ramp = np.repeat(loading_vector, nc) # the tweaks to elevation below make lateral node at node 7 z += ramp z[11] -= 0.9 z[12] -= 0.4 z[8] -= 0.001 fa = FlowAccumulator( mg, surface="topographic__elevation", flow_director="FlowDirectorD8", runoff_rate=None, depression_finder=None, ) latero = LateralEroder(mg, latero_mech="UC", Kv=0.1, Kl_ratio=1.5) fa.accumulate_flow() (mg, dzlat) = latero.run_one_step(dt=1.0) vlname = mg["node"]["volume__lateral_erosion"] # predicted volume of lateral eorsion pred_vollat = 0.00045158164 # predicted elevation after 1 time step pred_zafter = np.array([ 1.0, 1.0, 1.0, 1.0, 1.0, 1.75, 1.675, 1.675, 1.6731154, 1.75, 2.5, 1.66418779, 2.06181623, 2.4249, 2.5, 3.25, 3.085, 3.13332738, 3.16868272, 3.25, 4.0, 4.0, 4.0, 4.0, 4.0, ]) testing.assert_array_almost_equal( mg.at_node["topographic__elevation"], pred_zafter, decimal=8, err_msg="LatEro basic erosion test failed", verbose=True, ) testing.assert_array_almost_equal( vlname[7], pred_vollat, decimal=8, err_msg="LatEro volume lateral erosion failed", verbose=True, )
# Set watershed boundary condition - use lowest elevation if basic call fails rmg.set_watershed_boundary_condition(z) fa = FlowAccumulator( rmg, # surface='topographic__elevation', flow_director='FlowDirectorD8', # runoff_rate=None, # depression_finder='DepressionFinderAndRouter', # routing='D4' ) fa.run_one_step() (da, q) = fa.accumulate_flow() outlet_node_to_sample = np.argmax(rmg.at_node['drainage_area']) print('Outlet Node = ' + str(outlet_node_to_sample) + '; Drainage Area= ' + str(da[outlet_node_to_sample] / 1000000) + ' km^2; Elev = ' + str(round(z[outlet_node_to_sample], 1)) + ' m') # For each of the links, there is a tail and head and node. # Look at tail nodes of all links, and look at node area, find link that connects #the link number that carries the largest q outlet_link_to_sample = rmg.links_at_node[outlet_node_to_sample][3] rmg.links_at_node[outlet_node_to_sample] imshow_grid_at_node(rmg, 'drainage_area')