Binary to Ascii conversion

Kristian Horvath horvath at CIRUS.DHZ.HR
Fri Feb 23 05:05:22 EST 2007


Hello,

I also benefited from the discussion and tried the following script,
which resulted in a peculiar result:
'reinit'
'sdfopen /doma/horvath/uwnd.sig995.1961.nc'
'set t 1'
'set lon 15 25'
'set lat 38 48'
'set gxout print'
'set prnopts %10.3e 5 1'
'd uwnd'
rc=write(ascii.txt,result)
rc=close(ascii.txt)
'quit'
return

The script works and the result is:

Printing Grid -- 30 Values -- Undef = 32766
  3.100e+00  1.900e+00  1.400e+00  1.300e+00 -1.200e+00
  1.400e+00  1.100e+00  2.000e-01 -6.000e-01 -2.100e+00
  2.000e-01 -2.000e-01 -7.000e-01 -5.000e-01 -8.000e-01
-1.900e+00 -2.100e+00 -2.500e+00 -1.800e+00 -8.000e-01
  1.600e+00  1.400e+00 -1.000e-01 -8.000e-01  1.987e-06
  5.700e+00  3.900e+00  1.700e+00  6.000e-01  7.000e-01

Now if I modify the script:
'set lon 15 25'
'set lat 38'    ; result is
Printing Grid -- 5 Values -- Undef = 32766
  3.100e+00  1.900e+00  1.400e+00  1.300e+00 -1.200e+00  ; which is ok.

and the second modification:
'set lon 15 25'
'set lat 48'
Printing Grid -- 5 Values -- Undef = 32766
  1.600e+00  1.400e+00 -1.000e-01 -8.000e-01  1.987e-06  ; which is
not in accordance with the "area" example

What is the reason for the above discrepancy?

Thanks and regards,
Kristian

At 23:05 22.2.2007, you wrote:
>If you don't need the data in binary (which is what you have in file
>yiki.dat), you can skip the "gxout fwrite" lines and use "gxout print"
>instead.  Eg, in a grads script:
>
>'set gxout print'
>'set t 613 697'
>'display tloop(mean(soilw,lon=95.5,lon=112.5,lat=31.5,lat=42.5))'
>rc=write(yiki.txt,result)
>say 'return code from write is: 'rc
>rc=close(yiki.txt)
>say 'return code from close is: 'rc
>
>In the above, the output from the display command gets stored in
>variable "result" and you write the contents of "result" to ascii file
>yiki.txt.
>
>See the doc for 'set prnopts' at
>http://grads.iges.org/grads/gadoc/gradcomdsetprnopts.html
>if you want to change the format of the text output.
>
>    Diane
>
>
>Yitbarek Kifle wrote:
>>Dear all,
>>
>>As a new and inexperienced user of Grads,i have come with a problem of
>>converting the Grads time series binary output to Ascii format.I have read
>>almost all such problems on the users group list but that doesn't seem to
>>help me. Here is the discription of what i did,
>>
>>'set gxout fwrite'
>>'set fwrite yiki.dat'
>>set t 613 697
>>d tloop(mean(soilw,lon=95.5,lon=112.5,lat=31.5,lat=42.5))
>>disable fwrite
>>
>>i have the file Yiki.dat.
>>
>>Would somebody please tell me what to do next in step by step basis,as I do
>>not have a programming skill?
>>
>>thanks in advance.
>
>
>________ Information from NOD32 ________
>This message was checked by NOD32 Antivirus System for Linux Mail Server.
>http://www.nod32.com
>
>__________ NOD32 2072 (20070220) Information __________
>
>This message was checked by NOD32 antivirus system.
>http://www.eset.com
>

_________________________________
Kristian Horvath                                email: horvath at cirus.dhz.hr
Graduate Research Associate                     tel:+385-1-4565752
Meteorological and Hydrological Service         www:
http://www.dhmz.htnet.hr/index.php
Gric 3, 10000 Zagreb, Croatia                   personal www:
http://radar.dhz.hr/~horvath



More information about the gradsusr mailing list