[gradsusr] saving more than one variable in one file

James T. Potemra jimp at hawaii.edu
Wed Sep 26 14:59:39 EDT 2012


Mubashar:

I'm not exactly sure what the issue is with your script, but
I can say that GrADS can indeed handle writing multiple
variables with fwrite.  As an example, below is your script
substituting the "open" statement with an "sdfopen" (so
you should be able to run it without having the data),
everything else except the variable name (rain1 instead of
temp) is the same:

'sdfopen 
http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Rain-CMAP/monthly'
'set gxout fwrite'
'set fwrite NEW_FILE.dat'
t=1
tmax=60
while (t<=tmax)
'set t 't
'define N3=aave(rain1,lon=-150,lon=-90,lat=-5,lat=5)'
'define N4=aave(rain1,lon=160,lon=210,lat=-5,lat=5)'
'd N3'
'd N4'
t=t+1
endwhile
'disable fwrite'

After running this, and then using your exact same ctl
file, I was able to make a reasonable-looking plot:

'open NEW_FILE'
'set t 1 60'
'd n3'
'd n4'
'printim example1.png white'

Does the variable "temp" in your input file have vertical
dimension?  If so, since you are not explicitly setting a
z-level that might be the problem.

Jim

On 9/26/12 8:16 AM, Mubashar Dogar wrote:
> Hi Ricardo,
>
> It seems that GrADS can not handle two or more variables written using
> fwrite. If I just write only one variable and open it, every thing is
> fine. Also If I directly display both the variables, their plot is
> also fine. It's either a problem with fwrite for more than one
> variables or GrADS is not efficient enough to open more than one
> variables written using fwrite command.
>
> Thanks,
>
> Mubashar
> On 9/26/12, Ricardo Hallak <hallak at model.iag.usp.br> wrote:
>> Hi Mubashar,
>>
>> when you display in the GrADS prompt (without saving it using fwrite):
>>
>> 'set x 1'
>> 'set y 1'
>> 'set t 1 60'
>> 'd aave(temp,lon=-150,lon=-90,lat=-5,lat=5)'
>>
>> your result seems ok?
>> Is it different from that that you display after using fwrite?
>>
>> Ricardo
>>
>> On Wed, 26 Sep 2012 10:57:54 +0300, Mubashar Dogar wrote
>>> Hi  Sujata,
>>>
>>> It's not the issue of tdef. It doesn't make any difference.
>>>
>>> Thanks,
>>> Mubashar
>>>
>>> On 9/26/12, Sujata Mandke <amin at tropmet.res.in> wrote:
>>>> Hello!
>>>>
>>>>     If you want to write time series of both the variables
>>>>     of 60 times each, then in the ctl file to open
>>>>     newly created data, make following changes:
>>>>
>>>>> tdef 103 linear jan1900 1yr
>>>>    change to
>>>>    tdef 60 linear jan1900 1yr
>>>>
>>>>    With this change both variables are defined
>>>>    for time series of 60 times each.
>>>>    Hope this will match newly created variable with
>>>>    that from original data.
>>>> Regards
>>>> Sujata Mandke
>>>> Indian Institute of Tropical Meteorology
>>>> Pune,India.
>>>> -------------------------
>>>>
>>>> ----- Original Message -----
>>>> From: Jennifer Adams <jma at cola.iges.org>
>>>> To: GrADS Users Forum <gradsusr at gradsusr.org>
>>>> Sent: Tue, 25 Sep 2012 20:54:49 +0530 (IST)
>>>> Subject: Re: [gradsusr] saving more than one variable in one file
>>>>
>>>> Use the -ap flag with 'set fwrite' to append to an existing file. Also,
>>>> it
>>>> is not necessary to define N3 and N4 before displaying them -- why waste
>>>> the
>>>> memory? Simply change your 'define' to a 'd' and then you can remove the
>>>> two
>>>> 'd N3' and 'd N4' lines.
>>>> --Jennifer
>>>>
>>>>
>>>> On Sep 25, 2012, at 5:20 AM, Mubashar Dogar wrote:
>>>>
>>>>> Dear GrADS users,
>>>>>
>>>>> I have 2 spatial variables in one file. I wanted to do some operation
>>>>> on each one and wanted to save 2 new variables in a new GrADS file. I
>>>>> am doing some thing as given below:
>>>>>
>>>>> 'open File.ctl'
>>>>> 'set gxout fwrite'
>>>>> 'set fwrite NEW_FILE.dat'
>>>>> t=1                       ********************T=1 is Jan1900 and it is
>>>>> monthly data
>>>>> tmax=60
>>>>> while (t<=tmax)
>>>>> 'set t 't
>>>>> 'define N3=aave(temp,lon=-150,lon=-90,lat=-5,lat=5)'
>>>>> 'define N4=aave(temp,lon=160,lon=210,lat=-5,lat=5)'
>>>>> 'd N3'
>>>>> 'd N4'
>>>>> t=t+1
>>>>> endwhile
>>>>> 'disable fwrite'
>>>>> ********************************
>>>>> As the new variables are a 1-D time series, so my ctl file to open
>>>>> newly written data file is as:
>>>>>
>>>>> dset NEW_FILE.dat
>>>>> title N3 and N4 indices
>>>>> undef -9.99e+08
>>>>> xdef 1 linear 1 1
>>>>> ydef 1 linear 1 1
>>>>> zdef 1 linear 1 1
>>>>> tdef 103 linear jan1900 1yr
>>>>> vars 2
>>>>> N3   0 99  N3 variable
>>>>> N4   0 99  N4 variable
>>>>> endvars
>>>>>
>>>>> It works fine but it looks that the values of both variables are not
>>>>> representing to original values. How can I work with two or more
>>>>> variables in one file?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Mubashar
>>>>> _______________________________________________
>>>>> gradsusr mailing list
>>>>> gradsusr at gradsusr.org
>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>> --
>>>> Jennifer M. Adams
>>>> IGES/COLA
>>>> 4041 Powder Mill Road, Suite 302
>>>> Calverton, MD 20705
>>>> jma at cola.iges.org
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> gradsusr mailing list
>>>> gradsusr at gradsusr.org
>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>
>>> --
>>> Muhammad Mubashar Ahmad Dogar
>>> Scientific Officer (Climatology Section),
>>> Global Change Impact Studies Centre (GCISC),
>>> NCP complex, Quaid-e-Azam University Campus,
>>> Shahdra road, Islamabad, Pakistan.
>>> Tel:  +92519230226
>>> Mob:+923315144169
>>> email: mubashardogar at yahoo.com
>>>            mubashar.ahmad at gcisc.org.pk
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>> Ricardo Hallak
>>
>> Departamento de Ciências Atmosféricas (ACA)
>> Instituto de Astronomia, Geofísica e Ciências Atmosféricas (IAG)
>> Universidade de São Paulo (USP)
>> Rua do Matão, 1226 - Cidade Universitária - São Paulo SP 05508-900
>> Phone.: +55 (11) 3091-2850; 3091-4703
>> Fax: +55 (11) 3091-4714
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: example1.png
Type: image/png
Size: 9320 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20120926/20e38fb6/attachment-0003.png 


More information about the gradsusr mailing list