예제 #1
0
            dir_water_flux = self._Qs
            thisslice = (slice(1, -1, 1), slice(0, -1, 1))
            deadedge = (slice(0, 1, 1), slice(0, -1, 1))
        else:
            raise NameError("direction must be {'E', 'N', 'S', 'W'}")
        slope_diff = (S_val - S_thresh).clip(0.)
        dir_sed_flux[thisslice] = (dir_water_flux[thisslice] *
                                   slope_diff[thisslice])
        dir_sed_flux[deadedge] = 0.

    def diffuse_sediment(self, Qw_in, Qsed_in, **kwds):
        """
        """
        pass


if __name__ == '__main__':
    import numpy as np
    from landlab import RasterModelGrid, imshow_grid_at_node
    S_crit = 0.25
    mg = RasterModelGrid((20, 20), 0.5)
    mg.add_zeros('node', 'topographic__elevation')
    Qw_in = mg.add_zeros('node', 'water__discharge_in')
    Qs_in = mg.add_zeros('node', 'sediment__discharge_in')
    Qw_in[0] = 0.5 * np.pi
    Qs_in[0] = (1. - S_crit) * 0.5 * np.pi
    dd = DischargeDiffuser(mg, S_crit)
    for i in range(5):  # 501
        dd.run_one_step(0.01)  # 0.08
    imshow_grid_at_node(mg, 'topographic__elevation')
예제 #2
0
print(grid.at_node['landslide__probability_of_failure'])

LS_prob_relative_wetness = grid.at_node['soil__mean_relative_wetness']
print(grid.at_node['soil__mean_relative_wetness'])

mpl.rcParams['xtick.labelsize'] = 15
mpl.rcParams['ytick.labelsize'] = 15
mpl.rcParams['lines.linewidth'] = 1
mpl.rcParams['axes.labelsize'] = 18
mpl.rcParams['legend.fontsize'] = 15

plt.figure('Elevations from the DEM [m]')
imshow_grid_at_node(grid,
                    'topographic__elevation',
                    cmap='terrain',
                    grid_units=('coordinates', 'coordinates'),
                    shrink=0.75,
                    var_name='Elevation',
                    var_units='m')
plt.savefig('Elevation.png')

# plt.figure('Landslides')
# ls_mask1 = grid.at_node['landslides'] != 1.0
# ls_mask2 = grid.at_node['landslides'] != 2.0
# ls_mask3 = grid.at_node['landslides'] != 3.0
# ls_mask4 = grid.at_node['landslides'] != 4.0
# overlay_landslide1 = np.ma.array(grid.at_node['landslides'], mask=ls_mask1)
# overlay_landslide2 = np.ma.array(grid.at_node['landslides'], mask=ls_mask2)
# overlay_landslide3 = np.ma.array(grid.at_node['landslides'], mask=ls_mask3)
# overlay_landslide4 = np.ma.array(grid.at_node['landslides'], mask=ls_mask4)
# imshow_grid_at_node(grid, 'topographic__slope', cmap='pink',
예제 #3
0
            dir_water_flux = self._Qs
            thisslice = (slice(1, -1, 1), slice(0, -1, 1))
            deadedge = (slice(0, 1, 1), slice(0, -1, 1))
        else:
            raise NameError("direction must be {'E', 'N', 'S', 'W'}")
        slope_diff = (S_val - S_thresh).clip(0.)
        dir_sed_flux[
            thisslice] = dir_water_flux[thisslice] * slope_diff[thisslice]
        dir_sed_flux[deadedge] = 0.

    def diffuse_sediment(self, Qw_in, Qsed_in, **kwds):
        """
        """
        pass


if __name__ == "__main__":
    from landlab import imshow_grid_at_node

    S_crit = 0.25
    mg = RasterModelGrid((20, 20), 0.5)
    mg.add_zeros("node", "topographic__elevation")
    Qw_in = mg.add_zeros("node", "water__discharge_in")
    Qs_in = mg.add_zeros("node", "sediment__discharge_in")
    Qw_in[0] = 0.5 * np.pi
    Qs_in[0] = (1. - S_crit) * 0.5 * np.pi
    dd = DischargeDiffuser(mg, S_crit)
    for i in range(5):  # 501
        dd.run_one_step(0.01)  # 0.08
    imshow_grid_at_node(mg, "topographic__elevation")
