mg.create_node_array_zeros('topographic_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.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 = RasterModelGrid(nrows, ncols, dx) # mg.set_looped_boundaries(True, True) mg.set_closed_boundaries_at_grid_edges(True, True, True, True) #create the fields in the grid mg.create_node_array_zeros('topographic__elevation') z = mg.create_node_array_zeros() + init_elev mg.at_node['topographic__elevation'] = z + numpy.random.rand(len(z)) / 1000. # Display a message print('Running ...') start_time = time.time() #instantiate the component: diffusion_component = PerronNLDiffuse(mg, './drive_perron_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: diffusion_component.input_timestep(dt) mg.at_node['topographic__elevation'][mg.active_nodes[:( mg.active_nodes.shape[0] // 2.)]] += uplift * dt #half block uplift mg = diffusion_component.diffuse(mg, elapsed_time) elapsed_time += dt print('Total run time = ' + str(time.time() - start_time) + ' seconds.')