local_max_1d
Determines the relative maxima for a 1-dimensional array.
Available in version 4.2.0.a033 and later.
Prototype
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" function local_max_1d ( x [*] : numeric, cyclic : logical, delta [1] : numeric, iopt [1] : integer )
Arguments
xA one-dimensional (1D) numeric array.
cyclicA logical value indicating if x is cyclic [=True] or not [=False].
deltaTolerance level (positive). If values are within delta of surrounding values it will not be counted as a local maximum value.
ioptAn integer value indicating what is to be returned. iopt=0 means return the maximum values. iopt.ne.0 means return the indices [subscripts] where maximum values occured.
Return value
If iopt=0 then a 1D array containing the relative maxima is returned. Otherwise a 1D array containing the indices (subscripts) where the maxima are returned.
Description
Each element of x is checked against adjacent points to see if the difference exceeds delta.
See Also
Examples
Example 1
qmax = local_max_1d(q, False, 0.25, 0)
or
imax = local_max_1d(q, False, 0.25, 1)
if (.not.ismissing(imax)) then
qmax = q(imax)
zmax = z(imax) ; z where q is at a maximum
end if