예제 #4
0
            dir_sed_flux = self._Qsed_s
            dir_water_flux = self._Qs
            thisslice = (slice(1, -1, 1), slice(0, -1, 1))
            deadedge = (slice(0, 1, 1), slice(0, -1, 1))
        else:
            raise NameError("direction must be {'E', 'N', 'S', 'W'}")
        slope_diff = (S_val - S_thresh).clip(0.0)
        dir_sed_flux[thisslice] = dir_water_flux[thisslice] * slope_diff[thisslice]
        dir_sed_flux[deadedge] = 0.0

    def diffuse_sediment(self, Qw_in, Qsed_in, **kwds):
        """
        """
        pass


if __name__ == "__main__":
    from landlab import imshow_grid_at_node

    S_crit = 0.25
    mg = RasterModelGrid((20, 20), 0.5)
    mg.add_zeros("node", "topographic__elevation")
    Qw_in = mg.add_zeros("node", "water__discharge_in")
    Qs_in = mg.add_zeros("node", "sediment__discharge_in")
    Qw_in[0] = 0.5 * np.pi
    Qs_in[0] = (1.0 - S_crit) * 0.5 * np.pi
    dd = DischargeDiffuser(mg, S_crit)
    for i in range(5):  # 501
        dd.run_one_step(0.01)  # 0.08
    imshow_grid_at_node(mg, "topographic__elevation")
예제 #5
0
            dir_water_flux = self._Qs
            thisslice = (slice(1, -1, 1), slice(0, -1, 1))
            deadedge = (slice(0, 1, 1), slice(0, -1, 1))
        else:
            raise NameError("direction must be {'E', 'N', 'S', 'W'}")
        slope_diff = (S_val - S_thresh).clip(0.)
        dir_sed_flux[thisslice] = (dir_water_flux[thisslice] *
                                   slope_diff[thisslice])
        dir_sed_flux[deadedge] = 0.

    def diffuse_sediment(self, Qw_in, Qsed_in, **kwds):
        """
        """
        pass


if __name__ == '__main__':
    import numpy as np
    from landlab import RasterModelGrid, imshow_grid_at_node
    S_crit = 0.25
    mg = RasterModelGrid((20, 20), 0.5)
    mg.add_zeros('node', 'topographic__elevation')
    Qw_in = mg.add_zeros('node', 'water__discharge_in')
    Qs_in = mg.add_zeros('node', 'sediment__discharge_in')
    Qw_in[0] = 0.5*np.pi
    Qs_in[0] = (1. - S_crit)*0.5*np.pi
    dd = DischargeDiffuser(mg, S_crit)
    for i in range(5):  # 501
        dd.run_one_step(0.01)  # 0.08
    imshow_grid_at_node(mg, 'topographic__elevation')
from landlab import imshow_grid_at_node
from landlab.io import read_esri_ascii, write_esri_ascii  # this for exporting the rainfall field as ascii file
from landlab.components import SpatialPrecipitationDistribution
import os

rain = SpatialPrecipitationDistribution(rmg)
np.random.seed(26)
for storm_t, interstorm_t in rain.yield_storms(
        style='monsoonal'):  # storm lengths in hrs???
    rmg.at_node['rainfall__flux'] *= 0.001  #mm/hr
    rmg.at_node['rainfall__flux'] *= 10  # heavier storms...

imshow_grid_at_node(rmg,
                    'rainfall__flux',
                    cmap='gist_ncar',
                    colorbar_label='Rainfall Flux (m/h)',
                    plot_name='Storm 1 Rainfall')

flow_accum = FlowAccumulator(
    rmg,
    surface='topographic__elevation',
    flow_director='FlowDirectorD8',
    runoff_rate=
    'rainfall__flux',  # <-- feed in the rainfall data layer that you just created
    depression_finder='DepressionFinderAndRouter')
flow_accum.run_one_step()

imshow_grid(
    rmg,
    'surface_water__discharge',
예제 #7
0
from landlab import RasterModelGrid, imshow_grid_at_node
from landlab.components import FlowAccumulator
from landlab.components import SpatialPrecipitationDistribution
from landlab.components import SoilInfiltrationGreenAmpt
from matplotlib.pyplot import show, figure

mg = RasterModelGrid((100, 100), 100.)
z = mg.add_zeros('node', 'topographic__elevation', dtype=float)
z[:] = mg.node_x / 100000.

STORM = SpatialPrecipitationDistribution(mg)
WUFI = mg.add_field('node', 'water__unit_flux_in',
                    mg.at_node['rainfall__flux'])
fa = FlowAccumulator(mg)

count = 0
for storm in STORM.yield_storms():
    fa.run_one_step()
    print storm
    count += 1
    if count % 10 == 0:
        figure(count)
        imshow_grid_at_node(mg, 'rainfall__flux')
        figure(count + 1)
        imshow_grid_at_node(mg, 'surface_water__discharge')

show()