gradient
- gradient(fs, mode='fdiff', poles_missing_values=False, vector=False)
Computes the horizontal gradient of each field in a
Fieldsetin */m units.- Parameters
fs (
Fieldset) – input 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”.vector (bool, default: False) – indicates if
fsis a vector field whenmodeis “felem”
- Return type
The numerical method to compute the gradient 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 option. Ifvectoris Falseregrid()is invoked with nabla=”scalar_gradient” otherwise nabla=”uv_gradient” is used.
The resulting fieldset contains two fields for each input field: the zonal derivative followed by the meridional derivative.
The computations for a field f are based on the following formula:
\[\nabla f = (\frac {\partial f}{\partial x}, \frac {\partial f}{\partial y}) = (\frac{1}{R \ cos\phi}\frac{\partial f}{\partial \lambda}, \frac{1}{R}\frac{\partial f}{\partial \phi} )\]where:
R is the radius of the Earth (in m)
\(\phi\) is the latitude
\(\lambda\) is the longitude.
Note
See also
first_derivative_x(),first_derivative_y(),second_derivative_x()andsecond_derivative_y().