mg.set_closed_boundaries_at_grid_edges(False, True, False, True) # Display a message print 'Running ...' #instantiate the components: fr = FlowRouter(mg) sp = SPEroder(mg, input_file) diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = DiffusionComponent(grid=mg, input_stream=input_file) #perform the loops: for i in xrange(nt): #note the input arguments here are not totally standardized between modules #mg = diffuse.diffuse(mg, i*dt) mg = lin_diffuse.diffuse(mg, dt) mg = fr.route_flow(grid=mg) mg = sp.erode(mg) ##plot long profiles along channels pylab.figure(6) profile_IDs = prf.channel_nodes(mg, mg.at_node['steepest_slope'], mg.at_node['drainage_area'], mg.at_node['upstream_ID_order'], mg.at_node['flow_receiver']) dists_upstr = prf.get_distances_upstream( mg, len(mg.at_node['steepest_slope']), profile_IDs, mg.at_node['links_to_flow_receiver']) prf.plot_profiles(dists_upstr, profile_IDs, mg.at_node['topographic_elevation'])
#put these values plus roughness into that field mg['node'][ 'planet_surface__elevation'] = z + np.random.rand(len(z))/100000. # Display a message print 'Running ...' #instantiate the components: fr = FlowRouter(mg) sp = SPEroder(mg, input_file) diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = DiffusionComponent(grid=mg, input_stream=input_file) #perform the loops: for i in xrange(nt): #mg = diffuse.diffuse(mg, i*dt) mg = lin_diffuse.diffuse(mg, dt) mg = fr.route_flow(grid=mg) mg = sp.erode(mg) ##plot long profiles along channels pylab.figure(6) profile_IDs = prf.channel_nodes(mg, mg.at_node['steepest_slope'], mg.at_node['drainage_area'], mg.at_node['upstream_ID_order'], mg.at_node['flow_receiver']) dists_upstr = prf.get_distances_upstream(mg, len(mg.at_node['steepest_slope']), profile_IDs, mg.at_node['links_to_flow_receiver']) prf.plot_profiles(dists_upstr, profile_IDs, mg.at_node['planet_surface__elevation']) print 'Completed loop ', i print 'Completed the simulation. Plotting...'
#instantiate the components: diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = DiffusionComponent(grid=mg, input_stream=input_file) #Perform the loops. for i in xrange(nt): #This line performs the actual functionality of the component: #***NB: both diffusers contain an "automatic" element of uplift. #You can suppress this for the linear diffuser with the *internal_uplift* keyword, =False #See the docstrings for both classes for more details. #Switch these lines to switch between diffusion styles: #mg = diffuse.diffuse(mg, i*dt) #nonlinear diffusion mg = lin_diffuse.diffuse(mg) #linear diffusion #Plot a Xsection north-south through the middle of the data, once per loop pylab.figure(1) elev_r = mg.node_vector_to_raster(mg['node']['topographic_elevation']) im = pylab.plot(mg.dx*np.arange(nrows), elev_r[:,int(ncols//2)]) print 'Completed loop ', i print 'Completed the simulation. Plotting...' #Finalize and plot: #put a title on figure 1 pylab.figure(1) pylab.title('N-S cross_section') pylab.xlabel('Distance')
##Reset the elevation field in the grid: mg['node']['planet_surface__elevation'] = z + np.random.rand(len(z)) / 100000. # Display a message print 'Running ...' ##instantiate the components: #diffuse = PerronNLDiffuse(mg, input_file) #lin_diffuse = DiffusionComponent(grid=mg) #lin_diffuse.initialize(input_file) for i in xrange(nt): #This line performs the actual functionality of the component: #***NB: the nonlinear diffuser contains an "automatic" element of uplift. If you instead use the linear diffuser, you need to add the uplift manually... mg['node']['planet_surface__elevation'][uplifted_nodes] += uplift_per_step mg = lin_diffuse.diffuse(mg, internal_uplift=False) #linear diffusion pylab.figure(4) elev_r = mg.node_vector_to_raster(mg['node']['planet_surface__elevation']) im = pylab.plot(mg.dx * np.arange(nrows), elev_r[:, int(ncols // 2)]) print 'Completed loop ', i print 'Completed the simulation. Plotting...' #Finalize and plot: #put a title on figure 4 pylab.figure(4) pylab.title('N-S cross_section, linear diffusion') pylab.xlabel('Distance') pylab.ylabel('Elevation')
##Reset the elevation field in the grid: mg["node"]["planet_surface__elevation"] = z + np.random.rand(len(z)) / 100000.0 # Display a message print "Running ..." ##instantiate the components: # diffuse = PerronNLDiffuse(mg, input_file) # lin_diffuse = DiffusionComponent(grid=mg) # lin_diffuse.initialize(input_file) for i in xrange(nt): # This line performs the actual functionality of the component: # ***NB: the nonlinear diffuser contains an "automatic" element of uplift. If you instead use the linear diffuser, you need to add the uplift manually... mg["node"]["planet_surface__elevation"][uplifted_nodes] += uplift_per_step mg = lin_diffuse.diffuse(mg, internal_uplift=False) # linear diffusion pylab.figure(4) elev_r = mg.node_vector_to_raster(mg["node"]["planet_surface__elevation"]) im = pylab.plot(mg.dx * np.arange(nrows), elev_r[:, int(ncols // 2)]) print "Completed loop ", i print "Completed the simulation. Plotting..." # Finalize and plot: # put a title on figure 4 pylab.figure(4) pylab.title("N-S cross_section, linear diffusion") pylab.xlabel("Distance") pylab.ylabel("Elevation")
#instantiate the components: diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = DiffusionComponent(grid=mg, input_stream=input_file) #Perform the loops. for i in xrange(nt): #This line performs the actual functionality of the component: #***NB: both diffusers contain an "automatic" element of uplift. #You can suppress this for the linear diffuser with the *internal_uplift* keyword, =False #See the docstrings for both classes for more details. #Switch these lines to switch between diffusion styles: #mg = diffuse.diffuse(mg, i*dt) #nonlinear diffusion mg = lin_diffuse.diffuse(mg) #linear diffusion #Plot a Xsection north-south through the middle of the data, once per loop pylab.figure(1) elev_r = mg.node_vector_to_raster(mg['node']['topographic_elevation']) im = pylab.plot(mg.dx * np.arange(nrows), elev_r[:, int(ncols // 2)]) print 'Completed loop ', i print 'Completed the simulation. Plotting...' #Finalize and plot: #put a title on figure 1 pylab.figure(1) pylab.title('N-S cross_section') pylab.xlabel('Distance')