pvtend.helmholtz.gradient

pvtend.helmholtz.gradient(phi: ndarray, dx: ndarray, dy: float) tuple[ndarray, ndarray][source]

Physical gradient (∂φ/∂x, ∂φ/∂y) — spectral zonal, FD meridional.

The zonal derivative uses a spectral (FFT) method so that the composition div(grad(χ)) is consistent with the compact Laplacian stencil used in solve_poisson_spherical_fft(). The meridional derivative keeps centred finite differences via derivatives.ddy().

Note

The meridional derivative uses plain centred FD, which does NOT match the conservative half-grid stencil in the Poisson solver. Therefore div_FD(gradient(χ)) ∇²χ. For a consistent round-trip use laplacian_spherical_fft() instead.

Parameters:
  • phi – Scalar field, shape (nlat, nlon).

  • dx – Zonal grid spacing [m]. Scalar or array of shape (nlat,). When an array, dx[j] = a · cos(φ_j) · Δλ.

  • dy – Meridional grid spacing [m].

Returns:

(dphi_dx, dphi_dy) — each (nlat, nlon).