Reading Group of files

hersala hersala at GMAIL.COM
Wed Feb 24 09:23:45 EST 2010


Hi MMME:

As far as I know, it is possible to open several files (at least .nc files)
using Templates. Please see
http://www.iges.org/grads/gadoc/gadocindex.htmlfor details.
In my case I used two files to do that, one control file and a txt file with
some command lines. I have attached both files, perhaps it serves you as
example.
Cheers,

Hernán Sala
DCT-IAA


2010/2/23 MMME <mhsanabary9 at yahoo.com>

> Hi
>    I have group of files and I want to read all of them by one script. Is
> it possible?
>
> I have:
>
> i=1
> while (i < 9) 'sdfopen BlueNILEB-6i-ECMWF.nc'
> 'set prnopts %10.8
> 'set lat
> 'set lon
> 'set t 1
>
>
> 'd
> ascii = result
> asciifile = 'precipitation.asc'
> numbers = sublin(result,2)
> if (numbers != '')
> rc = write (asciifile,numbers)
> else
> say 'no ascii data to write'
> return
> endif
> * write out remaining ascii data
> i=3
> while(1)
> numbers = sublin(result,i)
> if (numbers != '')
> rc = write (asciifile,numbers,append)
> else
> break
> endif
> i = i+1
> endwhile
> rc = close(asciifile)
> say 'return code from close is:'rc'set gxout print'e1
> 1'7.5'35'1461'(cp+lsp+sf)*1000/60/60/6''set gxout contour'
> 'd cp'i = i + 1
> endwhile
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100224/3cd03aa9/attachment.html 
-------------- next part --------------
reinit

*This file allow to open simultaneously all the following files: from air.sig995.1975.nc to air.sig995.2005.nc
*It works associated with the control file daily.ctl
*In the way they have been written, both must be placed in the same directory with the data files.
*Then it creates a temporal series using aave function.
*It works properly in gradsNC-v1.8 and newer versions

xdfopen daily.ctl

*The content of daily.ctl file is:
*dset air.sig995.%y4.nc 
*options template
*tdef time 11323 linear 1jan1975 1dy

set lat 0
set lon 0

*Establish marker size
*set digsiz 0.02

*Sets color and line thickness
*set annot 1 1

*set the style of the marker for line plots
*set cmark 0


*%y4 replace the part of the name file which has 4 digit year


*This number should be set in function of the t units which are desired to analyse.
*In this case t unit is day. So, 11323 days beginning in 01ene1975 will be shown.
*this means 31dec2005

set t 1 11323

tt= aave(air, lon=275, lon=295, lat=-73, lat=-68) - 273.15

d tt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: daily.ctl
Type: application/octet-stream
Size: 145 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20100224/3cd03aa9/attachment.obj 


More information about the gradsusr mailing list