[gradsusr] zinterp.gs
Andrew Revering
andy at f5data.com
Tue Apr 26 08:42:21 EDT 2011
I'm confused about zinterp and pinterp. What I want to do is return a height
given variable pressure levels.
So I have LCL pressures for all the grid points, but I want to translate
that into a height AGL. My understanding is that you need to have one static
layer (IE all 850mb) to return heights from a pressure level given zinterp.
Is that correct.is there another way to do it?
I came up with this function but I'm getting errors. I'm sure I don't have
to reinvent the wheel:
function getheight(Pressure)
*FIND THE NEAREST PRESSURE LEVEL ABOVE
'define apres = Pressure'
while (math_fmod(apres,25) != 0)
'apres = apres - 1'
endwhile
*FIND THE NEAREST PRESSURE LEVEL BELOW
'bpres = apres + 25'
'Set LEV bpres'
"define l2="HGTprs
'Set LEV apres'
"define l1="HGTprs
'Percent = (Pressure - apres) / 25'
'Distance = l1 - l2'
if (Distance < 0) ; 'Distance = 0' ; endif
"define height ="nint(l1 - (Distance * Percent))
return (height)
From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org]
On Behalf Of Arlindo da Silva
Sent: Monday, April 25, 2011 8:14 PM
To: GrADS Users Forum
Subject: Re: [gradsusr] zinterp.gs
On Fri, Apr 22, 2011 at 1:43 PM, Jeffrey Duda <jdduda at iastate.edu> wrote:
Meredith,
I know the way Grads scripting works can be confusing with the quoting of
commands and calling of functions. That's all you're doing wrong. I've
attached an edited version of your zinterp.gs file to show you how to do it.
Notice that I only changed the top few lines. To work this, you need to run
the zinterp.gs script. Your test3.gs script would work but you need to
remove the call from any quotes and you need the actual code that makes up
the function to be located within the script file. Unfortunately Grads
doesn't know that your function is sitting in some other .gs file, even if
it is in the same directory.
If you are using an opengrads build, another possibility is to implement
zinterp.gs as a GS udf as explained here:
http://opengrads.org/doc/udxt/gsudf/
Better yet, the opengrads bundle comes with zinterp() implemented as an
extension:
zinterp(FIELD,ZGRID,ZLEV,[-l|-s|-p])
<http://opengrads.org/doc/udxt/libbjt/libbjt.html#zinterp_field_zgrid_zlev__
l_s_p__>
so just use it.
Arlindo
--
Arlindo da Silva
dasilva at alum.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110426/e2907008/attachment.html
More information about the gradsusr
mailing list