# Re: vertical velocity

```On Tue, 12 Mar 2002, maria lemos_diaz wrote:
> does someone have a journal which calculates vertical velocities
> from the U, V fields?

Hi Maria and Lei,

Here's a script I wrote a while ago to compute vertical velocity, assuming
a rigid lid at the surface.  Comments or improvements from the Ferret
community would be welcome!  Cheers,

Andrew

----------------------------------------------------------------------
Andrew Wittenberg          Program in Atmospheric and Oceanic Sciences
andyw@splash.princeton.edu                        Princeton University
----------------------------------------------------------------------

\can mode verify
! Usage: go calc_upwelling  u  v [coeff wgrid_opt outvar cu_zmax]
!                          \$1 \$2 [ \$3       \$4      \$5      \$6  ]
! Define a variable OUTVAR (default=W) which contains the upwelling (m/day),
! down to depth ZMAX (default = Z-range of U), calculated from zonal and
! meridional currents (U,V) which must be simple variables with (X,Y,Z) axes;
! a T axis is optional.  The horizontal currents (U,V) must be co-gridded
! and the Z axis should be a "depth" axis. (If necessary, regrid before
! calling this routine.)  The argument COEFF may be provided
! to convert U & V to units of m/s.
!
! If WGRID_OPT = 0 (default), W will be staggered from the vertical
!    grid of U and V, and the W-values in each grid cell will
!    refer to the center of the W-cell; convenient for interpolation.
! If WGRID_OPT = 1, W will have the same grid as U and V, and the
!    W-values will refer to the position at the W-cell bottom.
! If WGRID_OPT = 2, W will have the same grid as U and V, and the
!    W-values will refer to the center of the W-cell.  This case
!    is INTERPOLATED from case WGRID_OPT=0; the surface-layer W[k=1]
!    is defined to be half the upwelling at that grid-cell's bottom.
!
! Note that if the input Z-axis is irregular, WGRID_OPT=0
!    will produce upwelling POINTS which are not precisely aligned
!    with the grid cell BOTTOMS from the currents.
!
! EXAMPLES:
! Compute upwelling (m/day) for u/v (cm/s):
!   yes? can dat/all; use u.nc; use v.nc
!   yes? let uvar = u[d=1]; let vvar = v[d=2]
!   yes? go calc_upwelling uvar vvar .01
!
! atw 7/99

let cu_zmax = \$6"`\$1,r=zend`"
let \$5"w"_bottom = 86400 * \$3"1" * (\$1[x=@ddc,z=0:`cu_zmax`@iin] + \$2[y=@ddc,z=0:`cu_zmax`@iin])

IF `\$4"0" EQ 0` THEN
! Construct a staggered grid
def axis/z/edges/depth/unit="`\$1,r=zunit`" z_\$5"w"_mid = z[gz=\$1]
let/title="upwelling"/unit="m/day" \$5"w" = \$5"w"_bottom[z=0:`cu_zmax`,gz=z_\$5"w"_mid@asn]
ENDIF
IF `\$4"0" EQ 1` THEN
let/title="upwelling at cell bottom"/unit="m/day" \$5"w" = \$5"w"_bottom[z=0:`cu_zmax`]
ENDIF
IF `\$4"0" EQ 2` THEN
let \$5"w"_missing = (\$5"w"_bottom + \$5"w"_bottom[z=@shf:-1]) / 2
let/title="upwelling"/unit="m/day" \$5"w" = IF k[g=\$5"w"_bottom,z=0:`cu_zmax`] EQ 1 THEN \$5"w"_bottom/2 ELSE \$5"w"_missing
ENDIF

can var cu_zmax
set mode/last verify

```