mg.set_inactive_boundaries(False, True, False, True) ##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) 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...'
#create the field 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['node']['topographic__elevation'] = z + np.random.rand(len(z))/1000. #make some K values in a field to test mg.at_node['K_values'] = 0.00001+np.random.rand(nrows*ncols)/100000. #mg.at_node['water__volume_flux_in'] = dx*dx*np.ones_like(z) mg.at_node['water__volume_flux_in'] = dx*dx*np.ones_like(z)*100./(60.*60.*24.*365.25) #remember, flux is /sec, so this is a small number! #mg.set_closed_boundaries_at_grid_edges(True, True, False, False) #mg.set_closed_boundaries_at_grid_edges(True, True, False, True) print( 'Running ...' ) #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
#create the field 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 = 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'],
uplift = inputs.read_float("uplift_rate") init_elev = inputs.read_float("init_elev") 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.0 print("Running ...") # instantiate the components: 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.0 # total time in simulation while elapsed_time < time_to_run: print(elapsed_time) if elapsed_time + dt > time_to_run: print("Short step!")
uplift = inputs.read_float('uplift_rate') init_elev = inputs.read_float('init_elev') 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. print('Running ...') #instantiate the components: 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!"
#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 ...') #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) #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