dim_minind
Returns the index of the first occurrence of a minimum value within the specified dimension.
Available in version 6.4.0 and later.
Prototype
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" ; This library is automatically loaded ; from NCL V6.2.0 onward. ; No need for user to explicitly load. function dim_minind ( arg : numeric, dim [1] : integer ) return_val : integer array containing first occurrence of a minimum value
Arguments
argAn array of up to four dimensions.
dimThe dimension number of arg along which the first minimum is desired. Currently, this must be set to 0 which corresponds to the leftmost dimension.
Return value
integer array containing the index of first occurrence of a minimum value
Description
This function scans an array for the minimum value and returns the index of the first occurrence of the minimum along the specified dimension. Missing values are ignored. Remember that in NCL, indexing starts at 0, not 1.
This function will return a long if on a 64-bit system and the index value is >= 2 GB.
This function is based upon a response by Dave Allured (NOAA Affiliate) to an question asked on ncl-talk@ucar.edu.
See Also
dim_minind, maxind, minind, ind_resolve, min, max, dim_min, dim_max, dim_min_n, dim_max_n
Examples
Example 1: Trivial example. The results should be identical (i=>j=3)
x = (/3.,2.,5.,1.,5.,2.,5.,1.,3.,2./) imin = minind(x) ; Should be 3 jmin = dim_minind(x, 0)
Example 2: Find the first index value correspnding to the minimum and maximum values along the specified dimension.
z = (/ (/1, 2, 3, 4, 7/), \ ; a(4,5) ; dimension 0 is the leftmost dimension (/5, 6, 7, 8, 3/), \ (/9, 1, 9, 8,10/), \ (/7, 6, 1, 4, 3/) /) nmin = dim_minind(z, 0) ; nmim= (/0, 2, 3, 0, 1/) nmax = dim_maxind(z, 0) ; nmax= (/2, 1, 2, 1, 2/)