how to write a ASCII file by GrADS

Matthias Fripp matthias.fripp at ECI.OX.AC.UK
Fri Nov 6 10:25:17 EST 2009


You can do this using techniques that have been shown on this list  
recently, and a little creativity. All you really need are a couple of  
loops and a "write()" command. I have attached a script that does  
this. This script writes data for each longitude in one column of the  
output file, and each latitude in one row. The longitude or latitude  
is shown at the start of each column or row (respectively). All values  
are separated with single spaces.

If you want latitudes in columns and longitudes in rows (as shown in  
your example file), you will need to change x, y, lat and lon where  
needed in the script. If you want more spaces or other characters  
between the values, you can also revise the script to do that.

Matthias



On Nov 6, 2009, at 1:45 PM, hossein lotfi wrote:

>
>
> On Fri, Nov 6, 2009 at 7:10 AM, hersala <hersala at gmail.com> wrote:
> Hi Hao:
> I have solved this difficulty using this grads script that is  
> already posted in:
>
> http://cookbooks.opengrads.org/index.php?title=Recipe-002:_Saving_GrADS_variable_data_to_a_text_file
>
> It works really fine.
> Best regards
> Hernán
>
>
>
>
> 2009/11/5 Hao He <hhe at atmos.umd.edu>
>
> Hi,
>   I used GrADS to read the GRIB file and wanted to selected some
> variables, which can be write to an ASCII (.txt or .dat) file. I  
> read the
> manual and found I should use 'gxout fwrite'. But I still could not
> figure out how to write the script. Does anyone have an idea?
>
> Thanks!
>
> Hao
>  hi
> thank you for your help (fprintf.gs)
> but it can not save the latitude and longitude in the output file  
> that save variables
>  such as below matrix;
>             lat    lat    lat    lat    lat
> lon       var    var   var    var   var
> lon        .        .      .      .     .
> lon        .        .      .      .     .
>  can you cahnge the command in the fprintf.gs file to do this?
> thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20091106/2f42d23d/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: write_ascii_data_table.gs
Type: application/octet-stream
Size: 3103 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20091106/2f42d23d/attachment.obj 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20091106/2f42d23d/attachment-0001.html 


More information about the gradsusr mailing list