[gradsusr] zinterp.gs

Jeffrey Duda jdduda at iastate.edu
Fri Apr 22 13:43:44 EDT 2011


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.

Jeff

On Fri, Apr 22, 2011 at 12:23 PM, Meredith Croke <mcroke at airdat.com> wrote:

> Hi Jeff,
>
> I tried this and am still getting the same error, I attached the 2 scripts,
> thought this might be easier so you can see what I’m doing.  I’m not sure if
> this is necessary but in the test script (not in there now) I also tried
> setting lev to zlev and got an error message with that.
>
>
>
> Thanks again for helping me out with this!
>
>
>
> Meredith
>
>
>
> *From:* gradsusr-bounces at gradsusr.org [mailto:
> gradsusr-bounces at gradsusr.org] *On Behalf Of *Jeffrey Duda
> *Sent:* Thursday, April 21, 2011 4:52 PM
>
> *To:* GrADS Users Forum
> *Subject:* Re: [gradsusr] zinterp.gs
>
>
>
> Meredith,
> No problem.  It took me awhile to figure out how to use functions like
> this, too.
>
> If you have the standard script from the website script library (that
> begins like this:)
>
> function zinterp(field,zgrid,zlev)
>
> *----------------------------------------------------------------------
> *
> * Bob Hart (hart at ems.psu.edu) /  PSU Meteorology
> * 3/4/1999
> *
> * GrADS function to interpolate within a 3-D grid to a specified
>
> * height level.  Can also be used on non-pressure level data, such
> * as sigma or eta-coordinate output where height is a function
> * of time and grid level.
>
> then you need to put your call to the function outside of the code that
> contains the function (i.e., either before the first line that says
> "function zinterp(field,zgrid,zlev)" or after the last line
> "Return(interp)".  The code says it will return to you a newly defined
> variable called "interp".  Thus you will then want to display that
> variable.  You can do it any of the ways suggested in the notes.  One way I
> would suggest is:
>
> 'zinterp(temp,height,5000)'
> 'd interp'
>
> See if following that method works.
>
> Jeff
>
> On Thu, Apr 21, 2011 at 3:25 PM, Meredith Croke <mcroke at airdat.com> wrote:
>
> Thanks Jeff,
>
> I should have mentioned, initially I tried running zinterp from a script,
> but once that wasn’t working I was trying to trouble shoot on the command
> line.  I tried your suggestion and put 'zinterp(tmpprs,hgtprs,5000)' as
> the first line in the zinterp.gs script, I then tried running a very short
> script that just opened a ctl file and ‘d zinterp(tmpprs,hgtprs,5000)’
>
> I again get the following error:
>
> Syntax Error:  Invalid Operand
>
>   'zinterp' not a variable or function name
>
>   Error ocurred at column 1
>
> DISPLAY error:  Invalid expression
>
>   Expression = zinterp(tmprs,hgtprs,5000)
>
>
>
> I also tried putting ‘zinterp(tmpprs,hgtprs,5000)’ on the second line of
> zinterp.gs (under function zinterp(field,zgrid,zlev)) and got the same
> error.
>
> Not sure what I’m missing.
>
>
>
> Thanks for the help,
>
> Meredith
>
>
>
>
>
> *From:* gradsusr-bounces at gradsusr.org [mailto:
> gradsusr-bounces at gradsusr.org] *On Behalf Of *Jeffrey Duda
> *Sent:* Thursday, April 21, 2011 3:45 PM
> *To:* GrADS Users Forum
> *Subject:* Re: [gradsusr] zinterp.gs
>
>
>
> Meredith,
> To my knowledge, you can't run a function from the Grads command prompt.
> Instead, you need to put in a call to it inside a script that contains the
> function code.  Thus, just put the line 'zinterp(tmpprs,hgtprs,5000)' as the
> first line of code in the zinterp.gs script file.
>
> Jeff Duda
>
> On Thu, Apr 21, 2011 at 2:02 PM, Meredith Croke <mcroke at airdat.com> wrote:
>
> Hi Grads Users,
>
>
>
> I'm trying to use the zinterp.gs function to determine the 6km wind from
> model data that is output on pressure levels, however I'm running into
> some issues with zinterp.gs.
>
>
>
> To test the function I am attempting to run it from the command line and
> follow the samples in the script, so I have tried
>
> 'd zinterp(tmpprs,hgtprs,5000)', to display a temperature field at 5000,
> however I receive this error:
>
> Syntax Error:  Invalid Operand
>
>  'zinterp' not a variable or function name
>
>  Error ocurred at column 1
>
> DISPLAY error:  Invalid expression
>
>  Expression = zinterp(tmpprs,hgtprs,5000)
>
>
>
> The function is in my directory,  what else do I need to do to get this
> to work?
>
> I am using grads v1.9b4
>
>
>
> Thanks for your help.
>
>
>
> Regards,
>
>
>
> Meredith
>
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
> --
> Jeff Duda
> Iowa State University
> Meteorology Graduate Student
> 3134 Agronomy Hall
> www.meteor.iastate.edu/~jdduda <http://www.meteor.iastate.edu/%7Ejdduda>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
>
>
> --
> Jeff Duda
> Iowa State University
> Meteorology Graduate Student
> 3134 Agronomy Hall
> www.meteor.iastate.edu/~jdduda <http://www.meteor.iastate.edu/%7Ejdduda>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Iowa State University
Meteorology Graduate Student
3134 Agronomy Hall
www.meteor.iastate.edu/~jdduda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110422/b997b60a/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zinterp-1.gs
Type: application/octet-stream
Size: 3859 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20110422/b997b60a/attachment.obj 


More information about the gradsusr mailing list