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

dim_avg_wgt_n_Wrap

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

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

	return_val  :  float or double

Arguments

x

A variable of numeric type and any dimensionality. Missing values are indicated by the _FillValue attribute.

w

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

opt

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

dim

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

Description

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