 NCL Home > Documentation > Functions > Spherical harmonic routines

# vhsgc

Computes vector spherical harmonic syntheses of vector fields on a gaussian grid via spherical harmonics.

## Prototype

```	procedure vhsgc (
br  : numeric,
bi  : numeric,
cr  : numeric,
ci  : numeric,
u   : float or double,
v   : float or double
)
```

## Arguments

br
bi
cr
ci

arrays containing vector spherical harmonic coefficients (input, two or more dimensions). In general, these were created in the process of doing spherical harmonic analysis by invoking vhagc. These coefficients must be in mathematical coordinates. The br,bi coefficients are associated with v (north-south, meridional component), and cr,ci are associated with u (east-west, zonal component). Please read the documentation at:

http://www.scd.ucar.edu/css/software/spherepack/vhsgc.txt

u
v

arrays containing the reconstructed vector components.

## Description

vhsgc performs the vector spherical harmonic synthesis using the coefficients generated by vhagc. Note that both vhagc and vhsgc operate on a gaussian grid.

NOTE: This procedure does not allow for missing data (defined by the _FillValue attribute) to be present.

If the original input arrays are on a fixed grid, vhsec should be used. Also, note that vhsgc is the procedural version of vhsgC.

## Examples

In the examples below, u and v are on a gaussian grid.

Example 1

u(nlat,nlon), v(nlat,nlon)

```N = nlat
if (nlon%2 .eq.0) then    ; note % is NCL's modulus operator
if (nlat.gt. (nlon+2)/2) then
N = (nlon+2)/2
end if
else                      ; nlon must be odd
if (nlat.gt. (nlon+1)/2) then
N = (nlon+1)/2
end if
end if

br = new ( (/nlat,N/), float)
bi = new ( (/nlat,N/), float)
cr = new ( (/nlat,N/), float)
ci = new ( (/nlat,N/), float)

vhagc (u,v,br,bi,cr,ci)
[do something with the coefficients]
vhsgc (br,bi,cr,ci,u,v)
```
Example 2

u(nt,nlat,nlon), v(nt,nlat,nlon)

```[same if test as in Example 1]

br = new ( (/nt,nlat,N/), float)
bi = new ( (/nt,nlat,N/), float)
cr = new ( (/nt,nlat,N/), float)
ci = new ( (/nt,nlat,N/), float)

vhagc (u,v,br,bi,cr,ci)
[do something with the coefficients]
vhsgc (br,bi,cr,ci,u,v)
```
Example 3

g(nt,nlvl,nlat,nlon)

```[same if test as in Example 1]

br = new ( (/nt,nlvl,nlat,N/), float)
bi = new ( (/nt,nlvl,nlat,N/), float)
cr = new ( (/nt,nlvl,nlat,N/), float)
ci = new ( (/nt,nlvl,nlat,N/), float)

vhagc (u,v,br,bi,cr,ci)
[do something with the coefficients]
vhsgc (br,bi,cr,ci,u,v)
```