NCL Home > Documentation > Functions > Array query

isconstant

Test if all non-missing elements of an array are identical.

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 isconstant (
		x       
	)

Arguments

x

An array of any type and dimensionality.

Return value

Returns

        0 if the array contains different non-missing values.
        1 if all non-missing values of an array are identical.

Description

Tests if an array has multiple non-missing values.

See Also

isMonotonic

Examples

Example 1

      x  = new( 100, "integer", -999)
      x  = 3.0

      y  = random_normal( 0, 4, (/5,7,9/))
      z  = x
      z(4) = z@_FillValue
      z(8) = z@_FillValue

      A  = (/ "a", "a" /)
      BC = (/ "b", "c" /)

      ix = isconstant(x)     ; ix=1
      iy = isconstant(y)     ; iy=0
      iz = isconstant(z)     ; iz=1
      iA = isconstant(A)     ; iA=1
      iBC= isconstant(BC)    ;iBC=0