np.vstack((mg.node_x.max() - mg.node_x, mg.node_x - mg.node_x.min())), axis=0 ) y_distance_from_edge = np.amin( np.vstack((mg.node_y.max() - mg.node_y, mg.node_y - mg.node_y.min())), axis=0 ) # make the "hole" hole_elev = np.sqrt(x_distance_from_center ** 2 + y_distance_from_center ** 2) # make the rim: rim_elev = np.sqrt(x_distance_from_edge ** 2 + y_distance_from_edge ** 2) # assemble z = np.amin(np.vstack((hole_elev, rim_elev)), axis=0) z += np.random.rand(nx * ny) / 1000. mg.add_field("node", "topographic__elevation", z, copy=False) fr = FlowAccumulator(mg, flow_director="D8") lf = DepressionFinderAndRouter(mg) fr.run_one_step() figure("old drainage area") imshow_grid(mg, "drainage_area") lf.map_depressions(pits=mg.at_node["flow__sink_flag"]) figure("depression depth") imshow_grid(mg, "depression__depth") figure("new drainage area") imshow_grid(mg, "drainage_area")
mg = RasterModelGrid((nrows, ncols), xy_spacing=dx) # create the fields in the grid mg.add_zeros("topographic__elevation", at="node") z = mg.zeros(at="node") + init_elev # z += mg.node_x*0.001 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 ...") time_on = time.time() # instantiate the components: fr = FlowAccumulator(mg, flow_director="D8") sp = StreamPowerEroder(mg, "./drive_sp_params.txt") lf = DepressionFinderAndRouter(mg) # load the Fastscape module too, to allow direct comparison fsp = FastscapeEroder(mg, "./drive_sp_params.txt") # perform the loop: elapsed_time = 0. # total time in simulation while elapsed_time < time_to_run: # for i in range(10): print(elapsed_time) if elapsed_time + dt > time_to_run: print("Short step!") dt = time_to_run - elapsed_time mg = fr.route_flow(method="D8") lf.map_depressions()
mg = RasterModelGrid(nrows, ncols, dx) # 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 + np.random.rand(len(z)) / 1000. # make some surface load stresses in a field to test mg.at_node["surface_load__stress"] = np.zeros(nrows * ncols, dtype=float) # instantiate: gf = gFlex(mg, "./coupled_SP_gflex_params.txt") fsp = FastscapeEroder(mg, "./coupled_SP_gflex_params.txt") sp = StreamPowerEroder(mg, "./coupled_SP_gflex_params.txt") fr = FlowAccumulator(mg, flow_director="D8") # 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.run_one_step() # mg = fsp.erode(mg) mg, _, _ = sp.erode( mg, dt, node_drainage_areas="drainage_area", slopes_at_nodes="topographic__steepest_slope",
mg = RasterModelGrid(nrows, ncols, dx) #create the fields in the grid mg.add_zeros('topographic__elevation', at='node') z = mg.zeros(at='node') + init_elev #z += mg.node_x*0.001 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 ...' ) time_on = time.time() #instantiate the components: fr = FlowAccumulator(mg, flow_director='D8') sp = StreamPowerEroder(mg, './drive_sp_params.txt') lf = DepressionFinderAndRouter(mg) #load the Fastscape module too, to allow direct comparison fsp = FastscapeEroder(mg, './drive_sp_params.txt') #perform the loop: elapsed_time = 0. #total time in simulation while elapsed_time < time_to_run: #for i in range(10): print(elapsed_time) if elapsed_time+dt>time_to_run: print("Short step!") dt = time_to_run - elapsed_time mg = fr.route_flow(method='D8') lf.map_depressions()
mg = RasterModelGrid(nrows, ncols, dx) #create the fields in the grid mg.add_zeros('topographic__elevation', at='node') z = mg.zeros(at='node') + init_elev #z += mg.node_x*0.001 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 ...') time_on = time.time() #instantiate the components: fr = FlowAccumulator(mg, flow_director='D8') sp = StreamPowerEroder(mg, './drive_sp_params.txt') lf = DepressionFinderAndRouter(mg) #load the Fastscape module too, to allow direct comparison fsp = FastscapeEroder(mg, './drive_sp_params.txt') #perform the loop: elapsed_time = 0. #total time in simulation while elapsed_time < time_to_run: #for i in range(10): print(elapsed_time) if elapsed_time + dt > time_to_run: print("Short step!") dt = time_to_run - elapsed_time mg = fr.route_flow(method='D8') lf.map_depressions()
(mg.node_x.max() - mg.node_x, mg.node_x - mg.node_x.min())), axis=0) y_distance_from_edge = np.amin(np.vstack( (mg.node_y.max() - mg.node_y, mg.node_y - mg.node_y.min())), axis=0) # make the "hole" hole_elev = np.sqrt(x_distance_from_center**2 + y_distance_from_center**2) # make the rim: rim_elev = np.sqrt(x_distance_from_edge**2 + y_distance_from_edge**2) # assemble z = np.amin(np.vstack((hole_elev, rim_elev)), axis=0) z += np.random.rand(nx * ny) / 1000. mg.add_field('node', 'topographic__elevation', z, copy=False) fr = FlowAccumulator(mg, flow_director='D8') lf = DepressionFinderAndRouter(mg) fr.run_one_step() figure('old drainage area') imshow_node_grid(mg, 'drainage_area') lf.map_depressions(pits=mg.at_node['flow__sink_flag']) figure('depression depth') imshow_node_grid(mg, 'depression__depth') figure('new drainage area') imshow_node_grid(mg, 'drainage_area')
mg = RasterModelGrid((nrows, ncols), xy_spacing=dx) # 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 + np.random.rand(len(z)) / 1000. # make some surface load stresses in a field to test mg.at_node["surface_load__stress"] = np.zeros(nrows * ncols, dtype=float) # instantiate: gf = gFlex(mg, "./coupled_SP_gflex_params.txt") fsp = FastscapeEroder(mg, "./coupled_SP_gflex_params.txt") sp = StreamPowerEroder(mg, "./coupled_SP_gflex_params.txt") fr = FlowAccumulator(mg, flow_director="D8") # 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.run_one_step() # mg = fsp.erode(mg) mg, _, _ = sp.erode( mg, dt, node_drainage_areas="drainage_area", slopes_at_nodes="topographic__steepest_slope",