Example #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)
Example #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)
uplift_per_step = uplift_rate * dt
print 'uplift per step: ', uplift_per_step

#create the field
z = mg.add_zeros('topographic__elevation', at='node')
z += leftmost_elev
z += initial_slope*np.amax(mg.node_y) - initial_slope*mg.node_y
#put these values plus roughness into that field
z += np.random.rand(len(z))/100000.

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])
Example #4
0
uplift_per_step = uplift_rate * dt
print 'uplift per step: ', uplift_per_step

#create the field
z = mg.add_zeros('topographic__elevation', at='node')
z += leftmost_elev
z += initial_slope * np.amax(mg.node_y) - initial_slope * mg.node_y
#put these values plus roughness into that field
z += np.random.rand(len(z)) / 100000.

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])