[gradsusr] script to several files

Martin V. Mathew vmartinmathew at gmail.com
Sun Mar 3 00:47:27 EST 2013


Hi

I am not sure whether this delayed replay is of any to help to you.

I made some modifications to your script to enable it to plot data using 30
input file. Here I am making following assumptions

1) The input file names are media2_01.ctl, media2_02.ctl, media2_03.ctl,
....,media2_30.ctl
2) Output figure names are ' /data/climat_6190_2/Lluvia6190_01.gmf',......,'
/data/climat_6190_2/Lluvia6190_30.gmf'
3) Variable names are the same in all files
If  this assumptions are not right, you have to use compound variables to
get the job done.

The modified script is as follows
*
*
'reinit'

infile1a='/data/climat_6190_2/media2_'
infile1b='0'
infile1c='.ctl'

opfile1a='/data/climat_6190_2/Lluvia6190_'
opfile1b='0'
opfile1c='.gmf'
opfile1d='.gif'

MaxFig=30;

figs=1
while(figs<=MaxFig) ;*This loop will run until maximum no of figures is
reached.

* Generating i/p file name
if figs<10
InFileCnt=infile1b%figs
opFileCnt=opfile1b%figs

else ;* if figs<10
InFileCnt=figs
opFileCnt=figs
endif ;* if figs<10

infile=infile1a%InFileCnt% infile1c

* Generating o/p figure name
 figname=opfile1a%opFileCnt%opfile1c
 outfig=opfile1a%opFileCnt%opfile1d ;* % is used to concatenate strings

'open 'infile

'set display color white'
'c'
'enable print 'figname

'set gxout shaded'
'set mpdset hires'
'set lat 7.5 11.5'
'set lon -86.5 -82.5'
'set cmin 1'
'd prec*1000*4'
'draw title Precipitaci`6p`0n media diaria 1961-1990 enero'
'run /opt/grads30d/scripts/cbarn.gs'
'print'
'disable print'
'close 1'

'!/opt/grads30d/scripts/gxgif -r -i 'figname' -o 'outfig
'!rm -f 'figname

figs=figs+1 ;*Figure increment for the next figure
endwhile;*while(figs<=MaxFig)

'q pos'
'quit'

Hope this will help you. Contact me if you need any help in using compound
variable in this script

Regards

Martin

On 5 February 2013 23:03, Estefanía Jiménez <estefaniajimenez.r at gmail.com>wrote:

> this the script for only one file
> *
> *
> *'reinit'*
> *'open /data/climat_6190_2/media2_01.ctl'*
> *'set display color white'*
> *'c'*
> *'enable print /data/climat_6190_2/Lluvia6190_01.gmf'*
> *'set gxout shaded'*
> *'set mpdset hires'*
> *'set lat 7.5 11.5'*
> *'set lon -86.5 -82.5'*
> *'set cmin 1'*
> *'d prec*1000*4'*
> *'draw title Precipitaci`6p`0n media diaria 1961-1990 enero'*
> *'run /opt/grads30d/scripts/cbarn.gs'*
> *'print'*
> *'disable print'*
> *'!/opt/grads30d/scripts/gxgif -r -i
> /data/climat_6190_2/Lluvia6190_01.gmf -o
> /data/climat_6190_2/Lluvia6190_01.gif'*
> *'!rm /data/climat_6190_2/Lluvia6190_01.gmf'*
> *'q pos'*
> *'quit'*
>
>
>
> 2013/2/5 Estefanía Jiménez <estefaniajimenez.r at gmail.com>
>
>> Hi all! How can I do to do a script that plots and saves the same image
>> for several files? For example, I have 30 files that I need to get the rain
>> in an image and save it... I have the script for one file but how can I
>> change it to make it work for all the 30 files? So I don't have to run the
>> script 30 times...
>>
>> Thanks!
>>
>> --
>> *Estefanía Jiménez R.*
>>
>>
>
>
> --
> *Estefanía Jiménez R.*
> Meteoróloga
> Departamento de Climatología e Investigaciones Aplicadas
> Instituto Meteorológico Nacional
> MINAET
> Tel: +506 2222 5616 ext 131
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Martin V. Mathew
Research scholar
Centre for Oceans, Rivers, Atmosphere and Land Sciences (CORAL)
IIT Kharagpur
India.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130303/7d61310a/attachment-0003.html 


More information about the gradsusr mailing list