def _compute_parametric_acf(params, m, n):
    """Compute parametric ACF."""
    c, phi, sigma1, sigma2 = params

    phi_r = phi / 180.0 * np.pi
    rot_inv = np.array(
        [[np.cos(phi_r), np.sin(phi_r)], [-np.sin(phi_r), np.cos(phi_r)]]
    )

    if n % 2 == 0:
        n_max = int(n / 2)
    else:
        n_max = int(n / 2) + 1
    x = np.fft.ifftshift(np.arange(-int(n / 2), n_max))
    if m % 2 == 0:
        m_max = int(m / 2)
    else:
        m_max = int(m / 2) + 1
    y = np.fft.ifftshift(np.arange(-int(m / 2), m_max))

    grid_x, grid_y = np.meshgrid(x, y)
    grid_xy = np.vstack([grid_x.flatten(), grid_y.flatten()])
    grid_xy = np.dot(rot_inv, grid_xy)

    grid_xy[0, :] = grid_xy[0, :] / sigma1
    grid_xy[1, :] = grid_xy[1, :] / sigma2

    r2 = np.reshape(
        grid_xy[0, :] * grid_xy[0, :] + grid_xy[1, :] * grid_xy[1, :], grid_x.shape
    )
    result = np.exp(-np.sqrt(r2))

    return c * result
Compute parametric ACF.
pysteps/nowcasts/linda.py