second_derivative¶

metpy.calc.
second_derivative
(f, **kwargs)[source]¶ Calculate the second derivative of a grid of values.
Works for both regularlyspaced data and grids with varying spacing.
Either x or delta must be specified, or f must be given as an
xarray.DataArray
with attached coordinate and projection information. If f is anxarray.DataArray
, and x or delta are given, f will be converted to a pint.Quantity and the derivative returned as a pint.Quantity, otherwise, if neither x nor delta are given, the attached coordinate information belonging to axis will be used and the derivative will be returned as anxarray.DataArray
.This uses 3 points to calculate the derivative, using forward or backward at the edges of the grid as appropriate, and centered elsewhere. The irregular spacing is handled explicitly, using the formulation as specified by [Bowen2005].
Parameters:  f (arraylike) – Array of values of which to calculate the derivative
 axis (int or str, optional) – The array axis along which to take the derivative. If f is ndarraylike, must be an integer. If f is a DataArray, can be a string (referring to either the coordinate dimension name or the axis type) or integer (referring to axis number), unless using implicit conversion to pint.Quantity, in which case it must be an integer. Defaults to 0.
 x (arraylike, optional) – The coordinate values corresponding to the grid points in f.
 delta (arraylike, optional) – Spacing between the grid points in f. There should be one item less than the size of f along axis.
Returns: arraylike – The second derivative calculated along the selected axis.
See also