예제 #1
0
# Since the discharge files were created on the WRF-Hydro topography, we use that topography as our input. The original Landlab topography and the WRF-Hydro topography are almost identical, with only slight differences created by the rotation.
topo=Dataset('topography_wrf_hydro.nc')
topography=topo.variables['TOPOGRAPHY'][:]
topographic__elevation=np.asarray(topography, dtype=float).ravel()
mg.add_field('node', 'topographic__elevation', topographic__elevation) #create the field


#set boundary conditions -- these should match those used in the topography creation driver
for edge in (mg.nodes_at_left_edge, mg.nodes_at_right_edge):
    mg.status_at_node[edge] = CLOSED_BOUNDARY
for edge in (mg.nodes_at_top_edge, mg.nodes_at_bottom_edge):
    mg.status_at_node[edge] = FIXED_VALUE_BOUNDARY

#instantiate the components
fr = FlowRouter(mg)
sp = StreamPowerEroder(mg, input_file)
lin_diffuse = LinearDiffuser(mg, input_file)

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

#text for discharge file names
streamflow = "streamflow"
nc = ".nc"

elapsed_time = 0. #total time in simulation

#create list of all discharge files to be used, repeat as many times as necessary for run time.
#Example: here we have a total of 20 discharge files -- we need one file for every time step and we have 100 timesteps. 
# We will repeat the discharge file namelist 5 times Run Time = 100 yrs dt = 1yr 
rep_num = int(5) #depends on how many discharge files/time steps you have
예제 #2
0
mg = RasterModelGrid(nrows, ncols, dx)

#create the fields in the grid
mg.create_node_array_zeros('topographic_elevation')
z = mg.create_node_array_zeros() + 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 = FlowRouter(mg)
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
#load the Fastscape module too, to allow direct comparison
fsp = Fsc(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(grid=mg)
    mg = fr.route_flow(grid=mg)
    #print 'Area: ', numpy.max(mg.at_node['drainage_area'])
    #mg = fsp.erode(mg)
    mg, _, _ = sp.erode(mg,