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)
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), 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_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. )
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)