[gradsusr] help with fndlvl function? (Freezing level script) (slight correction)

Edward Pollock edwardp at ualberta.ca
Mon Feb 24 13:37:07 EST 2014


Hi all,

There have been a few enquiries recently about plotting freezing levels.

For data on sigma levels with sigma level height given, one can adapt Bob
Hart's script, isen.gs, to do this. (See the script library on the grads
website.)

That script can also be adapted to plot any variable on any surface, such
as height on potential vorticity, height on potential temperature, wind on
potential temperature, or wind on potential vorticity etc.

(Ideally you should do this calculation in height coordinates with a
polynomial interpolation or Fourier series, but I think a linear
interpolation between sigma levels works well if you have enough sigma
levels in your data file.)

I've added my version of the script below. (It's set up to work with fwrite
and several output files and times at the moment. The gen*ctl files are
generic non-dimensional files (no pdef entry) which are needed for fwrite
purposes. Feel free to modify the script as you please.)

Cheers,

Ted Pollock

**********************frzlvl.gs*************************

function frzlvl(args)

dom=1
while(dom<=3)

'set gxout fwrite'
'set fwrite FRZ.d'dom'.dat'

tt=1
while(tt<=48)

'open gen.d'dom'.3d.ctl'
'open gen.d'dom'.2d.ctl'

'set t 'tt
'set z 1 23'
'define height=z+ter.2'

'set z 1 23'
'define temp=t'
'set z 2 23'
'define tempp=t(z-1)'
'set z 1 22'
'define tempm=t(z+1)'

'define
tabove=0.5*maskout(maskout(temp,temp-273.15),temp(z-1)-temp(z+1))+0.5*ma
skout(maskout(temp,273.15-tempm),temp(z-1)-temp(z+1))'
'define
tbelow=0.5*maskout(maskout(temp,tempp-273.15),temp(z-1)-temp(z+1))+0.5*m
askout(maskout(temp,273.15-temp),temp(z-1)-temp(z+1))'

'define fabove=tabove*0+height'
'define fbelow=tbelow*0+height'

'set z 1'

'define fabove=max(maskout(fabove,temp(z+0)-temp(z+1)),z=1,z=23)'
'define fbelow=max(maskout(fbelow,temp(z+0)-temp(z+1)),z=1,z=23)'
'define tabove=max(maskout(tabove,temp(z+0)-temp(z+1)),z=1,z=23)'
'define tbelow=max(maskout(tbelow,temp(z+0)-temp(z+1)),z=1,z=23)'

'define slope=(fabove-fbelow)/(tabove-tbelow)'
'define b=fbelow-slope*tbelow'
'define interp=slope*273.15+b'

'd
const(maskout(interp,interp),0,-u)+const(const(interp,0),1,-u)*(ter.2+((t-273
.15)/0.0075))'
'd ter.2'


'close 2'
'close 1'

tt=tt+1
endwhile

'disable fwrite'

dom=dom+1
endwhile

'quit'

return
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140224/3ce934bf/attachment.html 


More information about the gradsusr mailing list