NCL Home > Documentation > Functions > Meteorology

wind_component

Calculate zonal and meridional wind components from wind speed and wind direction.

Available in version 6.1.0 and later.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

	function wind_component (
		wspd  : numeric,  ; float, double, integer only
		wdir  : numeric,  
		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.

opt

  • Set opt=0 to have the zonal and meridional wind components returned within a single array.
  • Set opt=1 to have the zonal and meridional wind components returned as two variables contained within a variable of type list. This option was introduced in NCL 6.4.0

See examples.

Return value

Regardless, if opt=0 or opt=1, the returned variable(s) will be type double if wspd or wdir is double, otherwise the returned variable(s) will be type float.

If opt=0, a single array containing an extra dimension of size 2 as the leftmost dimension will be returned:

    2 x dimsizes(wspd)

If opt=1, a single variable of type list will be returned. It will contain two variables: (i) zonal and (ii) meridional wind components.

    [/ zonal, meridional /]                ; added to NCL 6.4.0

Description

Calculates meteorological 'zonal' and 'meridional' wind components. Specifically:

      u = -wspd*sin(wdir*rad)   ; rad (=0.01745329)  converts degrees to radians
      v = -wspd*cos(wdir*rad)

See Also

wind_speed, wind_direction, wind_stats

Examples

Example 1: The following illustrates usage including returning the wind components via opt=0 and opt=1 .

   u    = (/ 10,   0,   0, -10, 10,  10, -10, -10, 0/)    ; 9 cases
   v    = (/  0,  10, -10,   0, 10, -10,  10, -10, 0/)

   wspd = wind_speed(u,v)                        ; = sqrt(u^2 + v^2)
   wdir = wind_direction(u,v,0)
   print(u+"  "+v+"  "+wspd+"  "+wdir)
   print("=====================")
                                                  ; convert back to source components
   uv   = wind_component(wspd,wdir,0)             ; uv(2,:)
   printVarSummary(uv)

   UV   = wind_component(wspd,wdir,1)             ; [/ zonal, meridional /]
   printVarSummary(UV)
   print("=====================")
                                                  ; for clarity, explicitly extract
   U    = UV[0]                                   ; 1st component of list
   V    = UV[1]                                   ; 2nd    "
   delete(UV)                                     ; no longer needed

   print(uv(0,:)+"  "+uv(1,:)+"  "+U+"  "+V )

Edited output from wind_direction:

         U     V    spd    dir
   (0)	10     0     10    270    (west)
   (1)	 0    10     10    180    (south)
   (2)   0   -10     10      0    (north)
   (3) -10     0     90     90    (east)
   
   (4)	10    10  14.14    225    (southwest)
   (5)	10   -10  14.14    315    (northwest)
   (6) -10    10  14.14    135    (northeast)
   (7) -10   -10  14.14     45    (southeast)
   
   (8)	 0     0      0      0    (calm;   opt=0)

Edited output from wind_component (opt=0):

   Variable: uv
   Type: float
   Total Size: 72 bytes
               18 values
   Number of Dimensions: 2
   Dimensions and sizes:	[uv | 2] x [9]   ; Note the left most dimension
   Coordinates: 
   Number Of Attributes: 2
     _FillValue :	1e+20
     long_name :	zonal and meridional wind components
   
   Edited output from wind_component (opt=1):
   ====
   Variable: UV
   Type: list       ; note the type
   Total items: 2
   
After extraction (as previously noted, for clarity only)
   
   Variable: U
   Type: float
   Total Size: 36 bytes
               9 values
   Number of Dimensions: 1
   Dimensions and sizes:   [9]
   Coordinates: 
   Number Of Attributes: 1
     long_name :   wind speed
   (0)     =====================
   
   Variable: V
   Type: float
   Total Size: 36 bytes
               9 values
   Number of Dimensions: 1
   Dimensions and sizes:   [9]
   Coordinates: 
   Number Of Attributes: 1
     long_name :   wind speed
   
   
      uv(0,:)  uv(1,:)      U      V 
   (0)   10        0       10      0
   (1)    0       10        0     10
   (2)    0      -10        0    -10
   (3)  -10        0      -10      0
   (4)   10       10       10     10
   (5)   10      -10       10    -10
   (6)  -10       10      -10     10
   (7)  -10      -10      -10    -10   
   (8)    0        0        0      0