def direct_flow(self): """ Find flow directions, save to the model grid, and return receivers. direct_flow() checks for updated boundary conditions, calculates slopes on links, finds baselevel nodes based on the status at node, calculates flow directions, saves results to the grid, and returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] an alternative to direct_flow() is run_one_step() which does the same things but also returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] """ self._check_updated_bc() # update the surface, if it was provided as a model grid field. self._changed_surface() # step 1. Calculate link slopes. link_slope = -self._grid._calculate_gradients_at_d8_active_links( self.surface_values ) # Step 2. Find and save base level nodes. (baselevel_nodes,) = numpy.where( numpy.logical_or( self._grid.status_at_node == FIXED_VALUE_BOUNDARY, self._grid.status_at_node == FIXED_GRADIENT_BOUNDARY, ) ) # Calculate flow directions by D8 method receiver, steepest_slope, sink, recvr_link = flow_direction_DN.flow_directions( self.surface_values, self._active_links, self._activelink_tail, self._activelink_head, link_slope, grid=self._grid, baselevel_nodes=baselevel_nodes, ) # Save the four ouputs of this component. self._grid["node"]["flow__receiver_node"][:] = receiver self._grid["node"]["topographic__steepest_slope"][:] = steepest_slope self._grid["node"]["flow__link_to_receiver_node"][:] = recvr_link self._grid["node"]["flow__sink_flag"][:] = numpy.zeros_like( receiver, dtype=bool ) self._grid["node"]["flow__sink_flag"][sink] = True return receiver
def direct_flow(self): """Find flow directions, save to the model grid, and return receivers. direct_flow() checks for updated boundary conditions, calculates slopes on links, finds baselevel nodes based on the status at node, calculates flow directions, saves results to the grid, and returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] An alternative to direct_flow() is run_one_step() which does the same things but also returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] """ self._check_updated_bc() # update the surface, if it was provided as a model grid field. self._changed_surface() # step 1. Calculate link slopes at active links only. all_grads = -self._grid.calc_grad_at_link(self._surface_values) link_slope = all_grads[self._grid.active_links] # Step 2. Find and save base level nodes. (baselevel_nodes,) = np.where( np.logical_or( self._grid.status_at_node == NodeStatus.FIXED_VALUE, self._grid.status_at_node == NodeStatus.FIXED_GRADIENT, ) ) # Calculate flow directions receiver, steepest_slope, sink, recvr_link = flow_direction_DN.flow_directions( self._surface_values, self._active_links, self._activelink_tail, self._activelink_head, link_slope, grid=self._grid, baselevel_nodes=baselevel_nodes, ) # Save the four ouputs of this component. self._grid["node"]["flow__receiver_node"][:] = receiver self._grid["node"]["topographic__steepest_slope"][:] = steepest_slope self._grid["node"]["flow__link_to_receiver_node"][:] = recvr_link self._grid["node"]["flow__sink_flag"][:] = np.zeros_like(receiver, dtype=bool) self._grid["node"]["flow__sink_flag"][sink] = True # determine link directions self._determine_link_directions() return receiver
def direct_flow(self): """ Find flow directions, save to the model grid, and return receivers. direct_flow() checks for updated boundary conditions, calculates slopes on links, finds baselevel nodes based on the status at node, calculates flow directions, saves results to the grid, and returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] an alternative to direct_flow() is run_one_step() which does the same things but also returns a at-node array of receiver nodes. This array is stored in the grid at: grid['node']['flow__receiver_node'] """ # step 0. Check and update BCs if self._bc_set_code != self.grid.bc_set_code: self.updated_boundary_conditions() self._bc_set_code = self.grid.bc_set_code # update the surface, if it was provided as a model grid field. self._changed_surface() # step 1. Calculate link slopes. link_slope = -self._grid._calculate_gradients_at_d8_active_links( self.surface_values) # Step 2. Find and save base level nodes. (baselevel_nodes, ) = numpy.where( numpy.logical_or( self._grid.status_at_node == FIXED_VALUE_BOUNDARY, self._grid.status_at_node == FIXED_GRADIENT_BOUNDARY)) # Calculate flow directions by D8 method receiver, steepest_slope, sink, recvr_link = \ flow_direction_DN.flow_directions(self.surface_values, self._active_links, self._activelink_tail, self._activelink_head, link_slope, grid=self._grid, baselevel_nodes=baselevel_nodes) # Save the four ouputs of this component. self._grid['node']['flow__receiver_node'][:] = receiver self._grid['node']['topographic__steepest_slope'][:] = steepest_slope self._grid['node']['flow__link_to_receiver_node'][:] = recvr_link self._grid['node']['flow__sink_flag'][:] = numpy.zeros_like(receiver, dtype=bool) self._grid['node']['flow__sink_flag'][sink] = True return receiver