z += initial_slope*np.amax(mg.node_y) - initial_slope*mg.node_y #put these values plus roughness into that field mg['node'][ 'topographic_elevation'] = z + np.random.rand(len(z))/100000. #set up grid's boundary conditions (bottom, left, top, right is inactive) mg.set_inactive_boundaries(False, True, False, True) mg.set_fixed_value_boundaries_at_grid_edges(True, False, True, False, value_of='topographic_elevation') print 'fixed vals in grid: ', mg.fixed_value_node_properties['values'] # Display a message print 'Running ...' #instantiate the components: fr = FlowRouter(mg) sde = SedDepEroder(mg, input_file) vid = VideoPlotter(mg, data_centering='node') time_on = time() #perform the loops: for i in xrange(nt): #print 'loop ', i mg.at_node['topographic_elevation'][mg.core_nodes] += uplift_per_step mg = fr.route_flow(grid=mg) #mg.calculate_gradient_across_cell_faces(mg.at_node['topographic_elevation']) #neighbor_slopes = mg.calculate_gradient_along_node_links(mg.at_node['topographic_elevation']) #mean_slope = np.mean(np.fabs(neighbor_slopes),axis=1) #max_slope = np.max(np.fabs(neighbor_slopes),axis=1) #mg,_,capacity_out = tl.erode(mg,dt,slopes_at_nodes='steepest_slope') #mg,_,capacity_out = tl.erode(mg,dt,slopes_at_nodes=max_slope) mg_copy = deepcopy(mg) mg,_ = sde.erode(mg,dt)
##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...' time_off = time()
#create the fields in the grid mg.add_zeros('topographic__elevation', at='node') z = mg.zeros(at='node') + 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!") dt = time_to_run - elapsed_time mg = fr.route_flow() #print 'Area: ', numpy.max(mg.at_node['drainage_area']) mg = fsp.erode(mg)
##create the elevation field in the grid: #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['node']['topographic_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']['topographic_elevation'][mg.core_nodes] += uplift_per_step mg = fr.route_flow(grid=mg) mg = sp.erode(mg) #vid.add_frame(mg, 'topographic_elevation') vid.add_frame(mg, mg.hillshade(alt=15.), cmap='gray') print 'Completed the simulation. Plotting...' time_off = time()
# set up grid's boundary conditions (bottom, left, top, right is inactive) mg.set_inactive_boundaries(True, False, True, False) mg.set_fixed_value_boundaries_at_grid_edges(False, True, False, True, value_of="topographic__elevation") print("fixed vals in grid: ", mg.fixed_value_node_properties["values"]) # Display a message print("Running ...") # instantiate the components: fr = FlowAccumulator(mg, flow_director="D8") sde = SedDepEroder(mg, input_file) vid = VideoPlotter(mg, data_centering="node") time_on = time() # perform the loops: for i in range(nt): # print 'loop ', i mg.at_node["topographic__elevation"][mg.core_nodes] += uplift_per_step mg = fr.run_one_step() # mg.calc_grad_across_cell_faces(mg.at_node['topographic__elevation']) # neighbor_slopes = mg.calc_grad_along_node_links(mg.at_node['topographic__elevation']) # mean_slope = np.mean(np.fabs(neighbor_slopes),axis=1) # max_slope = np.max(np.fabs(neighbor_slopes),axis=1) # mg,_,capacity_out = tl.erode(mg,dt,slopes_at_nodes='topographic__steepest_slope') # mg,_,capacity_out = tl.erode(mg,dt,slopes_at_nodes=max_slope) mg_copy = deepcopy(mg) mg, _ = sde.erode(mg, dt)
#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!" 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)