##create the elevation field in the grid: #create the field mg.create_node_array_zeros('planet_surface__elevation') z = mg.create_node_array_zeros() + leftmost_elev z += initial_slope*np.amax(mg.node_y) - initial_slope*mg.node_y #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'])
z = mg.create_node_array_zeros() + leftmost_elev z += initial_slope * np.amax(mg.node_y) - initial_slope * mg.node_y #put these values plus roughness into that field mg.at_node['topographic_elevation'] = z + np.random.rand(len(z)) / 100000. #set up grid's boundary conditions (bottom, right, top, left is inactive) 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'])
##create the elevation field in the grid: #create the field mg.create_node_array_zeros('planet_surface__elevation') z = mg.create_node_array_zeros() + leftmost_elev z += initial_slope * np.amax(mg.node_y) - initial_slope * mg.node_y #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) lin_diffuse.initialize(input_file) #perform the loops: for i in xrange(nt): mg['node']['planet_surface__elevation'][ mg.get_interior_nodes()] += uplift_per_step mg = fr.route_flow(grid=mg) mg = sp.erode(mg) mg = diffuse.diffuse(mg, i * dt) #mg = lin_diffuse.diffuse(mg, dt) ##plot long profiles along channels pylab.figure(6) profile_IDs = prf.channel_nodes(mg, mg.at_node['steepest_slope'], mg.at_node['drainage_area'],
#create the field mg.create_node_array_zeros('topographic_elevation') z = mg.create_node_array_zeros() + leftmost_elev #in our case, slope is zero, so the leftmost_elev is the mean elev #put these values plus roughness into that field mg['node'][ 'topographic_elevation'] = z + np.random.rand(len(z))/100000. #set up its boundary conditions (bottom, left, top, right) #The mechanisms for this are all automated within the grid object mg.set_fixed_value_boundaries_at_grid_edges(True, True, True, True) # Display a message print 'Running ...' #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)
##create the elevation field in the grid: #create the field mg.create_node_array_zeros('planet_surface__elevation') z = mg.create_node_array_zeros() + leftmost_elev z += initial_slope*np.amax(mg.node_y) - initial_slope*mg.node_y #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) lin_diffuse.initialize(input_file) #perform the loops: for i in xrange(nt): mg['node']['planet_surface__elevation'][mg.get_interior_nodes()] += uplift_per_step mg = fr.route_flow(grid=mg) mg = sp.erode(mg) mg = diffuse.diffuse(mg, i*dt) #mg = lin_diffuse.diffuse(mg, dt) ##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.set_inactive_boundaries(False, False, False, False) ##create the elevation field in the grid: #create the field mg.create_node_array_zeros('planet_surface__elevation') z = mg.create_node_array_zeros( ) + leftmost_elev #in our case, slope is zero, so the leftmost_elev is the mean elev #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: diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = DiffusionComponent(grid=mg, input_stream=input_file) #lin_diffuse.initialize(input_file) #Perform the loops. #First, we do the nonlinear diffusion: #We're going to perform a block uplift of the interior of the grid, but leave the boundary nodes at their original elevations. uplifted_nodes = mg.get_core_nodes( ) #access this function of the grid, and store the output with a local name #(Note: Node numbering runs across from the bottom left of the grid.) for i in xrange( nt ): #nt is the number of timesteps we calculated above, i.e., loop nt times. We never actually use i within the loop, but we could do. #("xrange" is a clever memory-saving way of producing consecutive integers to govern a loop) #this colon-then-tab-in arrangement is what Python uses to delineate connected blocks of text, instead of brackets or parentheses
# The mechanisms for this are all automated within the grid object mg.set_inactive_boundaries(False, False, False, False) ##create the elevation field in the grid: # create the field mg.create_node_array_zeros("planet_surface__elevation") z = mg.create_node_array_zeros() + leftmost_elev # in our case, slope is zero, so the leftmost_elev is the mean elev # put these values plus roughness into that field 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, input_stream=input_file) # lin_diffuse.initialize(input_file) # Perform the loops. # First, we do the nonlinear diffusion: # We're going to perform a block uplift of the interior of the grid, but leave the boundary nodes at their original elevations. uplifted_nodes = mg.get_core_nodes() # access this function of the grid, and store the output with a local name # (Note: Node numbering runs across from the bottom left of the grid.) for i in xrange( nt ): # nt is the number of timesteps we calculated above, i.e., loop nt times. We never actually use i within the loop, but we could do. # ("xrange" is a clever memory-saving way of producing consecutive integers to govern a loop) # this colon-then-tab-in arrangement is what Python uses to delineate connected blocks of text, instead of brackets or parentheses # This line performs the actual functionality of the component: