# Display a message print 'Running ...' #instantiate the components: fr = FlowRouter(mg) sp = SPEroder(mg, input_file) vid = VideoPlotter(mg, data_centering='node') time_on = time() #perform the loops: for i in xrange(nt): print 'loop ', i mg['node']['planet_surface__elevation'][mg.core_nodes] += uplift_per_step mg = fr.route_flow(grid=mg) mg = sp.erode(mg) #vid.add_frame(mg, 'planet_surface__elevation') vid.add_frame(mg, mg.hillshade(alt=15.), cmap='gray') print 'Completed the simulation. Plotting...' time_off = time() #Finalize and plot elev = mg['node']['planet_surface__elevation'] #imshow.imshow_node_grid(mg, elev) print('Done.') print 'Time: ', time_off-time_on
# 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']) print 'Completed loop ', i
#instantiate the components: fr = FlowRouter(mg) #load the Fastscape module too, to allow direct comparison fsp = SPEroder(mg, './pot_fr_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() #print 'Area: ', numpy.max(mg.at_node['drainage_area']) #mg = fsp.erode(mg) mg = fsp.erode(mg, K_if_used='K_values') #mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='topographic__steepest_slope') #add uplift mg.at_node['topographic__elevation'][mg.core_nodes] += uplift*dt elapsed_time += dt pfr = PotentialityFlowRouter(mg, 'pot_fr_params.txt') pfr.route_flow(return_components=True)#route_on_diagonals=False) figure('Topo') imshow_node_grid(mg, 'topographic__elevation') figure('Potentiality flow fluxes') imshow_node_grid(mg, 'water__volume_flux_magnitude') figure('D8 drainage areas') imshow_node_grid(mg, 'drainage_area') figure('K (core only)')
# Display a message print 'Running ...' #instantiate the components: fr = FlowRouter(mg) sp = SPEroder(mg, input_file) diffuse = PerronNLDiffuse(mg, input_file) lin_diffuse = LinearDiffuser(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(dt) mg = fr.route_flow() mg = sp.erode(mg, dt) mg.at_node['topographic__elevation'][mg.core_nodes] += uplift_per_step ##plot long profiles along channels pylab.figure(6) profile_IDs = prf.channel_nodes(mg, mg.at_node['topographic__steepest_slope'], mg.at_node['drainage_area'], mg.at_node['flow_receiver']) dists_upstr = prf.get_distances_upstream(mg, len(mg.at_node['topographic__steepest_slope']), profile_IDs, mg.at_node['links_to_flow_receiver']) prf.plot_profiles(dists_upstr, profile_IDs, mg.at_node['topographic__elevation']) print 'Completed loop ', i print 'Completed the simulation. Plotting...'
vid = VideoPlotter(mg, data_centering="node", step=2.5) try: mg = copy.deepcopy(mg_mature) except NameError: # run to a steady state: # We're going to cheat by running Fastscape SP for the first part of the solution elapsed_time = 0.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() # print 'Area: ', numpy.max(mg.at_node['drainage_area']) mg = fsp.erode(mg) # mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='topographic__steepest_slope') # add uplift mg.at_node["topographic__elevation"][mg.core_nodes] += uplift * dt elapsed_time += dt mg_mature = copy.deepcopy(mg) else: # reinstantiate the components with the new grid fr = FlowRouter(mg) sp = StreamPowerEroder(mg, "./drive_sp_params.txt") fsp = Fsc(mg, "./drive_sp_params.txt") # load the Fastscape module too, to allow direct comparison fsp = Fsc(mg, "./drive_sp_params.txt")
vid = VideoPlotter(mg, data_centering='node', step=2.5) try: mg = copy.deepcopy(mg_mature) except NameError: #run to a steady state: #We're going to cheat by running Fastscape SP for the first part of the solution 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) #print 'Area: ', numpy.max(mg.at_node['drainage_area']) mg = fsp.erode(mg) #mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='steepest_slope') #add uplift mg.at_node['topographic_elevation'][mg.core_nodes] += uplift * dt elapsed_time += dt mg_mature = copy.deepcopy(mg) else: #reinstantiate the components with the new grid fr = FlowRouter(mg) sp = StreamPowerEroder(mg, './drive_sp_params.txt') fsp = Fsc(mg, './drive_sp_params.txt') #load the Fastscape module too, to allow direct comparison fsp = Fsc(mg, './drive_sp_params.txt')
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) #print 'Area: ', numpy.max(mg.at_node['drainage_area']) #mg = fsp.erode(mg) mg = fsp.erode(mg, K_if_used='K_values') #mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='steepest_slope') #add uplift mg.at_node['topographic_elevation'][mg.core_nodes] += uplift * dt elapsed_time += dt #Finalize and plot elev = mg['node']['topographic_elevation'] elev_r = mg.node_vector_to_raster(elev) # Clear previous plots pylab.figure(1) pylab.close() # Plot topography pylab.figure(1)