Anyone Have Script for ageostrophic wind components

Rick Danielson Rick.Danielson at PHYS.OCEAN.DAL.CA
Thu Feb 12 20:55:50 EST 2009

```Hi Ron,

The attached script should get you started, at least.

Regards,
Rick

> Hi
>
> Just wondering if anybody has a script for the ageostrophic wind already
> coded-up.  Mostly just interested in isallobaric wind and
> inertial-advective wind.  If not, I guess I have to do a bit of work to
> do.
>
> tks
>
> ron

"I'd put my money on the sun              During 1956-1965, "the world was
and solar energy.  What a           consuming 4 billion barrels of oil per
source of power!  I hope we             year and the average discovery was
don't have to wait until oil          around 30 billion.  Today we consume
and coal run out before we             30 billion barrels per year and the
tackle that." - Edison to Ford         discovery rate is now approaching 4
and Firestone in 1931 (from        billion barrels of crude oil per year."
"Uncommon Friends" by J.Newton)     - Kjell Aleklett of Uppsala University
-------------- next part --------------
* This script computes one of various diagnostic quantities using
* basic NCEP Reanalysis grids stored in a template netcdf file.
* An assumption is that the calculation domain of interest has been
* specified - RD, Feb `99

function keb()

* query file for dimensions of current viewing domain

"q dims"
rec = sublin(result,5)
if (subwrd(rec,3) = "varying")
tmin = subwrd(rec,11)
tmax = subwrd(rec,13)
tvar = "varying"
else
tval = subwrd(rec,9)
tvar = "fixed"
endif

rec = sublin(result,4)
if (subwrd(rec,3) = "varying")
zmin = subwrd(rec,11)
zmax = subwrd(rec,13)
zvar = "varying"
else
zval = subwrd(rec,9)
zvar = "fixed"
endif

rec = sublin(result,3)
if (subwrd(rec,3) = "varying")
ymin = subwrd(rec,11)
ymax = subwrd(rec,13)
yvar = "varying"
else
yval = subwrd(rec,9)
yvar = "fixed"
endif

rec = sublin(result,2)
if (subwrd(rec,3) = "varying")
xmin = subwrd(rec,11)
xmax = subwrd(rec,13)
xvar = "varying"
else
xval = subwrd(rec,9)
xvar = "fixed"
endif

* query file for dimensions of calculation domain

"d timemin"
rec = sublin(result,1)
timemin = subwrd(rec,4)

"d timemax"
rec = sublin(result,1)
timemax = subwrd(rec,4)

"d levmin"
rec = sublin(result,1)
levmin = subwrd(rec,4)

"d levmax"
rec = sublin(result,1)
levmax = subwrd(rec,4)

"d moistmax"
rec = sublin(result,1)
moistmax = subwrd(rec,4)

"d latmin"
rec = sublin(result,1)
latmin = subwrd(rec,4)

"d latmax"
rec = sublin(result,1)
latmax = subwrd(rec,4)

"d lonmin"
rec = sublin(result,1)
lonmin = subwrd(rec,4)

"d lonmax"
rec = sublin(result,1)
lonmax = subwrd(rec,4)

say ""
say "calculating quasi geostrophic terms, pointwise"
say ""
say "using the following calculation domain:"
say "time from "timemin" to "timemax
say "level from "levmin" to "levmax
say "lat from "latmin" to "latmax
say "lon from "lonmin" to "lonmax
say ""

say "defining temporary variables" ; say ""
defa = "EARTH =  6.371e6"
say  "  "defa
"define "defa
defa = "D2R =    3.141592654 / 180.0"
say  "  "defa
"define "defa
defa = "OMEG =   7.292e-5"
say  "  "defa
"define "defa
defa = "GRAV =   9.8"
say  "  "defa
"define "defa
say ""

say "computing over lat and lon:" ; say ""
"set t 1"
"set z 1"
"set lat "latmin" "latmax
"set lon "lonmin" "lonmax

defa = "delx = EARTH * cdiff(lon,x) * D2R * cos(lat*D2R)"
say  "  "defa ; say ""
"define "defa

defa = "dely = EARTH * cdiff(lat,y) * D2R"
say  "  "defa ; say ""
"define "defa

defa = "coriol = 2.0 * OMEG * sin(lat*D2R)"
say  "  "defa ; say ""
"define "defa

say "computing over time, level, lat, and lon:" ; say ""
"set t "timemin" "timemax
"set lev "levmin" "levmax
"set lat "latmin" "latmax
"set lon "lonmin" "lonmax

defa = "geou = -GRAV / coriol * cdiff(hgt,y) / dely"
say  "  "defa ; say ""
"define "defa

defa = "geov = GRAV / coriol * cdiff(hgt,x) / delx"
say  "  "defa ; say ""
"define "defa

defa = "newu = -GRAV / coriol * cdiff(hgt,y) / dely * (uwnd * -GRAV / coriol * cdiff(hgt,y) / dely + "
defb =                                                "vwnd *  GRAV / coriol * cdiff(hgt,x) / delx) / "
defc =               "(-GRAV / coriol * cdiff(hgt,y) / dely * -GRAV / coriol * cdiff(hgt,y) / dely + "
defd =                 "GRAV / coriol * cdiff(hgt,x) / delx *  GRAV / coriol * cdiff(hgt,x) / delx)"
say  "  "defa" "defb" "defc" "defd ; say ""
"define "defa" "defb" "defc" "defd

defa = "nevu =  GRAV / coriol * cdiff(hgt,x) / delx * (uwnd * -GRAV / coriol * cdiff(hgt,y) / dely + "
defb =                                                "vwnd *  GRAV / coriol * cdiff(hgt,x) / delx) / "
defc =               "(-GRAV / coriol * cdiff(hgt,y) / dely * -GRAV / coriol * cdiff(hgt,y) / dely + "
defd =                 "GRAV / coriol * cdiff(hgt,x) / delx *  GRAV / coriol * cdiff(hgt,x) / delx)"
say  "  "defa" "defb" "defc" "defd ; say ""
"define "defa" "defb" "defc" "defd

say "undefining temporary variables" ; say ""
"undefine EARTH"
"undefine D2R"
"undefine OMEG"
"undefine GRAV"

say "resetting the original viewing domain" ; say ""
if (tvar = "varying")
"set t "tmin" "tmax
else
"set t "tval
endif
if (zvar = "varying")
"set z "zmin" "zmax
else
"set z "zval
endif
if (yvar = "varying")
"set y "ymin" "ymax
else
"set y "yval
endif
if (xvar = "varying")
"set x "xmin" "xmax
else
"set x "xval
endif

say "re-creating the display script" ; say ""
"run gui_list"
```