Exemplo n.º 1
0
def test_sp_discharges_new():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge_new.txt')
    inputs = ModelParameterDictionary(input_str)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([
        5., 5., 0., 5., 5., 5., 2., 1., 2., 5., 5., 3., 2., 3., 5., 5., 4., 4.,
        4., 5., 5., 5., 5., 5., 5.
    ])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sp.run_one_step(dt)

    z_tg = np.array([
        5.00000000e+00, 5.00000000e+00, 0.00000000e+00, 5.00000000e+00,
        5.00000000e+00, 5.00000000e+00, 1.29289322e+00, 1.00000000e-06,
        1.29289322e+00, 5.00000000e+00, 5.00000000e+00, 2.29289322e+00,
        1.00000000e+00, 2.29289322e+00, 5.00000000e+00, 5.00000000e+00,
        3.29289322e+00, 3.00000000e+00, 3.29289322e+00, 5.00000000e+00,
        5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00,
        5.00000000e+00
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 2
0
def test_storms():
    input_file_string = os.path.join(_THIS_DIR, 'drive_sp_params_storms.txt')
    inputs = ModelParameterDictionary(input_file_string)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')

    mg = RasterModelGrid(nrows, ncols, dx)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node')
    mg['node']['topographic__elevation'] = z + np.random.rand(len(z)) / 1000.
    mg.add_zeros('water__unit_flux_in', at='node')

    precip = PrecipitationDistribution(input_file=input_file_string)
    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    for (interval_duration, rainfall_rate) in \
            precip.yield_storm_interstorm_duration_intensity():
        if rainfall_rate != 0.:
            mg.at_node['water__unit_flux_in'].fill(rainfall_rate)
            mg = fr.route_flow()
            sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][
            mg.core_nodes] += uplift * interval_duration
def test_sp_discharges_new():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge_new.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([5., 5., 0., 5., 5.,
                  5., 2., 1., 2., 5.,
                  5., 3., 2., 3., 5.,
                  5., 4., 4., 4., 5.,
                  5., 5., 5., 5., 5.])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sp.run_one_step(dt)

    z_tg = np.array([5.        ,  5.        ,  0.        ,  5.        ,
                     5.        ,  5.        ,  1.47759225,  0.43050087,
                     1.47759225,  5.        ,  5.        ,  2.32883687,
                     1.21525044,  2.32883687,  5.        ,  5.        ,
                     3.27261262,  3.07175015,  3.27261262,  5.        ,
                     5.        ,  5.        ,  5.        ,  5.        ,
                     5.        ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 4
0
def test_sp_discharges_new():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge_new.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([
        5., 5., 0., 5., 5., 5., 2., 1., 2., 5., 5., 3., 2., 3., 5., 5., 4., 4.,
        4., 5., 5., 5., 5., 5., 5.
    ])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sp.run_one_step(dt)

    z_tg = np.array([
        5., 5., 0., 5., 5., 5., 1.47759225, 0.43050087, 1.47759225, 5., 5.,
        2.32883687, 1.21525044, 2.32883687, 5., 5., 3.27261262, 3.07175015,
        3.27261262, 5., 5., 5., 5., 5., 5.
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 5
0
def test_storms():
    input_file_string = os.path.join(_THIS_DIR, 'drive_sp_params_storms.txt')
    inputs = ModelParameterDictionary(input_file_string)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')

    mg = RasterModelGrid(nrows, ncols, dx)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node')
    mg['node']['topographic__elevation'] = z + np.random.rand(len(z)) / 1000.
    mg.add_zeros('water__unit_flux_in', at='node')

    precip = PrecipitationDistribution(input_file=input_file_string)
    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    for (interval_duration, rainfall_rate) in \
            precip.yield_storm_interstorm_duration_intensity():
        if rainfall_rate != 0.:
            mg.at_node['water__unit_flux_in'].fill(rainfall_rate)
            mg = fr.route_flow()
            sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][
            mg.core_nodes] += uplift * interval_duration
Exemplo n.º 6
0
def test_sp_voronoi():
    nnodes = 100

    np.random.seed(0)
    x = np.random.rand(nnodes)
    np.random.seed(1)
    y = np.random.rand(nnodes)
    mg = VoronoiDelaunayGrid(x, y)

    np.random.seed(2)
    z = mg.add_field('node', 'topographic__elevation',
                     np.random.rand(nnodes) / 10000., copy=False)

    fr = FlowRouter(mg)
    spe = StreamPowerEroder(mg, os.path.join(_THIS_DIR,
                                             'drive_sp_params_voronoi.txt'))

    for i in range(10):
        z[mg.core_nodes] += 0.01
        fr.route_flow()
        spe.erode(mg, 1.)

    z_tg = np.array([4.35994902e-05,   2.59262318e-06,   5.49662478e-05,
                     6.56738615e-03,   4.20367802e-05,   1.21371424e-02,
                     2.16596169e-02,   4.73320898e-02,   6.00389761e-02,
                     5.22007356e-02,   5.37507115e-02,   5.95794752e-02,
                     5.29862904e-02,   6.76465914e-02,   7.31720024e-02,
                     6.18730861e-02,   8.53975293e-05,   5.32189275e-02,
                     7.34302556e-02,   8.07385044e-02,   5.05246090e-05,
                     4.08940657e-02,   7.39971005e-02,   3.31915602e-02,
                     6.72650419e-02,   5.96745309e-05,   4.72752445e-02,
                     3.60359567e-02,   7.59432065e-02,   7.24461985e-02,
                     7.80305760e-02,   4.93866869e-02,   8.69642467e-02,
                     7.21627626e-02,   8.96368291e-02,   4.65142080e-02,
                     6.07720217e-02,   8.83372939e-02,   2.35887558e-02,
                     7.97616193e-02,   8.35615355e-02,   4.61809032e-02,
                     6.34634214e-02,   9.25711770e-02,   4.11717225e-03,
                     7.24493623e-02,   7.97908053e-02,   9.10375623e-02,
                     9.13155023e-02,   7.10567915e-02,   7.35271752e-02,
                     6.13091341e-02,   9.45498463e-02,   8.48532386e-02,
                     8.82702021e-02,   7.14969941e-02,   2.22640943e-02,
                     8.53311932e-02,   7.49161159e-02,   3.48837223e-02,
                     9.30132692e-02,   6.01817121e-05,   3.87455443e-02,
                     8.44673586e-02,   9.35213577e-02,   6.76075824e-02,
                     1.58614508e-02,   8.51346837e-02,   8.83645680e-02,
                     8.69944117e-02,   5.04000439e-05,   5.02319084e-02,
                     8.63882765e-02,   5.00991880e-02,   7.65156630e-02,
                     5.07591983e-02,   6.54909962e-02,   6.91505342e-02,
                     7.33358371e-02,   5.30109890e-02,   2.99074601e-02,
                     2.55509418e-06,   8.21523907e-02,   8.09368483e-02,
                     4.35073025e-02,   3.04096109e-02,   3.26298627e-02,
                     4.92259177e-02,   5.48690358e-02,   6.44732130e-02,
                     6.28133567e-02,   4.17977098e-06,   5.37149677e-02,
                     4.32828136e-02,   1.30559903e-02,   2.62405261e-02,
                     2.86079272e-02,   6.61481327e-05,   1.70477133e-05,
                     8.81652236e-05])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 7
0
def test_sp_voronoi():
    nnodes = 100

    np.random.seed(0)
    x = np.random.rand(nnodes)
    np.random.seed(1)
    y = np.random.rand(nnodes)
    mg = VoronoiDelaunayGrid(x, y)

    np.random.seed(2)
    z = mg.add_field('node', 'topographic__elevation',
                     np.random.rand(nnodes) / 10000., copy=False)

    fr = FlowRouter(mg)
    spe = StreamPowerEroder(mg, os.path.join(_THIS_DIR,
                                             'drive_sp_params_voronoi.txt'))

    for i in range(10):
        z[mg.core_nodes] += 0.01
        fr.route_flow()
        spe.erode(mg, 1.)

    z_tg = np.array([4.35994902e-05,   2.59262318e-06,   5.49662478e-05,
                     4.36094902e-05,   4.20367802e-05,   2.16664196e-03,
                     1.23484520e-02,   4.07654109e-02,   5.69974645e-02,
                     4.71086393e-02,   5.55056467e-02,   5.53655860e-02,
                     4.87984556e-02,   6.62132007e-02,   7.33132951e-02,
                     6.10003971e-02,   8.53975293e-05,   4.90709812e-02,
                     7.84728490e-02,   8.26091298e-02,   5.05246090e-05,
                     3.69289510e-02,   7.56743264e-02,   2.52850671e-02,
                     6.80517443e-02,   5.96745309e-05,   3.86335644e-02,
                     4.12526935e-02,   7.78476139e-02,   7.18165632e-02,
                     7.62359762e-02,   6.65702961e-02,   9.04684278e-02,
                     7.37203974e-02,   9.16862054e-02,   4.11168411e-02,
                     4.36498947e-02,   9.04430763e-02,   1.42123575e-02,
                     8.02734138e-02,   8.34895711e-02,   4.51564589e-02,
                     6.47124169e-02,   9.52317640e-02,   6.01917122e-05,
                     7.11667309e-02,   8.00463179e-02,   9.40668605e-02,
                     9.33247720e-02,   7.34011920e-02,   7.30924467e-02,
                     6.21387674e-02,   9.66278589e-02,   8.64266637e-02,
                     9.06100497e-02,   7.19991365e-02,   1.07162442e-02,
                     8.68685360e-02,   7.40515066e-02,   2.73264483e-02,
                     9.55406046e-02,   6.01817121e-05,   3.28663723e-02,
                     8.60706344e-02,   9.56285286e-02,   4.24741937e-02,
                     5.64139004e-03,   8.72373392e-02,   9.04304841e-02,
                     8.83708170e-02,   5.04000439e-05,   6.47845229e-02,
                     8.77304766e-02,   4.40894724e-02,   8.08029139e-02,
                     4.52732792e-02,   6.35806712e-02,   6.71004941e-02,
                     7.32682350e-02,   4.88067087e-02,   2.14920377e-02,
                     2.55509418e-06,   8.25346959e-02,   8.12610977e-02,
                     3.75778123e-02,   2.20818912e-02,   2.45940192e-02,
                     4.43365163e-02,   4.93255141e-02,   6.23517572e-02,
                     5.99594648e-02,   4.17977098e-06,   4.96450779e-02,
                     3.72952724e-02,   2.26332108e-03,   1.69925430e-02,
                     1.99835635e-02,   6.61481327e-05,   1.70477133e-05,
                     8.81652236e-05]  )

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 8
0
def test_sp_new():
    """
    Tests new style component instantiation and run.
    """
    input_str = os.path.join(_THIS_DIR, 'drive_sp_params.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')
    init_elev = inputs.read_float('init_elev')

    mg = RasterModelGrid((nrows, ncols), spacing=(dx, dx))
    mg.set_closed_boundaries_at_grid_edges(False, False, True, True)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node') + init_elev
    numpy.random.seed(0)
    mg['node']['topographic__elevation'] = z + \
        numpy.random.rand(len(z)) / 1000.

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)
    elapsed_time = 0.
    while elapsed_time < time_to_run:
        if elapsed_time + dt > time_to_run:
            dt = time_to_run - elapsed_time
        fr.route_flow()
        sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift * dt
        elapsed_time += dt

    z_trg = numpy.array([5.48813504e-04,   7.15189366e-04,   6.02763376e-04,
                         5.44883183e-04,   4.23654799e-04,   6.45894113e-04,
                         1.02783376e-02,   9.66667235e-03,   6.15060782e-03,
                         3.83441519e-04,   7.91725038e-04,   1.00905776e-02,
                         8.98955843e-03,   5.32836181e-03,   7.10360582e-05,
                         8.71292997e-05,   9.96377080e-03,   9.63738797e-03,
                         7.31213677e-03,   8.70012148e-04,   9.78618342e-04,
                         1.02124693e-02,   8.78386002e-03,   4.88161060e-03,
                         1.18274426e-04,   6.39921021e-04,   1.00377580e-02,
                         9.54340293e-03,   6.05173814e-03,   4.14661940e-04,
                         2.64555612e-04,   1.02160196e-02,   8.61600088e-03,
                         4.77005225e-03,   1.87898004e-05,   6.17635497e-04,
                         9.30445558e-03,   9.48713993e-03,   7.25689742e-03,
                         6.81820299e-04,   3.59507901e-04,   5.79161813e-03,
                         6.83777542e-03,   6.18063842e-03,   6.66766715e-04,
                         6.70637870e-04,   2.10382561e-04,   1.28926298e-04,
                         3.15428351e-04,   3.63710771e-04])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_trg)
Exemplo n.º 9
0
def test_sp_voronoi():
    nnodes = 100

    np.random.seed(0)
    x = np.random.rand(nnodes)
    np.random.seed(1)
    y = np.random.rand(nnodes)
    mg = VoronoiDelaunayGrid(x, y)

    np.random.seed(2)
    z = mg.add_field('node',
                     'topographic__elevation',
                     np.random.rand(nnodes) / 10000.,
                     copy=False)

    fr = FlowRouter(mg)
    spe = StreamPowerEroder(
        mg, os.path.join(_THIS_DIR, 'drive_sp_params_voronoi.txt'))

    for i in range(10):
        z[mg.core_nodes] += 0.01
        fr.route_flow()
        spe.erode(mg, 1.)

    z_tg = np.array([
        4.35994902e-05, 2.59262318e-06, 5.49662478e-05, 4.36094902e-05,
        4.20367802e-05, 2.16664196e-03, 1.23484520e-02, 4.07654109e-02,
        5.69974645e-02, 4.71086393e-02, 5.55056467e-02, 5.53655860e-02,
        4.87984556e-02, 6.62132007e-02, 7.33132951e-02, 6.10003971e-02,
        8.53975293e-05, 4.90709812e-02, 7.84728490e-02, 8.26091298e-02,
        5.05246090e-05, 3.69289510e-02, 7.56743264e-02, 2.52850671e-02,
        6.80517443e-02, 5.96745309e-05, 3.86335644e-02, 4.12526935e-02,
        7.78476139e-02, 7.18165632e-02, 7.62359762e-02, 6.65702961e-02,
        9.04684278e-02, 7.37203974e-02, 9.16862054e-02, 4.11168411e-02,
        4.36498947e-02, 9.04430763e-02, 1.42123575e-02, 8.02734138e-02,
        8.34895711e-02, 4.51564589e-02, 6.47124169e-02, 9.52317640e-02,
        6.01917122e-05, 7.11667309e-02, 8.00463179e-02, 9.40668605e-02,
        9.33247720e-02, 7.34011920e-02, 7.30924467e-02, 6.21387674e-02,
        9.66278589e-02, 8.64266637e-02, 9.06100497e-02, 7.19991365e-02,
        1.07162442e-02, 8.68685360e-02, 7.40515066e-02, 2.73264483e-02,
        9.55406046e-02, 6.01817121e-05, 3.28663723e-02, 8.60706344e-02,
        9.56285286e-02, 4.24741937e-02, 5.64139004e-03, 8.72373392e-02,
        9.04304841e-02, 8.83708170e-02, 5.04000439e-05, 6.47845229e-02,
        8.77304766e-02, 4.40894724e-02, 8.08029139e-02, 4.52732792e-02,
        6.35806712e-02, 6.71004941e-02, 7.32682350e-02, 4.88067087e-02,
        2.14920377e-02, 2.55509418e-06, 8.25346959e-02, 8.12610977e-02,
        3.75778123e-02, 2.20818912e-02, 2.45940192e-02, 4.43365163e-02,
        4.93255141e-02, 6.23517572e-02, 5.99594648e-02, 4.17977098e-06,
        4.96450779e-02, 3.72952724e-02, 2.26332108e-03, 1.69925430e-02,
        1.99835635e-02, 6.61481327e-05, 1.70477133e-05, 8.81652236e-05
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 10
0
def test_sp_new():
    """
    Tests new style component instantiation and run.
    """
    input_str = os.path.join(_THIS_DIR, 'drive_sp_params.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')
    init_elev = inputs.read_float('init_elev')

    mg = RasterModelGrid((nrows, ncols), spacing=(dx, dx))
    mg.set_closed_boundaries_at_grid_edges(False, False, True, True)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node') + init_elev
    numpy.random.seed(0)
    mg['node']['topographic__elevation'] = z + \
        numpy.random.rand(len(z)) / 1000.

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)
    elapsed_time = 0.
    while elapsed_time < time_to_run:
        if elapsed_time + dt > time_to_run:
            dt = time_to_run - elapsed_time
        fr.route_flow()
        sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift * dt
        elapsed_time += dt

    z_trg = numpy.array([5.48813504e-04,   7.15189366e-04,   6.02763376e-04,
                         5.44883183e-04,   4.23654799e-04,   6.45894113e-04,
                         1.01830760e-02,   9.58036770e-03,   6.55865452e-03,
                         3.83441519e-04,   7.91725038e-04,   1.00142749e-02,
                         8.80798884e-03,   5.78387585e-03,   7.10360582e-05,
                         8.71292997e-05,   9.81911417e-03,   9.52243406e-03,
                         7.55093226e-03,   8.70012148e-04,   9.78618342e-04,
                         1.00629755e-02,   8.49253798e-03,   5.33216680e-03,
                         1.18274426e-04,   6.39921021e-04,   9.88956320e-03,
                         9.47119567e-03,   6.43790696e-03,   4.14661940e-04,
                         2.64555612e-04,   1.00450743e-02,   8.37262908e-03,
                         5.21540904e-03,   1.87898004e-05,   6.17635497e-04,
                         9.21286940e-03,   9.34022513e-03,   7.51114450e-03,
                         6.81820299e-04,   3.59507901e-04,   6.19166921e-03,
                         7.10456176e-03,   6.62585507e-03,   6.66766715e-04,
                         6.70637870e-04,   2.10382561e-04,   1.28926298e-04,
                         3.15428351e-04,   3.63710771e-04])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_trg)
Exemplo n.º 11
0
def test_sp_new():
    """
    Tests new style component instantiation and run.
    """
    input_str = os.path.join(_THIS_DIR, 'drive_sp_params.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')
    init_elev = inputs.read_float('init_elev')

    mg = RasterModelGrid((nrows, ncols), spacing=(dx, dx))
    mg.set_closed_boundaries_at_grid_edges(False, False, True, True)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node') + init_elev
    numpy.random.seed(0)
    mg['node']['topographic__elevation'] = z + \
        numpy.random.rand(len(z)) / 1000.

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)
    elapsed_time = 0.
    while elapsed_time < time_to_run:
        if elapsed_time + dt > time_to_run:
            dt = time_to_run - elapsed_time
        fr.route_flow()
        sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift * dt
        elapsed_time += dt

    z_trg = numpy.array([
        5.48813504e-04, 7.15189366e-04, 6.02763376e-04, 5.44883183e-04,
        4.23654799e-04, 6.45894113e-04, 1.01830760e-02, 9.58036770e-03,
        6.55865452e-03, 3.83441519e-04, 7.91725038e-04, 1.00142749e-02,
        8.80798884e-03, 5.78387585e-03, 7.10360582e-05, 8.71292997e-05,
        9.81911417e-03, 9.52243406e-03, 7.55093226e-03, 8.70012148e-04,
        9.78618342e-04, 1.00629755e-02, 8.49253798e-03, 5.33216680e-03,
        1.18274426e-04, 6.39921021e-04, 9.88956320e-03, 9.47119567e-03,
        6.43790696e-03, 4.14661940e-04, 2.64555612e-04, 1.00450743e-02,
        8.37262908e-03, 5.21540904e-03, 1.87898004e-05, 6.17635497e-04,
        9.21286940e-03, 9.34022513e-03, 7.51114450e-03, 6.81820299e-04,
        3.59507901e-04, 6.19166921e-03, 7.10456176e-03, 6.62585507e-03,
        6.66766715e-04, 6.70637870e-04, 2.10382561e-04, 1.28926298e-04,
        3.15428351e-04, 3.63710771e-04
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_trg)
Exemplo n.º 12
0
def test_sp_new():
    """
    Tests new style component instantiation and run.
    """
    input_str = os.path.join(_THIS_DIR, 'drive_sp_params.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = inputs.read_int('nrows')
    ncols = inputs.read_int('ncols')
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')
    time_to_run = inputs.read_float('run_time')
    uplift = inputs.read_float('uplift_rate')
    init_elev = inputs.read_float('init_elev')

    mg = RasterModelGrid((nrows, ncols), spacing=(dx, dx))
    mg.set_closed_boundaries_at_grid_edges(False, False, True, True)

    mg.add_zeros('topographic__elevation', at='node')
    z = mg.zeros(at='node') + init_elev
    numpy.random.seed(0)
    mg['node']['topographic__elevation'] = z + \
        numpy.random.rand(len(z)) / 1000.

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)
    elapsed_time = 0.
    while elapsed_time < time_to_run:
        if elapsed_time + dt > time_to_run:
            dt = time_to_run - elapsed_time
        fr.route_flow()
        sp.run_one_step(dt)
        mg.at_node['topographic__elevation'][mg.core_nodes] += uplift * dt
        elapsed_time += dt

    z_trg = numpy.array([
        5.48813504e-04, 7.15189366e-04, 6.02763376e-04, 5.44883183e-04,
        4.23654799e-04, 6.45894113e-04, 1.02783376e-02, 9.66667235e-03,
        6.15060782e-03, 3.83441519e-04, 7.91725038e-04, 1.00905776e-02,
        8.98955843e-03, 5.32836181e-03, 7.10360582e-05, 8.71292997e-05,
        9.96377080e-03, 9.63738797e-03, 7.31213677e-03, 8.70012148e-04,
        9.78618342e-04, 1.02124693e-02, 8.78386002e-03, 4.88161060e-03,
        1.18274426e-04, 6.39921021e-04, 1.00377580e-02, 9.54340293e-03,
        6.05173814e-03, 4.14661940e-04, 2.64555612e-04, 1.02160196e-02,
        8.61600088e-03, 4.77005225e-03, 1.87898004e-05, 6.17635497e-04,
        9.30445558e-03, 9.48713993e-03, 7.25689742e-03, 6.81820299e-04,
        3.59507901e-04, 5.79161813e-03, 6.83777542e-03, 6.18063842e-03,
        6.66766715e-04, 6.70637870e-04, 2.10382561e-04, 1.28926298e-04,
        3.15428351e-04, 3.63710771e-04
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_trg)
Exemplo n.º 13
0
def test_sp_widths():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_widths.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    widths = np.ones(mg.number_of_nodes, dtype=float)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([5., 5., 0., 5., 5.,
                  5., 2., 1., 2., 5.,
                  5., 3., 2., 3., 5.,
                  5., 4., 4., 4., 5.,
                  5., 5., 5., 5., 5.])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, use_W=widths, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sqrt_A = mg.at_node['drainage_area']**0.5
        widths[mg.core_nodes] = sqrt_A[mg.core_nodes]/sqrt_A[
            mg.core_nodes].mean()
        # so widths has mean=1.
        # note the issue with drainage_area not defined at perimeter => nans
        # if not careful...
        sp.run_one_step(dt)

    z_tg = np.array([ 5.        ,  5.        ,  0.        ,  5.        ,
                      5.        ,  5.        ,  1.37222369,  0.36876358,
                      1.37222369,  5.        ,  5.        ,  2.17408606,
                      1.07986038,  2.17408606,  5.        ,  5.        ,
                      3.08340277,  2.85288049,  3.08340277,  5.        ,
                      5.        ,  5.        ,  5.        ,  5.        ,
                      5.        ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 14
0
def test_sp_discharges_old():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge.txt')
    inputs = ModelParameterDictionary(input_str)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([
        5., 5., 0., 5., 5., 5., 2., 1., 2., 5., 5., 3., 2., 3., 5., 5., 4., 4.,
        4., 5., 5., 5., 5., 5., 5.
    ])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, input_str)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        my_Q = mg.at_node['water__volume_flux'] * 1.
        sp.erode(mg,
                 dt,
                 node_drainage_areas='drainage_area',
                 slopes_at_nodes='topographic__steepest_slope',
                 Q_if_used=my_Q)

    z_tg = np.array([
        5.00000000e+00, 5.00000000e+00, 0.00000000e+00, 5.00000000e+00,
        5.00000000e+00, 5.00000000e+00, 1.29289322e+00, 1.00000000e-06,
        1.29289322e+00, 5.00000000e+00, 5.00000000e+00, 2.29289322e+00,
        1.00000000e+00, 2.29289322e+00, 5.00000000e+00, 5.00000000e+00,
        3.29289322e+00, 3.00000000e+00, 3.29289322e+00, 5.00000000e+00,
        5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00,
        5.00000000e+00
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 15
0
def test_sp_discharges():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge.txt')
    inputs = ModelParameterDictionary(input_str)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([5., 5., 0., 5., 5.,
                  5., 2., 1., 2., 5.,
                  5., 3., 2., 3., 5.,
                  5., 4., 4., 4., 5.,
                  5., 5., 5., 5., 5.])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, input_str)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow(method='D8')
        my_Q = mg.at_node['water__volume_flux'] * 1.
        sp.erode(mg, dt, node_drainage_areas='drainage_area',
                 slopes_at_nodes='topographic__steepest_slope',
                 Q_if_used=my_Q)

    z_tg = np.array([5.00000000e+00,   5.00000000e+00,   0.00000000e+00,
                     5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
                     1.29289322e+00,   1.00000000e-06,   1.29289322e+00,
                     5.00000000e+00,   5.00000000e+00,   2.29289322e+00,
                     1.00000000e+00,   2.29289322e+00,   5.00000000e+00,
                     5.00000000e+00,   3.29289322e+00,   3.00000000e+00,
                     3.29289322e+00,   5.00000000e+00,   5.00000000e+00,
                     5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
                     5.00000000e+00])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 16
0
def test_sp_widths():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_widths.txt')
    inputs = ModelParameterDictionary(input_str, auto_type=True)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    widths = np.ones(mg.number_of_nodes, dtype=float)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([
        5., 5., 0., 5., 5., 5., 2., 1., 2., 5., 5., 3., 2., 3., 5., 5., 4., 4.,
        4., 5., 5., 5., 5., 5., 5.
    ])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, use_W=widths, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sqrt_A = mg.at_node['drainage_area']**0.5
        widths[mg.core_nodes] = sqrt_A[mg.core_nodes] / sqrt_A[
            mg.core_nodes].mean()
        # so widths has mean=1.
        # note the issue with drainage_area not defined at perimeter => nans
        # if not careful...
        sp.run_one_step(dt)

    z_tg = np.array([
        5., 5., 0., 5., 5., 5., 1.37222369, 0.36876358, 1.37222369, 5., 5.,
        2.17408606, 1.07986038, 2.17408606, 5., 5., 3.08340277, 2.85288049,
        3.08340277, 5., 5., 5., 5., 5., 5.
    ])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 17
0
def test_sp_discharges_new():
    input_str = os.path.join(_THIS_DIR, 'test_sp_params_discharge_new.txt')
    inputs = ModelParameterDictionary(input_str)
    nrows = 5
    ncols = 5
    dx = inputs.read_float('dx')
    dt = inputs.read_float('dt')

    mg = RasterModelGrid(nrows, ncols, dx)
    mg.add_zeros('topographic__elevation', at='node')
    z = np.array([5., 5., 0., 5., 5.,
                  5., 2., 1., 2., 5.,
                  5., 3., 2., 3., 5.,
                  5., 4., 4., 4., 5.,
                  5., 5., 5., 5., 5.])
    mg['node']['topographic__elevation'] = z

    fr = FlowRouter(mg)
    sp = StreamPowerEroder(mg, **inputs)

    # perform the loop (once!)
    for i in range(1):
        fr.route_flow()
        sp.run_one_step(dt)

    z_tg = np.array([5.00000000e+00,   5.00000000e+00,   0.00000000e+00,
                     5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
                     1.29289322e+00,   1.00000000e-06,   1.29289322e+00,
                     5.00000000e+00,   5.00000000e+00,   2.29289322e+00,
                     1.00000000e+00,   2.29289322e+00,   5.00000000e+00,
                     5.00000000e+00,   3.29289322e+00,   3.00000000e+00,
                     3.29289322e+00,   5.00000000e+00,   5.00000000e+00,
                     5.00000000e+00,   5.00000000e+00,   5.00000000e+00,
                     5.00000000e+00])

    assert_array_almost_equal(mg.at_node['topographic__elevation'], z_tg)
Exemplo n.º 18
0
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000.
mg.add_zeros('node', 'water__unit_flux_in')

#make some K values in a field to test
#mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
mg.at_node['K_values'] = numpy.empty(nrows * ncols, dtype=float)
#mg.at_node['K_values'].fill(0.1+numpy.random.rand()/10.)
mg.at_node['K_values'].fill(0.001)

print('Running ...')

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file_string)
#fsp = FastscapeEroder(mg, input_file_string)
precip = PrecipitationDistribution(input_file=input_file_string)

#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, input_file_string)

try:
    #raise NameError
    mg = copy.deepcopy(mg_mature)
except NameError:
    print('building a new grid...')
    out_interval = 50000.
    last_trunc = time_to_run  #we use this to trigger taking an output plot
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
Exemplo n.º 19
0
mg = RasterModelGrid((nrows, ncols), xy_spacing=dx)

# create the fields in the grid
mg.add_zeros("topographic__elevation", at="node")
z = mg.zeros(at="node") + init_elev
mg["node"]["topographic__elevation"] = z + numpy.random.rand(len(z)) / 1000.

# make some K values in a field to test
mg.at_node["K_values"] = 0.1 + numpy.random.rand(nrows * ncols) / 10.

print("Running ...")
time_on = time.time()

# instantiate the components:
fr = FlowAccumulator(mg, flow_director="D8")
sp = StreamPowerEroder(mg, "./drive_sp_params.txt")
# load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, "./drive_sp_params.txt")

# perform the loop:
elapsed_time = 0.  # total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.run_one_step()
    # print 'Area: ', numpy.max(mg.at_node['drainage_area'])
    # mg = fsp.erode(mg)
    mg, _, _ = sp.erode(
        mg,
Exemplo n.º 20
0
rock_stress_param = inputs.read_float("rock_density") * 9.81

mg = RasterModelGrid(nrows, ncols, dx)

# create the fields in the grid
mg.add_zeros("topographic__elevation", at="node")
z = mg.zeros(at="node") + init_elev
mg["node"]["topographic__elevation"] = z + np.random.rand(len(z)) / 1000.

# make some surface load stresses in a field to test
mg.at_node["surface_load__stress"] = np.zeros(nrows * ncols, dtype=float)

# instantiate:
gf = gFlex(mg, "./coupled_SP_gflex_params.txt")
fsp = FastscapeEroder(mg, "./coupled_SP_gflex_params.txt")
sp = StreamPowerEroder(mg, "./coupled_SP_gflex_params.txt")
fr = FlowAccumulator(mg, flow_director="D8")

# perform the loop:
elapsed_time = 0.  # total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.run_one_step()
    # mg = fsp.erode(mg)
    mg, _, _ = sp.erode(
        mg,
        dt,
        node_drainage_areas="drainage_area",
Exemplo n.º 21
0
rock_stress_param = inputs.read_float('rock_density')*9.81

mg = RasterModelGrid(nrows, ncols, dx)

#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node'][ 'topographic__elevation'] = z + np.random.rand(len(z))/1000.

#make some surface load stresses in a field to test
mg.at_node['surface_load__stress'] = np.zeros(nrows*ncols, dtype=float)

#instantiate:
gf = gFlex(mg, './coupled_SP_gflex_params.txt')
fsp = FastscapeEroder(mg, './coupled_SP_gflex_params.txt')
sp = StreamPowerEroder(mg, './coupled_SP_gflex_params.txt')
fr = FlowRouter(mg)

#perform the loop:
elapsed_time = 0. #total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time+dt>time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.route_flow()
    #mg = fsp.erode(mg)
    mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='topographic__steepest_slope')
    mg.at_node['surface_load__stress'] = (mg.at_node['topographic__elevation']+1000)*rock_stress_param
    gf.flex_lithosphere()
    mg.at_node['topographic__elevation'][mg.number_of_nodes//4:3.*mg.number_of_nodes//4] += uplift_perstep
Exemplo n.º 22
0
#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000.

#make some K values in a field to test
mg.at_node['K_values'] = 0.1 + numpy.random.rand(nrows * ncols) / 10.
mg.set_closed_boundaries_at_grid_edges(False, True, True, True)

print('Running ...')
time_on = time.time()

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, './drive_sp_params.txt')

#perform the loop:
elapsed_time = 0.  #total time in simulation
counter = 0.
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.route_flow(method='D8')
    #print 'Area: ', numpy.max(mg.at_node['drainage_area'])
    #mg = fsp.erode(mg)
    mg, _, _ = sp.erode(mg,
Exemplo n.º 23
0
mg = RasterModelGrid(nrows, ncols, dx)

# create the fields in the grid
mg.add_zeros("topographic__elevation", at="node")
z = mg.zeros(at="node") + init_elev
mg["node"]["topographic__elevation"] = z + numpy.random.rand(len(z)) / 1000.

# make some K values in a field to test
mg.at_node["K_values"] = 0.1 + numpy.random.rand(nrows * ncols) / 10.

print("Running ...")
time_on = time.time()

# instantiate the components:
fr = FlowAccumulator(mg, flow_director="D8")
sp = StreamPowerEroder(mg, "./drive_sp_params.txt")
# load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, "./drive_sp_params.txt")

# perform the loop:
elapsed_time = 0.  # total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.run_one_step()
    # print 'Area: ', numpy.max(mg.at_node['drainage_area'])
    # mg = fsp.erode(mg)
    mg, _, _ = sp.erode(
        mg,
        4.0,
        5.0,
        5.0,
        5.0,
        5.0,
        5.0,
        5.0,
    ]
)
mg["node"]["topographic__elevation"] = z

print("Running ...")

# instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, "./drive_sp_params_discharge.txt")
# load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, "./drive_sp_params_discharge.txt")

# perform the loop (once!)
for i in range(1):
    fr.route_flow(method="D8")
    my_Q = mg.at_node["water__discharge"] * 1.0
    sp.erode(mg, dt, node_drainage_areas="drainage_area", slopes_at_nodes="topographic__steepest_slope", Q_if_used=my_Q)
    # no uplift

# print the stream power that was calculated:
print("stream power values:")
print(mg.at_node["stream_power_erosion"])

# Finalize and plot
Exemplo n.º 25
0
rock_stress_param = inputs.read_float("rock_density") * 9.81

mg = RasterModelGrid((nrows, ncols), xy_spacing=dx)

# create the fields in the grid
mg.add_zeros("topographic__elevation", at="node")
z = mg.zeros(at="node") + init_elev
mg["node"]["topographic__elevation"] = z + np.random.rand(len(z)) / 1000.

# make some surface load stresses in a field to test
mg.at_node["surface_load__stress"] = np.zeros(nrows * ncols, dtype=float)

# instantiate:
gf = gFlex(mg, "./coupled_SP_gflex_params.txt")
fsp = FastscapeEroder(mg, "./coupled_SP_gflex_params.txt")
sp = StreamPowerEroder(mg, "./coupled_SP_gflex_params.txt")
fr = FlowAccumulator(mg, flow_director="D8")

# perform the loop:
elapsed_time = 0.  # total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.run_one_step()
    # mg = fsp.erode(mg)
    mg, _, _ = sp.erode(
        mg,
        dt,
        node_drainage_areas="drainage_area",
Exemplo n.º 26
0
#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node'][ 'topographic__elevation'] = z + numpy.random.rand(len(z))/1000.

#make some K values in a field to test 
mg.at_node['K_values'] = 1.e-6+numpy.random.rand(nrows*ncols)*1.e-8

mg.set_closed_boundaries_at_grid_edges(False, True, True, True)

print( 'Running ...' )

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
fsp = Fsc(mg, './drive_sp_params.txt')

#load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, './drive_sp_params.txt')
#vid = VideoPlotter(mg, data_centering='node', step=2.5)

try:
    mg = copy.deepcopy(mg_mature)
except NameError:
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
    elapsed_time = 0. #total time in simulation
    while elapsed_time < time_to_run:
        print(elapsed_time)
        if elapsed_time+dt>time_to_run:
Exemplo n.º 27
0
#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
#z += mg.node_x*0.001
mg['node'][ 'topographic__elevation'] = z + numpy.random.rand(len(z))/1000.

#make some K values in a field to test
mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.

print( 'Running ...' )
time_on = time.time()

#instantiate the components:
fr = FlowAccumulator(mg, flow_director='D8')
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
lf = DepressionFinderAndRouter(mg)
#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, './drive_sp_params.txt')

#perform the loop:
elapsed_time = 0. #total time in simulation
while elapsed_time < time_to_run:
#for i in range(10):
    print(elapsed_time)
    if elapsed_time+dt>time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.route_flow(method='D8')
    lf.map_depressions()
    #print 'Area: ', numpy.max(mg.at_node['drainage_area'])
Exemplo n.º 28
0
#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000.

#make some K values in a field to test
mg.at_node['K_values'] = 1.e-6 + numpy.random.rand(nrows * ncols) * 1.e-8

mg.set_closed_boundaries_at_grid_edges(False, True, True, True)

print('Running ...')

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
fsp = Fsc(mg, './drive_sp_params.txt')

#load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, './drive_sp_params.txt')
#vid = VideoPlotter(mg, data_centering='node', step=2.5)

try:
    mg = copy.deepcopy(mg_mature)
except NameError:
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
    elapsed_time = 0.  #total time in simulation
    while elapsed_time < time_to_run:
        print(elapsed_time)
        if elapsed_time + dt > time_to_run:
Exemplo n.º 29
0
# create the fields in the grid
mg.add_zeros("topographic__elevation", at="node")
z = mg.zeros(at="node") + init_elev
mg["node"]["topographic__elevation"] = z + numpy.random.rand(len(z)) / 1000.0

# make some K values in a field to test
mg.at_node["K_values"] = 1.0e-6 + numpy.random.rand(nrows * ncols) * 1.0e-8

mg.set_closed_boundaries_at_grid_edges(False, True, True, True)

print("Running ...")

# instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, "./drive_sp_params.txt")
fsp = Fsc(mg, "./drive_sp_params.txt")

# load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, "./drive_sp_params.txt")
# vid = VideoPlotter(mg, data_centering='node', step=2.5)

try:
    mg = copy.deepcopy(mg_mature)
except NameError:
    # run to a steady state:
    # We're going to cheat by running Fastscape SP for the first part of the solution
    elapsed_time = 0.0  # total time in simulation
    while elapsed_time < time_to_run:
        print(elapsed_time)
        if elapsed_time + dt > time_to_run:
Exemplo n.º 30
0
from six.moves import range

from landlab import VoronoiDelaunayGrid
from landlab.components.flow_routing import FlowRouter
from landlab.components.stream_power import StreamPowerEroder
from landlab.plot.imshow import imshow_node_grid
import numpy as np
from matplotlib.pyplot import figure, show

nnodes = 10000

x, y = np.random.rand(nnodes), np.random.rand(nnodes)
mg = VoronoiDelaunayGrid(x,y)

z = mg.add_field('node', 'topographic__elevation', np.random.rand(nnodes)/10000., copy=False)

fr = FlowRouter(mg)
spe = StreamPowerEroder(mg, 'drive_sp_params_voronoi.txt')

for i in range(100):
    z[mg.core_nodes] += 0.01
    fr.route_flow()
    spe.erode(mg, 1.)

imshow_node_grid(mg, 'topographic__elevation')

show()
Exemplo n.º 31
0
mg = RasterModelGrid(nrows, ncols, dx)

#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000.

#make some K values in a field to test
mg.at_node['K_values'] = 0.1 + numpy.random.rand(nrows * ncols) / 10.

print('Running ...')

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, './drive_sp_params.txt')

#perform the loop:
elapsed_time = 0.  #total time in simulation
while elapsed_time < time_to_run:
    print(elapsed_time)
    if elapsed_time + dt > time_to_run:
        print("Short step!")
        dt = time_to_run - elapsed_time
    mg = fr.route_flow()
    #print 'Area: ', numpy.max(mg.at_node['drainage_area'])
    #mg = fsp.erode(mg)
    mg = fsp.erode(mg, K_if_used='K_values')
    #mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='topographic__steepest_slope')
Exemplo n.º 32
0
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node'][ 'topographic__elevation'] = z + numpy.random.rand(len(z))/1000.
mg.add_zeros('node', 'water__unit_flux_in')

#make some K values in a field to test
#mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
mg.at_node['K_values'] = numpy.empty(nrows*ncols, dtype=float)
#mg.at_node['K_values'].fill(0.1+numpy.random.rand()/10.)
mg.at_node['K_values'].fill(0.001)

print( 'Running ...' )

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file_string)
#fsp = FastscapeEroder(mg, input_file_string)
precip = PrecipitationDistribution(input_file=input_file_string)

#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, input_file_string)

try:
    #raise NameError
    mg = copy.deepcopy(mg_mature)
except NameError:
    print('building a new grid...')
    out_interval = 50000.
    last_trunc = time_to_run #we use this to trigger taking an output plot
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution
Exemplo n.º 33
0
mg = RasterModelGrid(nrows, ncols, dx)

# create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = np.array([5., 5., 0., 5., 5.,
              5., 2., 1., 2., 5.,
              5., 3., 2., 3., 5.,
              5., 4., 4., 4., 5.,
              5., 5., 5., 5., 5.])
mg['node']['topographic__elevation'] = z

print('Running ...')

# instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params_discharge.txt')
# load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, './drive_sp_params_discharge.txt')

# perform the loop (once!)
for i in range(1):
    fr.route_flow(method='D8')
    my_Q = mg.at_node['water__volume_flux']*1.
    sp.erode(mg, dt, node_drainage_areas='drainage_area',
             slopes_at_nodes='topographic__steepest_slope',
             Q_if_used=my_Q)
    # no uplift

# print the stream power that was calculated:
print('stream power values:')
print(mg.at_node['stream_power_erosion'])
Exemplo n.º 34
0
mg = RasterModelGrid(nrows, ncols, dx)

# create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = np.array([
    5., 5., 0., 5., 5., 5., 2., 1., 2., 5., 5., 3., 2., 3., 5., 5., 4., 4., 4.,
    5., 5., 5., 5., 5., 5.
])
mg['node']['topographic__elevation'] = z

