hand_curvature[:] = mg.at_node["height_above_drainage__elevation"].copy() df_output['mean_hand_curvature'] = np.mean(hand_curvature[mg.core_nodes]) hd.channel_mask = network_sat hd.run_one_step() hand_sat[:] = mg.at_node["height_above_drainage__elevation"].copy() df_output['mean_hand_sat_interstorm'] = np.mean(hand_sat[mg.core_nodes]) except: print('failed to calculate HAND') ######## Calculate drainage density dd = DrainageDensity(mg, channel__mask=np.uint8(network_curvature)) try: channel_mask = mg.at_node['channel__mask'] df_output['dd_curvature'] = dd.calculate_drainage_density() df_output['mean hillslope len curvature'] = 1 / (2 * df_output['dd_curvature']) channel_mask[:] = np.uint8(network_sat) df_output['dd_sat_interstorm'] = dd.calculate_drainage_density() df_output['mean hillslope len sat interstorm'] = 1 / ( 2 * df_output['dd_sat_interstorm']) except: print('failed to calculate drainage density') ####### calculate elevation change try: output_interval = df_params['output_interval'] except KeyError:
######## Calculate HAND hand = mg.add_zeros('node', 'hand') hd = HeightAboveDrainageCalculator(mg, channel_mask=network) hd.run_one_step() hand[:] = mg.at_node["height_above_drainage__elevation"].copy() df_output['mean hand'] = np.mean(hand[mg.core_nodes]) cell_area = max(mg.cell_area_at_node) df_output['hand mean ridges'] = np.mean( hand[mg.at_node["drainage_area"] == cell_area]) ######## Calculate drainage density if isinstance(mg, RasterModelGrid): dd = DrainageDensity(mg, channel__mask=np.uint8(network)) channel_mask = mg.at_node['channel__mask'] df_output['drainage density'] = dd.calculate_drainage_density() df_output['mean hillslope len'] = 1 / (2 * df_output['drainage density']) df_output['mean hillslope len ridges'] = np.mean( mg.at_node["surface_to_channel__minimum_distance"][ mg.at_node["drainage_area"] == cell_area]) ####### calculate relief change output_interval = int(files[1].split('_')[-1][:-3]) - int( files[0].split('_')[-1][:-3]) dt_nd = output_interval * dtg / tg relief_change = np.zeros(len(files)) for i in range(1, len(files)): grid = from_netcdf(files[i]) elev = grid.at_node['topographic__elevation'] relief_change[i] = np.mean(elev[grid.core_nodes])