def test_calculate_landslide_probability_lognormal_method():
    """Testing the main method 'calculate_landslide_probability()' with
    'lognormal' method. 
    """
    grid_2 = RasterModelGrid((5, 4), spacing=(0.2, 0.2))
    gridnum = grid_2.number_of_nodes
    np.random.seed(seed=6)
    grid_2.at_node['topographic__slope'] = np.random.rand(gridnum)
    scatter_dat = np.random.randint(1, 10, gridnum)
    grid_2.at_node['topographic__specific_contributing_area']= (
             np.sort(np.random.randint(30, 900, gridnum)))
    grid_2.at_node['soil__transmissivity']= (
             np.sort(np.random.randint(5, 20, gridnum), -1))
    grid_2.at_node['soil__mode_total_cohesion']= (
             np.sort(np.random.randint(30, 900, gridnum)))
    grid_2.at_node['soil__minimum_total_cohesion']= (
             grid_2.at_node['soil__mode_total_cohesion'] - scatter_dat)
    grid_2.at_node['soil__maximum_total_cohesion']= (
             grid_2.at_node['soil__mode_total_cohesion'] + scatter_dat)
    grid_2.at_node['soil__internal_friction_angle']= (
             np.sort(np.random.randint(26, 37, gridnum)))
    grid_2.at_node['soil__thickness']= (
             np.sort(np.random.randint(1, 10, gridnum)))
    grid_2.at_node['soil__density']= (2000. * np.ones(gridnum))

    ls_prob_lognormal = LandslideProbability(grid_2, number_of_iterations=10,
        groundwater__recharge_distribution='lognormal',
        groundwater__recharge_mean=5.,
        groundwater__recharge_standard_deviation=0.25,
        seed=6)
    ls_prob_lognormal.calculate_landslide_probability()
    np.testing.assert_almost_equal(
        grid_2.at_node['landslide__probability_of_failure'][5], 0.8)
    np.testing.assert_almost_equal(
        grid_2.at_node['landslide__probability_of_failure'][9], 0.4)
Example #2
0
def setup_grid():
    """Setting up test raster grid.
    """
    grid = RasterModelGrid((20, 20), spacing=10e0)
    grid.at_node['topographic__slope'] = (np.zeros(grid.number_of_nodes,
                                                   dtype=float))
    ls_prob = LandslideProbability(grid)
    globals().update({'ls_prob': LandslideProbability(grid)})
