[gradsusr] lats4d and used defined variable
Arlindo da Silva
dasilva at alum.mit.edu
Thu Mar 3 19:32:41 EST 2011
On Fri, Feb 25, 2011 at 10:00 AM, Becker, Bernd <
bernd.becker at metoffice.gov.uk> wrote:
>
> Dear all,
> I grapple with lats4d and writing a user defined variable
> in grib_format.
>
> How can I achieve the following:
>
> open file.ctl (contains tmax amongst other things)
> define pop=tmax/2.
>
> lats4d -v -q -i file.ctl -vars pop -o ex2a -format grads_grib
>
> the follwing works just fine:
>
> lats4d -v -q -i ex2a.ctl -vars tmax -o ex2a -format grads_grib
>
>
Here is something that should work:
lats4d -v -q -i ex2a.ctl -vars tmax -func @/2 -o ex2a -format grads_grib
where '@' will be replaced with the actual variable name. If you really want
to do something more elaborate it may be better for you to write a gsudf
function to handle each one of your variables. For example,
lats4d -v -q -i ex2a.ctl -vars tmax -func handler(@) -o ex2a -format
grads_grib
Nex you implement the "handler" function in a file called "handler.gsf" that
you contain something like that:
function handler(vname)
'define xxx = ' vname '/2
return xxx
The script "handler.gsf" needs to be registered as a (grads script) gs UDF
in your UDXT as explained here:
http://opengrads.org/doc/udxt/gsudf/
Gs UDF's are very powerful: it allows you to write very complicated
"expression functions" as a simple grads script. For example, these t-storm
related functions were written entirely as gs UDFs:
http://opengrads.org/doc/udxt/saakeskus/
You will need an opengrads build for using this this feature; use
v2.0.a9.oga.1 if you can, although it should work in v1.x as well.
http://opengrads.org/wiki/index.php?title=Installing_the_OpenGrADS_Bundle
Good Luck,
Arlindo
> This runs in a 1.9 built.
>
> In the real case, pop is a lot more complicated than tmax/2.
>
> Thanks for your suggestions!
> Have a nice weekend.
> Bernd.
>
> --
> Bernd Becker Climate Impacts Product Development
> Met Office Hadley Centre FitzRoy Road Exeter Devon EX1 3PB United
> Kingdom
> Tel.: +44 (0) 1392 884511 Fax: +44 (0)870 900 5050
> E-mail:bernd.becker at metoffice.gov.uk -
> http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/
> bernd-becker
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
--
Arlindo da Silva
dasilva at alum.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110303/b792a0db/attachment-0003.html
More information about the gradsusr
mailing list