NCL Home > Documentation > Functions > General applied math, Statistics


Computes the weighted sum of a variable's given dimension at all other dimensions and retains metadata.


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_sum_wgt_n_Wrap (
		x       : numeric,  
		w   [*] : numeric,  
		opt [1] : integer,  
		dim [1] : integer   

	return_val  :  float or double



A one dimensional array of weights. The length must be the same as the dim-th dimension of x.exit


A one-dimensional array of weights. The length must the same as the rightmost dimension of x.


A scalar: (a) opt=0 means compute the weighted sum only if all values are not missing; (b) opt=1 means compute the weighted sum of all non-missing values; (c) opt>1 means to return the weighted sum only if the number of non-missing values is greater-than or equal to opt.


A scalar, the dimension of "x" of which to do the weighted sum across.


This function is identical to dim_sum_wgt_n, except the return value will have metadata added based on metadata attached to x. See the dim_sum_wgt_n page for full documentation and examples.