def test_calculate_landslide_probability_lognormal_spatial_method():
    """Testing the main method 'calculate_landslide_probability()' with
    'lognormal_spatial' method.
    """
    grid_3 = RasterModelGrid((5, 4), xy_spacing=(0.2, 0.2))
    gridnum = grid_3.number_of_nodes
    np.random.seed(seed=7)
    grid_3.at_node["topographic__slope"] = np.random.rand(gridnum)
    scatter_dat = np.random.randint(1, 10, gridnum)
    grid_3.at_node["topographic__specific_contributing_area"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_3.at_node["soil__transmissivity"] = np.sort(
        np.random.randint(5, 20, gridnum), -1
    )
    grid_3.at_node["soil__mode_total_cohesion"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_3.at_node["soil__minimum_total_cohesion"] = (
        grid_3.at_node["soil__mode_total_cohesion"] - scatter_dat
    )
    grid_3.at_node["soil__maximum_total_cohesion"] = (
        grid_3.at_node["soil__mode_total_cohesion"] + scatter_dat
    )
    grid_3.at_node["soil__internal_friction_angle"] = np.sort(
        np.random.randint(26, 37, gridnum)
    )
    grid_3.at_node["soil__thickness"] = np.sort(np.random.randint(1, 10, gridnum))
    grid_3.at_node["soil__density"] = 2000. * np.ones(gridnum)

    ls_prob_lognormal_spatial = LandslideProbability(
        grid_3,
        number_of_iterations=10,
        groundwater__recharge_distribution="lognormal_spatial",
        groundwater__recharge_mean=np.random.randint(2, 7, gridnum),
        groundwater__recharge_standard_deviation=np.random.rand(gridnum),
        seed=7,
    )
    ls_prob_lognormal_spatial.calculate_landslide_probability()
    np.testing.assert_almost_equal(
        grid_3.at_node["landslide__probability_of_failure"][5], 0.4
    )
    np.testing.assert_almost_equal(
        grid_3.at_node["landslide__probability_of_failure"][9], 0.29999999
    )
def test_calculate_landslide_probability_uniform_method():
    """Testing the main method 'calculate_landslide_probability()' with
    'uniform' method.
    """
    grid_1 = RasterModelGrid((5, 4), xy_spacing=(0.2, 0.2))
    gridnum = grid_1.number_of_nodes
    np.random.seed(seed=5)
    grid_1.at_node["topographic__slope"] = np.random.rand(gridnum)
    scatter_dat = np.random.randint(1, 10, gridnum)
    grid_1.at_node["topographic__specific_contributing_area"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_1.at_node["soil__transmissivity"] = np.sort(
        np.random.randint(5, 20, gridnum), -1
    )
    grid_1.at_node["soil__mode_total_cohesion"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_1.at_node["soil__minimum_total_cohesion"] = (
        grid_1.at_node["soil__mode_total_cohesion"] - scatter_dat
    )
    grid_1.at_node["soil__maximum_total_cohesion"] = (
        grid_1.at_node["soil__mode_total_cohesion"] + scatter_dat
    )
    grid_1.at_node["soil__internal_friction_angle"] = np.sort(
        np.random.randint(26, 37, gridnum)
    )
    grid_1.at_node["soil__thickness"] = np.sort(np.random.randint(1, 10, gridnum))
    grid_1.at_node["soil__density"] = 2000. * np.ones(gridnum)

    ls_prob_uniform = LandslideProbability(
        grid_1,
        number_of_iterations=10,
        groundwater__recharge_distribution="uniform",
        groundwater__recharge_min_value=20.,
        groundwater__recharge_max_value=120.,
        seed=5,
    )
    ls_prob_uniform.calculate_landslide_probability()
    np.testing.assert_almost_equal(
        grid_1.at_node["landslide__probability_of_failure"][5], 1.
    )
    np.testing.assert_almost_equal(
        grid_1.at_node["landslide__probability_of_failure"][9], 0.
    )
Example #5
0
def test_calculate_landslide_probability_uniform_method():
    """Testing the main method 'calculate_landslide_probability()' with
    'uniform' method.
    """
    grid_1 = RasterModelGrid((5, 4), spacing=(0.2, 0.2))
    gridnum = grid_1.number_of_nodes
    np.random.seed(seed=5)
    grid_1.at_node["topographic__slope"] = np.random.rand(gridnum)
    scatter_dat = np.random.randint(1, 10, gridnum)
    grid_1.at_node["topographic__specific_contributing_area"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_1.at_node["soil__transmissivity"] = np.sort(
        np.random.randint(5, 20, gridnum), -1
    )
    grid_1.at_node["soil__mode_total_cohesion"] = np.sort(
        np.random.randint(30, 900, gridnum)
    )
    grid_1.at_node["soil__minimum_total_cohesion"] = (
        grid_1.at_node["soil__mode_total_cohesion"] - scatter_dat
    )
    grid_1.at_node["soil__maximum_total_cohesion"] = (
        grid_1.at_node["soil__mode_total_cohesion"] + scatter_dat
    )
    grid_1.at_node["soil__internal_friction_angle"] = np.sort(
        np.random.randint(26, 37, gridnum)
    )
    grid_1.at_node["soil__thickness"] = np.sort(np.random.randint(1, 10, gridnum))
    grid_1.at_node["soil__density"] = 2000. * np.ones(gridnum)

    ls_prob_uniform = LandslideProbability(
        grid_1,
        number_of_iterations=10,
        groundwater__recharge_distribution="uniform",
        groundwater__recharge_min_value=20.,
        groundwater__recharge_max_value=120.,
        seed=5,
    )
    ls_prob_uniform.calculate_landslide_probability()
    np.testing.assert_almost_equal(
        grid_1.at_node["landslide__probability_of_failure"][5], 1.
    )
    np.testing.assert_almost_equal(
        grid_1.at_node["landslide__probability_of_failure"][9], 0.
    )
def test_calculate_landslide_probability_lognormal_spatial_method():
    """Testing the main method 'calculate_landslide_probability()' with
    'lognormal_spatial' method.
    """
    grid_3 = RasterModelGrid((5, 4), xy_spacing=(0.2, 0.2))
    gridnum = grid_3.number_of_nodes
    np.random.seed(seed=7)
    grid_3.add_zeros("soil__saturated_hydraulic_conductivity", at="node")
    grid_3.at_node["topographic__slope"] = np.random.rand(gridnum)
    scatter_dat = np.random.randint(1, 10, gridnum).astype(float)
    grid_3.at_node["topographic__specific_contributing_area"] = np.sort(
        np.random.randint(30, 900, gridnum).astype(float))
    grid_3.at_node["soil__transmissivity"] = np.sort(
        np.random.randint(5, 20, gridnum).astype(float), -1)
    grid_3.at_node["soil__mode_total_cohesion"] = np.sort(
        np.random.randint(30, 900, gridnum).astype(float))
    grid_3.at_node["soil__minimum_total_cohesion"] = (
        grid_3.at_node["soil__mode_total_cohesion"] - scatter_dat)
    grid_3.at_node["soil__maximum_total_cohesion"] = (
        grid_3.at_node["soil__mode_total_cohesion"] + scatter_dat)
    grid_3.at_node["soil__internal_friction_angle"] = np.sort(
        np.random.randint(26, 37, gridnum).astype(float))
    grid_3.at_node["soil__thickness"] = np.sort(
        np.random.randint(1, 10, gridnum).astype(float))
    grid_3.at_node["soil__density"] = 2000.0 * np.ones(gridnum)

    ls_prob_lognormal_spatial = LandslideProbability(
        grid_3,
        number_of_iterations=10,
        groundwater__recharge_distribution="lognormal_spatial",
        groundwater__recharge_mean=np.random.randint(2, 7,
                                                     gridnum).astype(float),
        groundwater__recharge_standard_deviation=np.random.rand(gridnum),
        seed=7,
    )
    ls_prob_lognormal_spatial.calculate_landslide_probability()
    np.testing.assert_almost_equal(
        grid_3.at_node["landslide__probability_of_failure"][5], 0.4)
    np.testing.assert_almost_equal(
        grid_3.at_node["landslide__probability_of_failure"][9], 0.29999999)
Example #7
0
def ls_prob():
    grid = RasterModelGrid((20, 20), xy_spacing=10e0)
    grid.add_zeros("topographic__slope", at="node", dtype=float)
    grid.add_zeros("topographic__specific_contributing_area", at="node")
    grid.add_zeros("soil__transmissivity", at="node")
    grid.add_zeros("soil__saturated_hydraulic_conductivity", at="node")
    grid.add_zeros("soil__mode_total_cohesion", at="node")
    grid.add_zeros("soil__minimum_total_cohesion", at="node")
    grid.add_zeros("soil__maximum_total_cohesion", at="node")
    grid.add_zeros("soil__internal_friction_angle", at="node")
    grid.add_zeros("soil__density", at="node")
    grid.add_zeros("soil__thickness", at="node")

    return LandslideProbability(grid)
Example #8
0
def ls_prob():
    grid = RasterModelGrid((20, 20), spacing=10e0)
    grid.add_zeros('topographic__slope', at='node', dtype=float)
    return LandslideProbability(grid)