Beispiel #1
0
def test_tl_fluvial():
    input_file = os.path.join(_THIS_DIR, 'stream_power_params_ideal.txt')
    inputs = ModelParameterDictionary(input_file)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    leftmost_elev = inputs.read_float('leftmost_elevation')
    initial_slope = inputs.read_float('initial_slope')
    uplift_rate = inputs.read_float('uplift_rate')

    runtime = inputs.read_float('total_time')
    dt = inputs.read_float('dt')

    nt = int(runtime // dt)
    uplift_per_step = uplift_rate * dt

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('node', 'topographic__elevation')
    z = np.loadtxt(os.path.join(_THIS_DIR, 'tl_init.txt'))
    mg['node']['topographic__elevation'] = z

    mg.set_closed_boundaries_at_grid_edges(True, False, True, False)
    mg.set_fixed_value_boundaries_at_grid_edges(
        False, True, False, True, value_of='topographic__elevation')

    fr = FlowRouter(mg)
    tl = TransportLimitedEroder(mg, input_file)

    for i in range(nt):
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift_per_step
        mg = fr.route_flow()
        mg, _ = tl.erode(mg, dt, stability_condition='loose')

    z_tg = np.loadtxt(os.path.join(_THIS_DIR, 'tlz_tg.txt'))
    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Beispiel #2
0
def test_tl_fluvial():
    input_file = os.path.join(_THIS_DIR, 'stream_power_params_ideal.txt')
    inputs = ModelParameterDictionary(input_file)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    leftmost_elev = inputs.read_float('leftmost_elevation')
    initial_slope = inputs.read_float('initial_slope')
    uplift_rate = inputs.read_float('uplift_rate')

    runtime = inputs.read_float('total_time')
    dt = inputs.read_float('dt')

    nt = int(runtime // dt)
    uplift_per_step = uplift_rate * dt

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('node', 'topographic__elevation')
    z = np.loadtxt(os.path.join(_THIS_DIR, 'tl_init.txt'))
    mg['node']['topographic__elevation'] = z

    mg.set_closed_boundaries_at_grid_edges(True, False, True, False)
    mg.set_fixed_value_boundaries_at_grid_edges(
        False, True, False, True, value_of='topographic__elevation')

    fr = FlowRouter(mg)
    tl = TransportLimitedEroder(mg, input_file)

    for i in range(nt):
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift_per_step
        mg = fr.route_flow()
        mg, _ = tl.erode(mg, dt, stability_condition='loose')

    z_tg = np.loadtxt(os.path.join(_THIS_DIR, 'tlz_tg.txt'))
    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
mg.status_at_node[mg.nodes_at_left_edge] = CLOSED_BOUNDARY
mg.status_at_node[mg.nodes_at_right_edge] = CLOSED_BOUNDARY

fr = FlowRouter(mg)
if DL_or_TL == 'TL':
    tle = TransportLimitedEroder(mg, input_file)
else:
    spe = StreamPowerEroder(mg, input_file)

for i in xrange(nt):
    # print 'loop ', i
    mg.at_node['topographic__elevation'][mg.core_nodes] += uplift_per_step
    mg = fr.route_flow(grid=mg)
    if DL_or_TL == 'TL':
        mg, _ = tle.erode(mg, dt)
    else:
        mg, _, _ = spe.erode(mg, dt=dt)
    if i % init_interval == 0:
        print 'loop ', i
        print 'max_slope', np.amax(mg.at_node['topographic__steepest_slope'][
            mg.core_nodes])
        pylab.figure("long_profiles_init")
        profile_IDs = prf.channel_nodes(
            mg, mg.at_node['topographic__steepest_slope'],
            mg.at_node['drainage_area'],
            mg.at_node['flow__receiver_node'])
        dists_upstr = prf.get_distances_upstream(mg, len(mg.at_node['topographic__steepest_slope']),
                                                profile_IDs, mg.at_node['flow__link_to_receiver_node'])
        prf.plot_profiles(dists_upstr, profile_IDs, mg.at_node['topographic__elevation'])
Beispiel #4
0
mg.status_at_node[mg.nodes_at_left_edge] = CLOSED_BOUNDARY
mg.status_at_node[mg.nodes_at_right_edge] = CLOSED_BOUNDARY

fr = FlowRouter(mg)
if DL_or_TL == 'TL':
    tle = TransportLimitedEroder(mg, input_file)
else:
    spe = StreamPowerEroder(mg, input_file)

for i in xrange(nt):
    # print 'loop ', i
    mg.at_node['topographic__elevation'][mg.core_nodes] += uplift_per_step
    mg = fr.route_flow(grid=mg)
    if DL_or_TL == 'TL':
        mg, _ = tle.erode(mg, dt)
    else:
        mg, _, _ = spe.erode(mg, dt=dt)
    if i % init_interval == 0:
        print 'loop ', i
        print 'max_slope', np.amax(
            mg.at_node['topographic__steepest_slope'][mg.core_nodes])
        pylab.figure("long_profiles_init")
        profile_IDs = prf.channel_nodes(
            mg, mg.at_node['topographic__steepest_slope'],
            mg.at_node['drainage_area'], mg.at_node['flow__receiver_node'])
        dists_upstr = prf.get_distances_upstream(
            mg, len(mg.at_node['topographic__steepest_slope']), profile_IDs,
            mg.at_node['flow__link_to_receiver_node'])
        prf.plot_profiles(dists_upstr, profile_IDs,
                          mg.at_node['topographic__elevation'])