On Fri, Feb 25, 2011 at 10:00 AM, Becker, Bernd <span dir="ltr">&lt;<a href="mailto:bernd.becker@metoffice.gov.uk">bernd.becker@metoffice.gov.uk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Dear all,<br>
I grapple with lats4d and writing a user defined variable<br>
in grib_format.<br>
<br>
How can I achieve the following:<br>
<br>
open file.ctl  (contains tmax amongst other things)<br>
define pop=tmax/2.<br>
<br>
lats4d -v -q -i  file.ctl -vars pop  -o ex2a -format grads_grib<br>
<br>
the follwing works just fine:<br>
<br>
lats4d -v -q -i  ex2a.ctl -vars tmax  -o ex2a -format grads_grib<br>
<br></blockquote><div><br></div><div><br></div><div>Here is something that should work:</div><div><br></div><div>lats4d -v -q -i  ex2a.ctl -vars tmax  -func @/2 -o ex2a -format grads_grib</div><div><br></div><div>where &#39;@&#39; 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,</div>
<div><br></div><div>lats4d -v -q -i  ex2a.ctl -vars tmax  -func handler(@)  -o ex2a -format grads_grib</div><div><br></div><div>Nex you implement the &quot;handler&quot; function in a file called &quot;handler.gsf&quot; that you contain something like that:</div>
<div><br></div><div>function handler(vname)</div><div>&#39;define xxx = &#39; vname &#39;/2</div><div>return xxx</div><div><br></div><div>The script &quot;handler.gsf&quot; needs to be registered as a (grads script) gs UDF in your UDXT as explained here:</div>
<div><br></div><div>     <a href="http://opengrads.org/doc/udxt/gsudf/">http://opengrads.org/doc/udxt/gsudf/</a></div><div><br></div><div>Gs UDF&#39;s are very powerful: it allows you to write very complicated &quot;expression functions&quot; as a simple grads script. For example, these t-storm related functions were written entirely as gs UDFs:</div>
<div><br></div><div>     <a href="http://opengrads.org/doc/udxt/saakeskus/">http://opengrads.org/doc/udxt/saakeskus/</a></div><div><br></div><div>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.</div>
<div><br></div><div>     <a href="http://opengrads.org/wiki/index.php?title=Installing_the_OpenGrADS_Bundle">http://opengrads.org/wiki/index.php?title=Installing_the_OpenGrADS_Bundle</a></div><div><br></div><div>Good Luck,</div>
<div><br></div><div>     Arlindo</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This runs in a 1.9 built.<br>
<br>
In the real case, pop is a lot more complicated than tmax/2.<br>
<br>
Thanks for your suggestions!<br>
Have a nice weekend.<br>
Bernd.<br>
<br>
--<br>
Bernd Becker   Climate Impacts Product Development<br>
Met Office Hadley Centre    FitzRoy Road  Exeter   Devon EX1 3PB  United<br>
Kingdom<br>
Tel.: +44 (0) 1392 884511 Fax: +44 (0)870 900 5050<br>
<a href="mailto:E-mail%3Abernd.becker@metoffice.gov.uk">E-mail:bernd.becker@metoffice.gov.uk</a> -<br>
<a href="http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/
bernd-becker" target="_blank">http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/<br>
bernd-becker</a><br>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a><br>