priority_flow.border_direction_fix ================================== .. py:module:: priority_flow.border_direction_fix .. autoapi-nested-parse:: Border direction fixing functions for PriorityFlow. This module contains functions for correcting the flow directions of border cells based on slope analysis to ensure proper drainage patterns. Functions --------- .. autoapisummary:: priority_flow.border_direction_fix.fix_border_dir Module Contents --------------- .. py:function:: fix_border_dir(direction: numpy.ndarray, dem: numpy.ndarray, d4: Tuple[int, int, int, int] = (1, 2, 3, 4)) -> numpy.ndarray Fix the directions of border cells. Originally all border cells are initialized to point out of the domain. This function checks the slopes and areas to determine if they need to swap direction to point into the domain instead. NOTE: This function is not yet tested. :param direction: Flow direction matrix [nx, ny] - will be modified in place :type direction: np.ndarray :param dem: Digital Elevation Model matrix [nx, ny] :type dem: np.ndarray :param d4: Direction numbering system for down, left, top, right. Defaults to (1, 2, 3, 4). :type d4: tuple, optional :returns: The modified direction array :rtype: np.ndarray .. rubric:: Notes This is a Python port of the R function FixBorderDir from PriorityFlow. The function analyzes slopes at domain boundaries to determine whether border cells should drain inward or outward. WARNING: This function modifies the input direction array in place for backwards compatibility with the R version. Direction mapping: - d4[0] = 1: Down - d4[1] = 2: Left - d4[2] = 3: Up - d4[3] = 4: Right