From 284dde8b1c762cf7b7a7a5121fbf5495fac13da6 Mon Sep 17 00:00:00 2001 From: angelmons Date: Fri, 6 Sep 2024 16:55:50 -0400 Subject: [PATCH] Updates tests to Landlab's new version Updates Landlab and check all tests. --- .../river_bed_dynamics/RiverBedDynamics.py | 139 +++++++++--------- .../_bedload_eq_Parker_1990.py | 20 +-- .../river_bed_dynamics/_initialize_fields.py | 76 +++++----- .../river_bed_dynamics/_initialize_gsd.py | 54 +++---- .../river_bed_dynamics/_stratigraphy.py | 24 +-- .../river_bed_dynamics/_utilities.py | 100 ++++++------- 6 files changed, 205 insertions(+), 208 deletions(-) diff --git a/landlab/components/river_bed_dynamics/RiverBedDynamics.py b/landlab/components/river_bed_dynamics/RiverBedDynamics.py index f50f647fb3..25f862889e 100644 --- a/landlab/components/river_bed_dynamics/RiverBedDynamics.py +++ b/landlab/components/river_bed_dynamics/RiverBedDynamics.py @@ -195,7 +195,7 @@ class property. >>> qb_gsd_l15 = rbd._sed_transp__bedload_gsd_link[15] >>> np.round(qb_gsd_l15, decimals=3) -array([ 0.475, 0.525]) +array([0.475, 0.525]) Which in cummulative percentage is equivalent to @@ -212,46 +212,46 @@ class property. >>> qb_gsd_l = rbd._sed_transp__bedload_gsd_link >>> np.round(qb_gsd_l, decimals=3) -array([[ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.475, 0.525], - [ 0.475, 0.525], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.475, 0.525], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ]]) +array([[0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0.475, 0.525], + [0.475, 0.525], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.475, 0.525], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.282, 0.718], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ]]) Zeros indicate that there is no sediment transport of that grain size at that location. @@ -261,11 +261,11 @@ class property. >>> z = grid.at_node["topographic__elevation"].reshape(grid.shape) >>> np.round(z, decimals=3) -array([[ 1.07 , 1.06 , 1.007, 1.06 , 1.07 ], - [ 1.08 , 1.068, 1.037, 1.068, 1.08 ], - [ 1.09 , 1.08 , 1.068, 1.08 , 1.09 ], - [ 1.09 , 1.09 , 1.08 , 1.09 , 1.09 ], - [ 1.09 , 1.09 , 1.09 , 1.09 , 1.09 ]]) +array([[1.07 , 1.06 , 1.007, 1.06 , 1.07 ], + [1.08 , 1.068, 1.037, 1.068, 1.08 ], + [1.09 , 1.08 , 1.068, 1.08 , 1.09 ], + [1.09 , 1.09 , 1.08 , 1.09 , 1.09 ], + [1.09 , 1.09 , 1.09 , 1.09 , 1.09 ]]) Let's take a look at bed load transport rate when we use the different bedload equations. First, let's recover the original topography. @@ -372,9 +372,9 @@ class property. >>> qb_imposed = np.array([1, 2]) >>> rbd = RiverBedDynamics(grid, sed_transp__bedload_rate_fix_link=qb_imposed) >>> rbd._sed_transp__bedload_rate_fix_link -array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) +array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0.]) >>> gsd_loc = np.array([1, 2]) >>> rbd = RiverBedDynamics(grid, bed_surf__gsd_loc_node=gsd_loc) @@ -406,11 +406,10 @@ class property. >>> vel_n_1 = np.array([1, 2]) >>> rbd = RiverBedDynamics(grid, surface_water__velocity_prev_time_link=vel_n_1) >>> rbd._surface_water__velocity_prev_time_link -array([ 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25]) +array([0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25]) For sed_transp__bedload_gsd_fix_link, for simplicity, we only show links 0, 5, and 10 @@ -418,9 +417,9 @@ class property. >>> qb_gsd_imposed = np.array([1, 2]) >>> rbd = RiverBedDynamics(grid, sed_transp__bedload_gsd_fix_link=qb_gsd_imposed) >>> rbd._sed_transp__bedload_gsd_fix_link[[0, 5, 10], :] -array([[ 0., 0.], - [ 0., 0.], - [ 0., 0.]]) +array([[0., 0.], + [0., 0.], + [0., 0.]]) In summary, in all these cases the wrong given value is override by default values. But, if the size of the array is correct the specified condition is used. @@ -429,7 +428,7 @@ class property. >>> qb_imposed = np.full(grid.number_of_links, 1) >>> rbd = RiverBedDynamics(grid, sed_transp__bedload_rate_fix_link=qb_imposed) >>> rbd._sed_transp__bedload_rate_fix_link[[0, 5, 10]] -array([ 1., 1., 1.]) +array([1., 1., 1.]) >>> gsd_loc = np.full(grid.number_of_nodes, 1) >>> rbd = RiverBedDynamics(grid, bed_surf__gsd_loc_node=gsd_loc) @@ -461,14 +460,14 @@ class property. >>> vel_n_1 = np.full(grid.number_of_links, 1) >>> rbd = RiverBedDynamics(grid, surface_water__velocity_prev_time_link=vel_n_1) >>> rbd._surface_water__velocity_prev_time_link[[0, 5, 10]] -array([ 1., 1., 1.]) +array([1., 1., 1.]) >>> qb_gsd_imposed = np.ones((grid.number_of_links, 2)) # 2 comes from gsd.shape[0]-1 >>> rbd = RiverBedDynamics(grid, sed_transp__bedload_gsd_fix_link=qb_gsd_imposed) >>> rbd._sed_transp__bedload_gsd_fix_link[[0, 5, 10]] -array([[ 1., 1.], - [ 1., 1.], - [ 1., 1.]]) +array([[1., 1.], + [1., 1.], + [1., 1.]]) Using the hydraulics radius is also possible. Let's compare the shear stress with and without that option. First, without including the hydraulics radius. @@ -490,6 +489,7 @@ class property. So, there is an important difference between the two ways of calculating it. """ + import numpy as np import scipy.constants @@ -508,7 +508,6 @@ class property. class RiverBedDynamics(Component): - """Predicts the evolution of a river bed. Landlab component that predicts the evolution of a river bed @@ -830,10 +829,10 @@ def __init__( self._num_cycles_to_process_strat = num_cycles_to_process_strat # Makes a copy of the original bed surface elevation and maps into links - self._grid["link"][ - "topographic__elevation" - ] = self._grid.map_mean_of_link_nodes_to_link( - self._grid["node"]["topographic__elevation"] + self._grid["link"]["topographic__elevation"] = ( + self._grid.map_mean_of_link_nodes_to_link( + self._grid["node"]["topographic__elevation"] + ) ) self._topogr__elev_orig_node = self._grid["node"][ "topographic__elevation" @@ -1175,9 +1174,9 @@ def update_bed_elevation(self): z[self._out_id] = z0[self._out_id] + dz_outlet # Now we map data into links to update Bed GSD - self._grid["link"][ - "topographic__elevation" - ] = self._grid.map_mean_of_link_nodes_to_link(z) + self._grid["link"]["topographic__elevation"] = ( + self._grid.map_mean_of_link_nodes_to_link(z) + ) self._grid["node"]["topographic__elevation"] = z def update_bed_surf_gsd(self): diff --git a/landlab/components/river_bed_dynamics/_bedload_eq_Parker_1990.py b/landlab/components/river_bed_dynamics/_bedload_eq_Parker_1990.py index 6be9336c38..ad68dc1188 100644 --- a/landlab/components/river_bed_dynamics/_bedload_eq_Parker_1990.py +++ b/landlab/components/river_bed_dynamics/_bedload_eq_Parker_1990.py @@ -131,30 +131,30 @@ def strain_functions(phi_sgo): >>> phi_sgo = np.array([0.1, 0.2, 0.3, 0.7639]) >>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo) >>> omega0 - array([ 1.011, 1.011, 1.011, 1.011]) + array([1.011, 1.011, 1.011, 1.011]) >>> sigma0 - array([ 0.8157, 0.8157, 0.8157, 0.8157]) + array([0.8157, 0.8157, 0.8157, 0.8157]) range 2: (phi_sgo > 0.7639) & (phi_sgo < 231.2) >>> phi_sgo = np.array([0.7639, 1, 100, 231.1]) >>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo) - >>> omega0 - array([ 1.011 , 0.9997 , 0.45601387, 0.45409851]) + >>> np.round(omega0,3) + array([1.011, 1. , 0.456, 0.454]) - >>> sigma0 - array([ 0.8157 , 0.8439 , 1.49812569, 1.49900013]) + >>> np.round(sigma0,3) + array([0.816, 0.844, 1.498, 1.499]) range 3: phi_sgo >= 231.2 >>> phi_sgo = np.array([231.1, 1000, 2000, 2320]) >>> (omega0, sigma0) = Parker1990.strain_functions(phi_sgo) - >>> omega0 - array([ 0.45409851, 0.45358472, 0.45291448, 0.4527 ]) + >>> np.round(omega0,3) + array([0.454, 0.454, 0.453, 0.453]) - >>> sigma0 - array([ 1.49900013, 1.49936806, 1.4998468 , 1.5 ]) + >>> np.round(sigma0,3) + array([1.499, 1.499, 1.5 , 1.5 ]) """ diff --git a/landlab/components/river_bed_dynamics/_initialize_fields.py b/landlab/components/river_bed_dynamics/_initialize_fields.py index c2e320750e..062b04e59b 100644 --- a/landlab/components/river_bed_dynamics/_initialize_fields.py +++ b/landlab/components/river_bed_dynamics/_initialize_fields.py @@ -56,9 +56,9 @@ ... grid, sed_transp__bedload_rate_fix_link ... ) >>> sed_transp__bedload_rate_fix_link -array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) +array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0.]) Case2b: Setting sed_transp__bedload_gsd_fix_link as 6.7 at link 3, 6, and 10 @@ -68,10 +68,10 @@ ... grid, sed_transp__bedload_rate_fix_link ... ) >>> sed_transp__bedload_rate_fix_link -array([ 0. , 0. , 0. , 6.7, 0. , 0. , 6.7, 0. , 0. , 0. , 6.7, - 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , - 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , - 0. , 0. , 0. , 0. , 0. , 0. , 0. ]) +array([0. , 0. , 0. , 6.7, 0. , 0. , 6.7, 0. , 0. , 0. , 6.7, 0. , 0. , + 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. ]) Case2c: Setting sed_transp__bedload_gsd_fix_link with wrong size @@ -80,9 +80,9 @@ ... grid, sed_transp__bedload_rate_fix_link ... ) >>> sed_transp__bedload_rate_fix_link -array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) +array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0.]) Case3a: Using default values @@ -96,11 +96,11 @@ we did not specified any imposed gsd >>> sed_transp__bedload_gsd_fix_link[:5, :] -array([[ 0., 0.], - [ 0., 0.], - [ 0., 0.], - [ 0., 0.], - [ 0., 0.]]) +array([[0., 0.], + [0., 0.], + [0., 0.], + [0., 0.], + [0., 0.]]) Case3b: Setting sed_transp__bedload_gsd_fix_link at links 2 and 4 as gsd = np.array([[32, 100], [16, 50], [8, 0]]) @@ -118,11 +118,11 @@ For displaying purposes we only show the first 5 links. >>> sed_transp__bedload_gsd_fix_link[:5, :] -array([[ 0. , 0. ], - [ 0.5, 0.5], - [ 0. , 0. ], - [ 0.5, 0.5], - [ 0. , 0. ]]) +array([[0. , 0. ], + [0.5, 0.5], + [0. , 0. ], + [0.5, 0.5], + [0. , 0. ]]) The rest of elements are [0., 0.] because they are not imposed. The importance of this step is that in the component. It will know what links must preserve its gsd. @@ -138,11 +138,11 @@ there was an error while trying to specify sed_transp__bedload_gsd_fix_link >>> sed_transp__bedload_gsd_fix_link[:5, :] -array([[ 0., 0.], - [ 0., 0.], - [ 0., 0.], - [ 0., 0.], - [ 0., 0.]]) +array([[0., 0.], + [0., 0.], + [0., 0.], + [0., 0.], + [0., 0.]]) Case4a: Using default values @@ -153,11 +153,10 @@ ... grid, surface_water__velocity_prev_time_link ... ) >>> surface_water__velocity_prev_time_link -array([ 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25]) +array([0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25]) Case4b: Setting surface_water__velocity_prev_time_link with link 4 as 1.2 m/s >>> surface_water__velocity_prev_time_link = np.full(grid.number_of_links, 0.50) @@ -167,10 +166,10 @@ ... grid, surface_water__velocity_prev_time_link ... ) >>> surface_water__velocity_prev_time_link -array([ 0.5, 0.5, 0.5, 0.5, 1.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]) +array([0.5, 0.5, 0.5, 0.5, 1.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5]) Case4c: Setting surface_water__velocity_prev_time_link with wrong size @@ -179,11 +178,10 @@ ... grid, surface_water__velocity_prev_time_link ... ) >>> surface_water__velocity_prev_time_link -array([ 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, - 0.25, 0.25, 0.25, 0.25]) +array([0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25]) """ diff --git a/landlab/components/river_bed_dynamics/_initialize_gsd.py b/landlab/components/river_bed_dynamics/_initialize_gsd.py index 0c5a1e2c1f..06d83a30c9 100644 --- a/landlab/components/river_bed_dynamics/_initialize_gsd.py +++ b/landlab/components/river_bed_dynamics/_initialize_gsd.py @@ -38,10 +38,10 @@ def adds_2mm_to_gsd(gsd): >>> gsd = [[32, 100, 100], [16, 25, 50], [1, 0, 0]] >>> gsd = initialize_gsd.adds_2mm_to_gsd(gsd) >>> gsd - array([[ 32. , 100. , 100. ], - [ 16. , 25. , 50. ], - [ 2. , 6.25, 12.5 ], - [ 1. , 0. , 0. ]]) + array([[ 32. , 100. , 100. ], + [ 16. , 25. , 50. ], + [ 2. , 6.25, 12.5 ], + [ 1. , 0. , 0. ]]) """ gsd = np.array(gsd) @@ -178,22 +178,22 @@ def map_initial_bed_properties_to_nodes(gsd, gsd_loc_node): >>> gsd = initialize_gsd.adds_2mm_to_gsd(gsd) >>> gsd - array([[ 32. , 100. , 100. , 100. ], - [ 16. , 25. , 50. , 60. ], - [ 8. , 10. , 20. , 30. ], - [ 4. , 5. , 4. , 2. ], - [ 2. , 2.5, 2. , 1. ], - [ 1. , 0. , 0. , 0. ]]) + array([[ 32. , 100. , 100. , 100. ], + [ 16. , 25. , 50. , 60. ], + [ 8. , 10. , 20. , 30. ], + [ 4. , 5. , 4. , 2. ], + [ 2. , 2.5, 2. , 1. ], + [ 1. , 0. , 0. , 0. ]]) Second, remove sand (only when using Parker 1990) >>> gsd = initialize_gsd.remove_sand_from_gsd(gsd, "Parker1990") >>> np.around(gsd, 2) - array([[ 32. , 100. , 100. , 100. ], - [ 16. , 23.08, 48.98, 59.6 ], - [ 8. , 7.69, 18.37, 29.29], - [ 4. , 2.56, 2.04, 1.01], - [ 2. , 0. , 0. , 0. ]]) + array([[ 32. , 100. , 100. , 100. ], + [ 16. , 23.08, 48.98, 59.6 ], + [ 8. , 7.69, 18.37, 29.29], + [ 4. , 2.56, 2.04, 1.01], + [ 2. , 0. , 0. , 0. ]]) And now we can map to nodes @@ -206,21 +206,21 @@ def map_initial_bed_properties_to_nodes(gsd, gsd_loc_node): Sand fraction should be zero everywhere because we removed it by using Parker >>> sand_fract - array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) + array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0.]) Let's check some of the gsd for selected nodes, representative of locations 1, 2, and 3. These nodes are: 5, 8, and 12, respectively >>> np.around(gs_D_freq[5], 2) - array([ 0.77, 0.15, 0.05, 0.03]) + array([0.77, 0.15, 0.05, 0.03]) >>> np.around(gs_D_freq[8], 2) - array([ 0.51, 0.31, 0.16, 0.02]) + array([0.51, 0.31, 0.16, 0.02]) >>> np.around(gs_D_freq[12], 2) - array([ 0.4 , 0.3 , 0.28, 0.01]) - + array([0.4 , 0.3 , 0.28, 0.01]) + Another example, where the 2 mm fraction is not originally present and only sizes larger than 2 mm are present @@ -240,20 +240,20 @@ def map_initial_bed_properties_to_nodes(gsd, gsd_loc_node): Sand fraction should be zero everywhere because there was none in the gsd >>> sand_fract - array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., - 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) + array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0.]) Let's check some of the gsd for selected nodes, representative of locations 1, 2, and 3. These nodes are: 5, 8, and 12, respectively >>> np.around(gs_D_freq[5], 2) - array([ 0.75, 0.25]) + array([0.75, 0.25]) >>> np.around(gs_D_freq[8], 2) - array([ 0.5, 0.5]) - + array([0.5, 0.5]) + >>> np.around(gs_D_freq[12], 2) - array([ 0.4, 0.6]) + array([0.4, 0.6]) """ gsd = np.array(gsd) diff --git a/landlab/components/river_bed_dynamics/_stratigraphy.py b/landlab/components/river_bed_dynamics/_stratigraphy.py index f0bc11bed2..b1be0b275d 100644 --- a/landlab/components/river_bed_dynamics/_stratigraphy.py +++ b/landlab/components/river_bed_dynamics/_stratigraphy.py @@ -128,10 +128,10 @@ def checks_erosion_or_deposition(self): self._bed_surf__thick_new_layer_link > self._bed_surf_new_layer_thick ) update_deposited_link_id = update_deposited_link_id[ - np.in1d(update_deposited_link_id, self._grid.active_links) + np.isin(update_deposited_link_id, self._grid.active_links) ] self._update_deposited_link_id = update_deposited_link_id[ - ~np.in1d(update_deposited_link_id, self._bed_surf__elev_fix_link_id) + ~np.isin(update_deposited_link_id, self._bed_surf__elev_fix_link_id) ] if self._update_deposited_link_id.shape[0] > 0: @@ -147,10 +147,10 @@ def checks_erosion_or_deposition(self): self._bed_surf__thick_new_layer_link < -self._bed_surf_new_layer_thick ) update_eroded_link_id = update_eroded_link_id[ - np.in1d(update_eroded_link_id, self._grid.active_links) + np.isin(update_eroded_link_id, self._grid.active_links) ] self._update_eroded_link_id = update_eroded_link_id[ - ~np.in1d(update_eroded_link_id, self._bed_surf__elev_fix_link_id) + ~np.isin(update_eroded_link_id, self._bed_surf__elev_fix_link_id) ] if self._update_eroded_link_id.shape[0] > 0: @@ -242,16 +242,16 @@ def evolve(self): num_cycles_to_process_strat=2 >>> rbd._link_stratigraphy_temp[23][0][0, 4:6] - array([ 0.1, 0.9]) + array([0.1, 0.9]) >>> rbd._link_stratigraphy_temp[23][13][0, 4:6] - array([ 0.1052982, 0.8947018]) + array([0.1052982, 0.8947018]) >>> rbd._link_stratigraphy_temp[23][58][0, 4:6] - array([ 0.12428022, 0.87571978]) + array([0.12428022, 0.87571978]) >>> rbd._link_stratigraphy_temp[23][649][0, 4:6] - array([ 0.3631502, 0.6368498]) + array([0.3631502, 0.6368498]) The list rbd._link_stratigraphy_temp[23] has 650 elements, this means that it's evolution was recorded every 2 seconds @@ -315,16 +315,16 @@ def evolve(self): this list was deleted previously, when deposition occurred >>> rbd._link_stratigraphy_temp[23][0][0, 4:6] - array([ 0.2368653, 0.7631347]) + array([0.2368653, 0.7631347]) >>> rbd._link_stratigraphy_temp[23][14][0, 4:6] - array([ 0.23001637, 0.76998363]) + array([0.23001637, 0.76998363]) >>> rbd._link_stratigraphy_temp[23][59][0, 4:6] - array([ 0.21015594, 0.78984406]) + array([0.21015594, 0.78984406]) >>> rbd._link_stratigraphy_temp[23][1299][0, 4:6] - array([ 0.09472506, 0.90527494]) + array([0.09472506, 0.90527494]) The list rbd._link_stratigraphy_temp[23] has 1300 elements, this means that it's evolution was recorded every 2 seconds diff --git a/landlab/components/river_bed_dynamics/_utilities.py b/landlab/components/river_bed_dynamics/_utilities.py index fea613df6b..3d4a0da779 100644 --- a/landlab/components/river_bed_dynamics/_utilities.py +++ b/landlab/components/river_bed_dynamics/_utilities.py @@ -135,31 +135,31 @@ def map_gsd_from_link_to_node(self, location="bed_surf"): >>> bed_surf__gsd_node = utilities.map_gsd_from_link_to_node(rbd) >>> np.round(bed_surf__gsd_node, 3) - array([[ 0.656, 0.344], - [ 0.562, 0.438], - [ 0.531, 0.469], - [ 0.562, 0.438], - [ 0.656, 0.344], - [ 0.688, 0.312], - [ 0.531, 0.469], - [ 0.5 , 0.5 ], - [ 0.531, 0.469], - [ 0.688, 0.312], - [ 0.688, 0.312], - [ 0.531, 0.469], - [ 0.5 , 0.5 ], - [ 0.531, 0.469], - [ 0.688, 0.312], - [ 0.688, 0.312], - [ 0.531, 0.469], - [ 0.5 , 0.5 ], - [ 0.531, 0.469], - [ 0.688, 0.312], - [ 0.656, 0.344], - [ 0.562, 0.438], - [ 0.531, 0.469], - [ 0.562, 0.438], - [ 0.656, 0.344]]) + array([[0.656, 0.344], + [0.562, 0.438], + [0.531, 0.469], + [0.562, 0.438], + [0.656, 0.344], + [0.688, 0.312], + [0.531, 0.469], + [0.5 , 0.5 ], + [0.531, 0.469], + [0.688, 0.312], + [0.688, 0.312], + [0.531, 0.469], + [0.5 , 0.5 ], + [0.531, 0.469], + [0.688, 0.312], + [0.688, 0.312], + [0.531, 0.469], + [0.5 , 0.5 ], + [0.531, 0.469], + [0.688, 0.312], + [0.656, 0.344], + [0.562, 0.438], + [0.531, 0.469], + [0.562, 0.438], + [0.656, 0.344]]) And for the bed load gsd we have: @@ -167,31 +167,31 @@ def map_gsd_from_link_to_node(self, location="bed_surf"): ... rbd, location="bedload" ... ) >>> np.round(sed_transp__bedload_gsd_node, 3) - array([[ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.379, 0.621], - [ 0.475, 0.525], - [ 0.379, 0.621], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.33 , 0.67 ], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0.282, 0.718], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ], - [ 0. , 0. ]]) + array([[0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0.379, 0.621], + [0.475, 0.525], + [0.379, 0.621], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.33 , 0.67 ], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0.282, 0.718], + [0.282, 0.718], + [0.282, 0.718], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ], + [0. , 0. ]]) A bed load gsd that shows [ 0. , 0. ] means that there is zero transport at that node