NCL Home > Documentation > Functions > Spherical harmonic routines


Computes the divergent (irrotational) wind components for a gaussian grid via spherical harmonics.


	function dv2uvG (
		dv  : numeric   

	return_val [2, dimsizes(dv)] :  float or double



Divergence array (input, two or more dimensions, where the rightmost two dimensions must be lat x lon)

  • input values must be in ascending latitude order
  • input array must be on a global grid

Return value

The results are returned in an array dimensioned 2 x N x nlat x nlon, where the 0-th point of the leftmost dimension contains the u component and the 1-th point of the leftmost dimension contains the v component (both in ascending latitude order). N represents all but the last two dimensions of dv. If the input array is two-dimensional, then N can either be considered equal to 1 or nothing at all. The array returned will be of type double if the input is double, and float otherwise.


The function dv2uvG computes the divergent wind components given an array, dv, containing divergence and operates on a gaussian grid.

This function does not handle missing values (defined by the _FillValue attribute). If any missing values are encountered in a particular 2D input grid, then all of the values in the corresponding output grid will be set to the default missing value appropriate to the type of the output.

Arrays which have dimensions N x nlat x nlon should not include the cyclic (wraparound) points when invoking the procedures and functions which use spherical harmonics (Spherepack).

Use dv2uvG_Wrap if retention of metadata is desired.

If the input array dv is on a fixed grid, dv2uvF should be used. Also, note that dv2uvG is the function version of dv2uvg.

See Also

dv2uvF, dv2uvf, dv2uvg, uv2dvF, uv2dvG


Example 1

Let div(nlat,mlon) be an array on a gaussian grid. Then:

    uvd = dv2uvG (div)
will return the divergent zonal and meridional wind components.

uvd(0,nlat,mlon) <== divergent zonal wind components
uvd(1,nlat,mlon) <== divergent meridional wind components
These values are the same as those returned by the procedural version of this routine but the user does not have to explicitly allocate memory. For example:

  ud = new (dimsizes(div), typeof(div))
  vd = new (dimsizes(div), typeof(div))
  dv2uvg (div, ud, vd)   
Example 2

Read u/v from a netCDF file and compute divergence:

  f = addfile ("", "r")
  u = f->U
  v = f->V

  div = uv2dvG(u,v) ;computes divergence given the u and v components gaussian grid)

  uvd = dv2uvG (div)


If jer or ker is equal to:

1 : error in the specification of nlat
2 : error in the specification of nlon
4 : error in the specification of nt (jer only)