[gradsusr] Sprintf to write binary to ascii

Zablone Owiti zablonowiti at yahoo.com
Sun Feb 6 02:14:28 EST 2011


Hi Zilore, 
I know fprintf (and NOT Sprintf) used to write out binary data to ascii format. Depending on your requirement, you can use it to write out the whole data (lets say gridded binary data) and also write out the corresponding latitudes and longitudes on separate files. This procedure is demonstrated in the following link:http://cookbooks.opengrads.org/index.php?title=Recipe-002:_Saving_GrADS_variable_data_to_a_text_file

You can also use it to write out data averaged over a particular domain or grid box as in the example of a .CTL file below:

'sdfopen H:/griddata/data.cdf'
'set lon 10'
'set lat 15'
'set t 1 516'
'define pc2sst = aave(sst,lon=-165,lon=-80,lat=-5,lat=5)'
'set t 1 516'
'fprintf rain raingcpc.txt %g 12 1'

NB: In the last line, rain is the variable, raingcpc.txt is the outputfilename, 12 is the number of values in each line (i.e monthly data in this case so that each line is Jan to Dec for each year), and 1 is the number of spaces between the values in each row/ line.

Hope this will help

 
===================================================
ZABLONE OWITI
GRADUATE STUDENT
Nanjing University of Information, Science and Technology
College of International Education
Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China
Tel: +86-25-58731402
Fax: +86-25-58731456
Mob. 15077895632
Website: www.nuist.edu.cn
====================================================
"The real art of conversation is not only to say the right thing at the right time, but also to leave unsaid the wrong thing at the tempting moment."
 



From: Zilore Mumba <zmumba at gmail.com>
To: gradsusr at gradsusr.org
Cc: 
Sent: Saturday, 5 February 2011 7:31 PM
Subject: [gradsusr] Sprintf to write binary to ascii

Hello Grads users,
I tohught there was a command like "sprintf" to write binary data in
grads to ascii.
Help will be appreciated
Zilore
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110205/6640dc2c/attachment-0003.html 


More information about the gradsusr mailing list