carto_flow.flow_cartogram.displacement¶
Displacement computation utilities for flow-based cartography.
Functions:
-
displace_coords_numba–Numba-compiled coordinate displacement with bilinear interpolation on uniform grids.
-
max_velocity_magnitude–Single-pass max(sqrt(vx²+vy²)) without temporary array allocation.
-
max_abs_velocity–Single-pass max(|vx|, |vy|) without temporary array allocation.
displace_coords_numba
¶
displace_coords_numba(
coords: ndarray,
x_coords: ndarray,
y_coords: ndarray,
vx: ndarray,
vy: ndarray,
dt: float,
dx: float,
dy: float,
use_parallel: bool = True,
) -> np.ndarray
Dispatch to parallel or serial JIT variant based on use_parallel.
max_abs_velocity
¶
Return max(max|vx|, max|vy|) over all grid cells in a single pass.
Equivalent to max(np.max(np.abs(vx)), np.max(np.abs(vy))) but avoids
allocating the two intermediate abs arrays.
Parameters:
-
vx((ndarray, shape(sy, sx))) –Velocity component arrays.
-
vy((ndarray, shape(sy, sx))) –Velocity component arrays.
Returns:
-
float–Maximum absolute velocity in either direction.
max_velocity_magnitude
¶
Return max(sqrt(vx² + vy²)) over all grid cells in a single pass.
Equivalent to np.nanmax(np.sqrt(vx**2 + vy**2)) but avoids allocating
the intermediate arrays, cutting memory bandwidth by ~3x at large grid sizes.
Parameters:
-
vx((ndarray, shape(sy, sx))) –Velocity component arrays.
-
vy((ndarray, shape(sy, sx))) –Velocity component arrays.
Returns:
-
float–Maximum velocity magnitude.