divergence
- divergence(fx, fy, mode='fdiff', poles_missing_values=False)
Computes the divergence of 2-dimensional vector fields.
- Parameters
fx (
Fieldset) – zonal (west-east) vector component fieldsetfy (
Fieldset) – meridional (south-north) vector component fieldsetmode ({"fdiff", "felem"}, default: "fdiff") – specifies the computation mode (see below)
poles_missing_values (bool, default: False) – puts missing values at the poles when
modeis “felem”.
- Return type
The numerical method to compute the divergence is based on the value of
mode.When
modeis “fdiff”:a second order finite-difference approximation is used
the output fields contain missing values at the poles
only works for regular latitude-longitude grids
When
modeis “felem”:a finite-element technique is used
works with (regular and reduced) latitude-longitude and Gaussian grids
no missing values are allowed in
fs!the computations are performed by using
regrid()with the nabla=”uv_divergence” option
The computations for a vector field f=(fx,fy) are based on the following formula:
\[div(f) = \frac{1}{R \ cos\phi}\frac{\partial f_x}{\partial \lambda} + \frac{1}{R}\frac{\partial f_y}{\partial \phi} - \frac{f_y}{R}tan\phi\]where:
R is the radius of the Earth (in m)
\(\phi\) is the latitude
\(\lambda\) is the longitude.
If
fxandfyare horizontal wind components the ecCodes paramId of the resulting field is set to 155 (=divergence).Note
See also
vorticity(),shear_deformation()andstretch_deformation().