priority_flow.find_orphan ========================= .. py:module:: priority_flow.find_orphan .. autoapi-nested-parse:: Find Orphan functions for PriorityFlow. This module provides functions to find orphan branches - unprocessed river cells that have D8 neighbors on the river network or on the boundary. This is useful for identifying missed cells during river network processing. Functions --------- .. autoapisummary:: priority_flow.find_orphan.find_orphan Module Contents --------------- .. py:function:: find_orphan(dem: numpy.ndarray, mask: numpy.ndarray, marked: numpy.ndarray) -> Dict[str, Union[int, numpy.ndarray, None]] Find orphan branches in river network processing. Function to look for unprocessed river cells that have D8 neighbors on the river network or on the boundary. :param dem: Digital elevation model matrix :type dem: np.ndarray :param mask: River network mask (1 for river cells, 0 for non-river cells) :type mask: np.ndarray :param marked: Matrix of grid cells that have been processed (1 for processed, 0 for unprocessed) :type marked: np.ndarray :returns: A dictionary containing: - 'norphan': Number of orphaned branches found - 'queue': Queue of marked neighbors to be processed (numpy array with columns: x, y, elevation) :rtype: Dict[str, Union[int, np.ndarray, None]] .. rubric:: Notes This function implements an orphan detection algorithm that: 1. Identifies unprocessed river cells (masked but not marked) 2. Checks D8 connectivity to find marked neighbors 3. Counts marked neighbors for each orphan cell 4. Creates a processing queue from marked neighbors of orphan cells The algorithm uses D8 connectivity (8-directional) to ensure complete neighbor checking and proper orphan identification.