For each index of dimensions 0..n-2, this function computes the variance of the n-1 dimension.
function dim_variance( x : numeric )
N = num(.not.ismissing(x))
begin ; ; Create example array ; a = onedtond(ispan(1,150,1),(/3,5,10/)) ; ; Assign dimension names ; a!0 = "time" a!1 = "latitude" a!2 = "longitude" ; ; Compute variance of dimension "longitude" at all time and latitude points ; pxy = dim_variance(a) N = num(.not.ismissing(a)) ; compute number of values used in calculation ; ; Compute variance of dimension "time" at all points latitude and longitude points ; The following uses Named Subscripting to reorder the input array ; such that time is the n-1 dimension. ; pyz = dim_variance( a(latitude | :, longitude | : , time | :) ) end
NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?