print('Running ...')

# instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params_discharge.txt')
# load the Fastscape module too, to allow direct comparison
fsp = Fsc(mg, './drive_sp_params_discharge.txt')

# perform the loop (once!)
for i in range(1):
    fr.route_flow(method='D8')
    my_Q = mg.at_node['water__volume_flux'] * 1.
    sp.erode(mg,
             dt,
             node_drainage_areas='drainage_area',
             slopes_at_nodes='topographic__steepest_slope',
             Q_if_used=my_Q)
    # no uplift

# print the stream power that was calculated:
Exemplo n.º 35
0
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node'][ 'topographic__elevation'] = z + numpy.random.rand(len(z))/1000.
mg.add_zeros('node', 'water__unit_flux_in')

#make some K values in a field to test
#mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
mg.at_node['K_values'] = numpy.empty(nrows*ncols, dtype=float)
#mg.at_node['K_values'].fill(0.1+numpy.random.rand()/10.)
mg.at_node['K_values'].fill(0.001)

print( 'Running ...' )

#instantiate the components:
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file_string)
#fsp = FastscapeEroder(mg, input_file_string)
precip = PrecipitationDistribution(input_file=input_file_string)

#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, input_file_string)

try:
    #raise NameError
    mg = copy.deepcopy(mg_mature)
except NameError:
    print('building a new grid...')
    out_interval = 50000.
    last_trunc = time_to_run #we use this to trigger taking an output plot
    #run to a steady state:
    #We're going to cheat by running Fastscape SP for the first part of the solution