gradient
- gradient(fs, mode='fdiff', poles_missing_values=False, vector=False)
Computes the horizontal gradient of each field in a
Fieldset
in */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
mode
is “felem”.vector (bool, default: False) – indicates if
fs
is a vector field whenmode
is “felem”
- Return type
The numerical method to compute the gradient is based on the value of
mode
.When
mode
is “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
mode
is “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. Ifvector
is 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()
.