[gradsusr] Is it possible to run GRADS in shell script

Eric Altshuler ela at cola.iges.org
Thu Feb 20 18:00:10 EST 2014


Hi Sourabh, 


You can create a loop over the script variable 'n' to increment the year and output filename as follows: 


n=1 
while (n<=100) 
yr=n+1978 
'reinit' 

'open precip.'yr'.ctl' 


'set grads off' 
'set gxout shaded' 
'set lon 60 180' 
'set lat -20 40' 
#'set xlevs -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90' 
#'set ylevs 0 30 60 90 120 150 180 210 240 270 300 330 360' 
'set rgb 16 0 0 139' 
'set rgb 17 24 116 205' 
'set rgb 18 0 191 255' 
'set rgb 19 135 206 250' 
'set rgb 20 176 226 255' 
'set rgb 21 224 255 255' 
'set rgb 22 255 220 220' 
'set rgb 23 255 165 165' 
'set rgb 24 255 110 110' 
'set rgb 25 255 55 55' 
'set rgb 26 225 0 0' 
'set rgb 27 200, 0, 0' 

'set clevs -2.5 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 2.5' 
#'set clevs -2.5 -2.0 -1.5 0 1.5 2 2.5' 
'set ccols 16 17 18 19 20 21 22 23 24 25 26 27' 
#'set ccols 16 17 18 19 25 26 27' 


'd precip' 
'cbarn' 
'draw title observed 'yr' precipitation' 

'set string 1 tr 6' 
'set strsiz 0.1' 
'draw string 10 0.9 [mm/day]' 


#'draw xlab longtitude' 
'enable print figure'n'.mf' 
'print' 
'disable print' 
'!./gxeps -c -i figure'n'.mf -o preci.'yr'.eps' 

n=n+1 

endwhile 


Best regards, 


Eric L. Altshuler 
Research Scientist 
Center for Ocean-Land-Atmosphere Studies 
253 Research Hall, Mail Stop 6C5 
George Mason University 
4400 University Drive 
Fairfax, VA 22030 USA 

E-mail: ela at cola.iges.org 
Phone: (703) 993-5725 
Fax: (703) 993-5770 

----- Original Message -----
From: "Sourabh Bal" <sourabhbal at gmail.com> 
To: "GrADS Users Forum" <gradsusr at gradsusr.org> 
Sent: Thursday, February 20, 2014 10:07:02 AM 
Subject: Re: [gradsusr] Is it possible to run GRADS in shell script 


I have 100 files .ctl files for 100 years. I want to plot for these 100 years. As an example.. 


'reinit' 
'open precip.1979.ctl' 


'set grads off' 
'set gxout shaded' 
'set lon 60 180' 
'set lat -20 40' 
#'set xlevs -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90' 
#'set ylevs 0 30 60 90 120 150 180 210 240 270 300 330 360' 
'set rgb 16 0 0 139' 
'set rgb 17 24 116 205' 
'set rgb 18 0 191 255' 
'set rgb 19 135 206 250' 
'set rgb 20 176 226 255' 
'set rgb 21 224 255 255' 
'set rgb 22 255 220 220' 
'set rgb 23 255 165 165' 
'set rgb 24 255 110 110' 
'set rgb 25 255 55 55' 
'set rgb 26 225 0 0' 
'set rgb 27 200, 0, 0' 

'set clevs -2.5 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 2.5' 
#'set clevs -2.5 -2.0 -1.5 0 1.5 2 2.5' 
'set ccols 16 17 18 19 20 21 22 23 24 25 26 27' 
#'set ccols 16 17 18 19 25 26 27' 


'd precip' 
'cbarn' 
'draw title observed 1979 precipitation' 

'set string 1 tr 6' 
'set strsiz 0.1' 
'draw string 10 0.9 [mm/day]' 


#'draw xlab longtitude' 
'enable print figure3.mf' 
'print' 
'disable print' 
'!./gxeps -c -i figure3.mf -o preci.1979.eps' 

'reinit' 
'open precip.1980.ctl' 


'set grads off' 
'set gxout shaded' 
'set lon 60 180' 
'set lat -20 40' 
#'set xlevs -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90' 
#'set ylevs 0 30 60 90 120 150 180 210 240 270 300 330 360' 
'set rgb 16 0 0 139' 
'set rgb 17 24 116 205' 
'set rgb 18 0 191 255' 
'set rgb 19 135 206 250' 
'set rgb 20 176 226 255' 
'set rgb 21 224 255 255' 
'set rgb 22 255 220 220' 
'set rgb 23 255 165 165' 
'set rgb 24 255 110 110' 
'set rgb 25 255 55 55' 
'set rgb 26 225 0 0' 
'set rgb 27 200, 0, 0' 

'set clevs -2.5 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 2.5' 
#'set clevs -2.5 -2.0 -1.5 0 1.5 2 2.5' 
'set ccols 16 17 18 19 20 21 22 23 24 25 26 27' 
#'set ccols 16 17 18 19 25 26 27' 


'd precip' 
'cbarn' 
'draw title observed 1980 precipitation' 

'set string 1 tr 6' 
'set strsiz 0.1' 
'draw string 10 0.9 [mm/day]' 


#'draw xlab longtitude' 
'enable print figure4.mf' 
'print' 
'disable print' 
'!./gxeps -c -i figure4.mf -o preci.1980.eps' 


Here I wrote for two years i.e 1979 and 1980. In order to write for 100 years, how to write the shell script, so that opening initial (1979) and final (2078) year as different files and produce .eps files for each files representing each year. 




regards 




Sourabh 





























On Thu, Feb 20, 2014 at 8:21 PM, Kishore Ragi < kishoreragi at gmail.com > wrote: 



Dr. Sourabh, 


Tell me what exactly you want to do. You might have your grads scripts ready to run in shell script, isn't it? 





On Thu, Feb 20, 2014 at 8:16 PM, Sourabh Bal < sourabhbal at gmail.com > wrote: 

<blockquote>

Thanks Kishore. may you please give an example. 


regards 


Sourabh 





On Thu, Feb 20, 2014 at 8:11 PM, Kishore Ragi < kishoreragi at gmail.com > wrote: 

<blockquote>

yeah .. you can .. 


just use grads -lbc 'run yourfile_name.gs ' if you want in portrait use -pbc 


cheers, 


Kishore 





On Thu, Feb 20, 2014 at 8:00 PM, Sourabh Bal < sourabhbal at gmail.com > wrote: 

<blockquote>



Dear All, 


I want plot precipitation for individual 100 years. Each year represent as .ctl file. How to plot these 100 individual years in a single grads script. 


Please Help. 


Sourabh Bal 


-- 

Dr. Sourabh Bal 
Assistant Professor 
Dream Institute of Technology, Kolkata 



_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 





_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 


</blockquote>




-- 

Dr. Sourabh Bal 
Assistant Professor 
Dream Institute of Technology, Kolkata 



_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 


</blockquote>


_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 


</blockquote>




-- 

Dr. Sourabh Bal 
Assistant Professor 
Dream Institute of Technology, Kolkata 



_______________________________________________ 
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/20140220/04e405d5/attachment-0001.html 


More information about the gradsusr mailing list