[gradsusr] lats4d and used defined variable

Becker, Bernd bernd.becker at metoffice.gov.uk
Fri Mar 4 06:24:26 EST 2011


Arlindo,
 
great, thanks!
 
Would it not be more intuitive to extend the scope of lats4d to accept
all currently user defined variables to be writen out, similar to
fwrite?
 
User defined variables may be plotted or written out via fwrite
according to 
current dimension settings. 
 
The long way home seems to be to write out with fwrite first, build a
ctl file
and then translate the binary file to grib with lats4d. 
 
Thanks for your help,
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



 

________________________________

From: gradsusr-bounces at gradsusr.org
[mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Arlindo da Silva
Sent: 04 March 2011 00:33
To: GrADS Users Forum
Subject: Re: [gradsusr] lats4d and used defined variable


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_Bundl
e

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
<mailto:E-mail%3Abernd.becker at metoffice.gov.uk>  -
	
http://www.metoffice.gov.uk/research/our-scientists/seasonal-to-decadal/
	bernd-becker
<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/20110304/b7b803fd/attachment-0001.html 


More information about the gradsusr mailing list