def _compute_kernel_isotropic(sigma, cutoff=6.0):
    """Compute isotropic Gaussian convolution kernel."""
    bb_y1, bb_x1, bb_y2, bb_x2 = (
        -sigma * cutoff,
        -sigma * cutoff,
        sigma * cutoff,
        sigma * cutoff,
    )

    x = np.arange(int(bb_x1), int(bb_x2) + 1).astype(float)
    if len(x) % 2 == 0:
        x = np.arange(int(bb_x1) - 1, int(bb_x2) + 1).astype(float)
    y = np.arange(int(bb_y1), int(bb_y2) + 1).astype(float)
    if len(y) % 2 == 0:
        y = np.arange(int(bb_y1) - 1, int(bb_y2) + 1).astype(float)

    x_grid, y_grid = np.meshgrid(x / sigma, y / sigma)

    r2 = x_grid * x_grid + y_grid * y_grid
    result = np.exp(-0.5 * r2)

    return result / np.sum(result)
Compute isotropic Gaussian convolution kernel.
pysteps/nowcasts/linda.py