Semyon.<br><br> There is a bug bug in LATS that causes it crash when used more than oce in a GrADS session. Starts a fresh grads session and do this:<br><br>
ga-> open ../sst/sst_month<br>ga-> set x 1 360<br>ga-> sst1 = sst - 273<br>ga-> lats4d -o qq -func sst1 -time nov1981 dec2007 -vars sst<br><br>Now, if your modification of the sst field can expressed as a simple expression you could have said (this time from the command line for simplicity):<br>
<br>% lats4d.sh -nc -i ./sst/sst_month -o new_sst -func '@-273' -v<br><br>and the new file "<a href="http://new_sst.nc">new_sst.nc</a>" will be written for all times and variables in the input file (since it only had sst I didn't bother specifying -vars).<br>
<br>Now, suppose your modification of SST is something complicated that cannot easily be done with a single line. In the case you can write a GrADS expression function by means of a script function. I know, we've always been taught that these kinds of functions do not mix. However, the GsUDF extension does just that:<br>
<br> <a href="http://opengrads.org/doc/udxt/gsudf/">http://opengrads.org/doc/udxt/gsudf/</a><br><br>OK, now you create a file "sstfunc.gsf" where you implement this function:<br><br>function sstfunc(sst)<br>
'define sst1 = sst - 273'<br> return 'sst1'<br><br>In this function you simply define a variable and then return its name. Next you will need to modify lats4d/gs to initialize the GsUDF package (I'll fix this in future versions): just add the line<br>
<br>'gsudf init'<br><br>in the beginning of the <a href="http://lats4d.gs">lats4d.gs</a> script. Now, you enter at the command line:<br><br>% lats4d.sh -nc -i ./sst/sst_month -o new_sst -func 'sstfunc(@)' -v<br>
<br>The '@' is replaced with the name of each variable on file. For this to work you need to install the newest version of the OpenGrADS extensions just released.<br><br> Good luck and please let's keep this discussion on gradsusr.<br>
<br> Arlindo<br><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Semyon Grodsky</b> <<a href="mailto:senya@atmos.umd.edu">senya@atmos.umd.edu</a>><br>
Date: Fri, Apr 4, 2008 at 8:21 AM<br>Subject: Re: lats4d for defined variable<br>To: Arlindo da Silva <<a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a>><br><br><br>Arlindo,<br>
what I try to do is to save results of a script in a file that will be used by other project participants. We decided to output into *.nc to achieve portability into applications other than GRADS.<br>
<br>
I tried what you suggested by doing a simple exersise.<br>
<br>
**********************************************************<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
gradsnc<br>
</blockquote>
<br>
Grid Analysis and Display System (GrADS) Version 1.9b4<br>
Copyright (c) 1988-2005 by Brian Doty and IGES<br>
Center for Ocean-Land-Atmosphere Studies (COLA)<br>
Institute for Global Environment and Society (IGES)<br>
GrADS comes with ABSOLUTELY NO WARRANTY<br>
See file COPYRIGHT for more information<br>
<br>
Config: v1.9b4 32-bit little-endian readline sdf/xdf netcdf lats printim<br>
<br>
Issue 'q config' command for more information.<br>
<br>
Landscape mode? (no for portrait): n<br>
GX Package Initialization: Size = 8.5 11<br>
***************************************************<br>
ga-> open ../sst/sst_month<br>
Scanning description file: ../sst/sst_month<br>
Data file ../sst/sst_month_v2_%y4.dat is open as file 1<br>
LON set to 0 360<br>
LAT set to -89.5 89.5<br>
LEV set to 0 0<br>
Time values set: 1981:11:1:0 1981:11:1:0<br>
*******************************************************<br>
<br>
ga-> set t 1 last<br>
Time values set: 1981:11:1:0 2007:12:1:0<br>
<br>
*****now I define sst1<br>
ga-> sst1=sst<br>
Define memory allocation size = 81840960 bytes<br>
<br>
ga-> q file<br>
File 1 : OI_sst_V2 Reynolds&Smith<br>
Descriptor: ../sst/sst_month.ctl<br>
Binary: ../sst/sst_month_v2_%y4.dat<br>
Type = Gridded<br>
Xsize = 360 Ysize = 180 Zsize = 1 Tsize = 314<br>
Number of Variables = 1<br>
sst 0 99 surface temperature<br>
ga-> set x 1 360<br>
LON set to 0.5 359.5<br>
ga-> set y 1 180<br>
LAT set to -89.5 89.5<br>
<br>
********Now I try what (I believe) you suggested<br>
********************************************************<br>
ga-> lats4d -o qq -func sst1 -time nov1981 dec2007 -vars ps<br>
ylats4d: All invalid sfc/upper variables: ps<br>
lats4d: error creating coards file <a href="http://qq.nc" target="_blank">qq.nc</a><br>
<RC> n1 </RC><br>
</IPC><br>
n1<br>
<br>
*******if variable <ps> is replaced by defined name sst1, grads crashes<br>
***********************************************************<br>
ga-> lats4d -o qq -func sst1 -time nov1981 dec2007 -vars sst1<br>
Segmentation fault<br>
<br>
****************************************************************<br>
lats4d -h<br>
<br>
NAME<br>
<br>
lats4d - LATS for Dummies (Version 1.9.4 of 28 Nov 2007)<br>
***************************************************************<br>
<br>
I am sorry in advance for taking your time. I would really appreciate any help.<br>
Regards,<br>
--Senya<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Thu, 3 Apr 2008, Arlindo da Silva wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Thu, Apr 3, 2008 at 3:26 PM, Semyon Grodsky <<a href="mailto:senya@atmos.umd.edu" target="_blank">senya@atmos.umd.edu</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Folks,<br>
I am a beginner with lats4d.<br>
<br>
I would like to output a defined variable (that is a result of<br>
calculations) into a netcdf. Is it possible with lats4d?<br>
<br>
</blockquote>
<br>
<br>
Yes, you should be able to do it. Here is an example:<br>
<br>
% gradsnc -l<br>
ga-> open model.ctl<br>
ga-> set x 1 72<br>
ga-> speed = sqrt(ua*ua+va*va)<br>
ga-> lats4d -o myfile -func speed -time 0z1jan1987 -vars ps<br>
ga-> quit<br>
<br>
and it will create a netcdf file named "<a href="http://myfile.nc" target="_blank">myfile.nc</a>" with a variable called<br>
"ps" but actually containing the defined variable "speed". There are other<br>
tricks you can play to have the variable name come right, but I'll stop here<br>
since I don't know what you are trying to do exactly.<br>
<br>
Arlindo<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Arlindo da Silva<br>
<a href="mailto:dasilva@alum.mit.edu" target="_blank">dasilva@alum.mit.edu</a><br>
<br>
</blockquote>
<br></div></div><div><div></div><div class="Wj3C7c">
-----------------------------------------------------------<br>
Semyon Grodsky<br>
Computer and Space Science Building (Bldg. #224), Room 2409<br>
Department of Atmospheric and Oceanic Science<br>
University of Maryland<br>
College Park, MD 20742<br>
<br>
Phone: 301-405-5330<br>
Fax: 301-314-9482<br>
E-mail: <a href="mailto:senya@atmos.umd.edu" target="_blank">senya@atmos.umd.edu</a><br>
</div></div></div><br><br clear="all"><br>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a>