@BeginModule
@NewPage
@Name      = Wind
@Title     = Wind transformation
@Section   = Transformation
@Class     = Transformation
@Arguments = ifile ofile
@Operators = dv2uv dv2uvl uv2dv uv2dvl dv2ps

@BeginDescription
This module converts relative divergence and vorticity to U and V wind and vice versa.
Divergence and vorticity are spherical harmonic coefficients in spectral space and
U and V are on a regular Gaussian grid. The Gaussian latitudes need to be ordered from
north to south.
@EndDescription
@EndModule


@BeginOperator_dv2uv
@Title     = Divergence and vorticity to U and V wind

@BeginDescription
Calculate U and V wind on a Gaussian grid from spherical harmonic 
coefficients of relative divergence and vorticity. The divergence and vorticity 
need to have the names sd and svo or code numbers 155 and 138.
The number of latitudes of the resulting Gaussian grid is calculated 
from the triangular truncation by:
@IfMan

   nlat = NINT((trunc*3 + 1.)/2.)
@EndifMan
@IfDoc
\\
@BeginMath
   \mbox{nlat} = NINT((\mbox{trunc}*\fbox{3} + 1.)/2.)
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_dv2uvl
@Title     = Divergence and vorticity to U and V wind (linear)

@BeginDescription
Calculate U and V wind on a Gaussian grid from spherical harmonic 
coefficients of relative divergence and vorticity. The divergence and vorticity 
need tohave the names sd and svo or code numbers 155 and 138.
The number of latitudes of the resulting Gaussian grid is calculated 
from the triangular truncation by:
@IfMan

   nlat = NINT((trunc*2 + 1.)/2.)
@EndifMan
@IfDoc
\\
@BeginMath
   \mbox{nlat} = NINT((\mbox{trunc}*\fbox{2} + 1.)/2.)
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_uv2dv
@Title     = U and V wind to divergence and vorticity

@BeginDescription
Calculate spherical harmonic coefficients of relative divergence and vorticity
from U and V wind. The U and V wind need to be on a Gaussian grid and need to have the 
names u and v or the code numbers 131 and 132.
The triangular truncation of the resulting spherical harmonics
is calculated from the number of latitudes by:
@IfMan

   trunc = (nlat*2 - 1) / 3
@EndifMan
@IfDoc
\\
@BeginMath
   \mbox{trunc} = (\mbox{nlat}*2 - 1) / \fbox{3}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_uv2dvl
@Title     = U and V wind to divergence and vorticity (linear)

@BeginDescription
Calculate spherical harmonic coefficients of relative divergence and vorticity
from U and V wind. The U and V wind need to be on a Gaussian grid and need to have the 
names u and v or the code numbers 131 and 132.
The triangular truncation of the resulting spherical harmonics
is calculated from the number of latitudes by:
@IfMan

   trunc = (nlat*2 - 1) / 2
@EndifMan
@IfDoc
\\
@BeginMath
   \mbox{trunc} = (\mbox{nlat}*2 - 1) / \fbox{2}
@EndMath
@EndifDoc
@EndDescription
@EndOperator


@BeginOperator_dv2ps
@Title     = D and V to velocity potential and stream function

@BeginDescription
Calculate spherical harmonic coefficients of velocity potential and stream function from 
spherical harmonic coefficients of relative divergence and vorticity. The divergence and 
vorticity need to have the names sd and svo or code numbers 155 and 138.
@EndDescription
@EndOperator


@BeginExample
Assume a dataset has at least spherical harmonic coefficients of divergence and vorticity.
To transform the spectral divergence and vorticity to U and V wind on a Gaussian grid use:
@BeginVerbatim
   cdo dv2uv ifile ofile
@EndVerbatim
@EndExample
