NCL Home > Documentation > Functions > Meteorology

# wind_stats

Given a sequence of wind speeds and directions, compute assorted wind-related statistics including the standard deviation of the wind direction.

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 wind_stats (
wspd     : numeric,  ; float, double, integer only
wdir     : numeric,
nDim [*] : integer,
opt      : integer
)
```

## Arguments

wspd

A variable of any dimensionality containing the wind speed. Array size and shape must match wdir.

wdir

A variable of any dimensionality containing the meteorological wind direction. Array size and shape must match wspd.

nDim

The dimension(s) of wspd on which to calculate the statistics. Most commonly, this is the 'time' dimension. Must be consecutive and monotonically increasing if not a scalar.

opt

Set to zero (0)

## Return value

A variable of type list containg six (6) variables: (i) average and (ii) standard deviation of the wspd; (iii) mean vector wind direction, (iv) standard deviation of the wind direction; (v) mean zonal and (vi) meridional wind components. All list members will be type double if wspd is double, otherwise float arrays are returned.

## Description

The mean wind speed and standard deviation are the classical statistical values. The mean wind direction is the result of computing the mean zonal ("U") and meridional ("V") components and using atan2.

Wind direction is a 'circular' quantity. It is defined [0..360); including 0 but excluding 360 and above. (Think of 360 as being a discontinuity.) Hence, the standard statistical formula is not appropriate in all cases. The wind_stats uses the method of Yamartino (1984) to approximate the directional standard deviation. This is accurate to within 2% of the theoretical value. This does assume that wind directions do not randomly span all directions.

In some applications, the standard deviation of wind direction is a measure of lateral turbulence, and can be used to estimate the Pasquill stability.

References:

```
NOAA's method for computing mean wid direction
NOAA: http://www.ndbc.noaa.gov/wndav.shtml

Turner, D.B. (1986): Comparison of Three Methods ...
http://journals.ametsoc.org/doi/pdf/10.1175/1520-0450%281986%29025%3C0703%3ACOTMFC%3E2.0.CO%3B2

Weber, R. (1997): Estimators for the Standard Deviation of Horizontal Wind Direction
http://journals.ametsoc.org/doi/pdf/10.1175/1520-0450%281997%29036%3C1403%3AEFTSDO%3E2.0.CO%3B2

Wikipedia;
https://en.wikipedia.org/wiki/Yamartino_method

Yamartino (1984): Journal of Climate and Applied Meteorology , 23, 1362-1366
http://dx.doi.org/10.1175/1520-0450(1984)023<1362:ACOSPE>2.0.CO;2
```

## Examples

Example 1

```   N     = 10
u    := random_normal(  0, 2, N)   ; zonal wind 'noise'
v    := random_normal(-10, 2, N)   ; winds from the north
wspd := wind_speed(u,v)
wdir := wind_direction(u,v,0)

print(sprintf("%7.2f", u)+sprintf("%7.2f", v)+sprintf("%7.2f", wspd)+sprintf("%7.2f", wdir))

x    := wind_stats(wspd, wdir, 0, False)  ; variable of type 'list'
; extract variables from list for clarity
wspd_avg = x[0]        ; average of 'wspd'
wspd_std = x[1]        ; standard deviation of 'wspd'
wdir_avg = x[2]        ; mean vector wind direction
wdir_std = x[3]        ; standard deviation of the wind direction
avgU     = x[4]        ; average zonal component
avgV     = x[5]        ; average medidional wind component
delete(x)        ; no longer needed

print(sprintf("%7.2f", wspd_avg)+sprintf("%7.2f", wspd_std)  \
+sprintf("%7.2f", wdir_avg)+sprintf("%7.2f", wdir_std)  \
+sprintf("%7.2f",    avgU )+sprintf("%7.2f",   avgV  )  )

The edited output is:

u      v     spd    dir
(0)	   1.74  -8.16   8.35 347.96
(1)	   1.75  -8.53   8.71 348.43
(2)	   3.89 -15.65  16.13 346.03
(3)	   1.97  -9.97  10.16 348.85
(4)	   0.71  -9.89   9.92 355.91
(5)	  -0.25  -8.49   8.49   1.71
(6)	  -1.72  -9.65   9.80  10.10
(7)	   1.75 -11.24  11.37 351.13
(8)	   1.86  -7.97   8.18 346.83
(9)	  -2.34 -11.00  11.25  11.98

wspd_avg =  10.24
wspd_std =   2.37
wdir_avg = 354.68     == vector wind direction
wdir_std =   9.24     == Yamartino estimate
avgU =   0.94
avgV = -10.06

```