Extracting and writing data in ascii file

krishnamohan krishmet at GMAIL.COM
Sat Jan 9 10:26:29 EST 2010


Hi Sablone,
         You can use subwrd function for that. Suppose you want to have data
form 2000 to 2009, you can do it as given below. Put a variable yyyy for
year such that you can use while loop for time step. This script will write
output in the ascii file output.txt as given in the 10th line. The gs file
is attached


************************************************
'reinit'
'sdfopen filename.nc'
'set lon 90'
'set lat 15'
yyyy=2000
while(yyyy<=2009)
'set time jan'yyyy''
'd aave(precip,lon=39,lon=41,lat=-5,lat=0)'
te=subwrd(result,4)
w=write(output.txt,te)
yyyy=yyyy+1
endwhile

***********************************************

Best wishes.........
-- 
Krishnamohan.K.S
Junior Research Fellow
Department Of Atmospheric Sciences
Cochin University of Science and Technology
Cochin,India

On Sat, Jan 9, 2010 at 9:57 AM, Zablone Owiti <zowiti at ncst.go.ke> wrote:

> Hi Grad Users,
>
> I wish to extract data from gridded netcdf file for a particular domain to
> get a time series (i.e of a particular month or season for a number of
> years) and write it in ascii file so that I can export the series to say
> excell.
>
> I can do this, but through the long way of using the commands for example:
>
> 'set t 1 30'
> 'd aave(precip,lon=39,lon=41,lat=-5,lat=0)
>
> Through this I am unable to only get the targeted months or season of the
> years. Furthermore I have to mannualy copy the data from Grads and paste
> in excell the rearrange the data to pick the months or seasons I target.
>
> My question is: How can I extract the data for the targeted months and
> directly  write them ascii file.
>
> Thanks
> --
> 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
> Website: www.globenuist.cn
> _________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100109/5b0c2e0d/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aave.gs
Type: application/octet-stream
Size: 213 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20100109/5b0c2e0d/attachment.obj 


More information about the gradsusr mailing list