* File : plot_track.gs * A grads script for plotting cyclone tracks *TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT * Author : Martin V. Mathew, vmartinmathew@gmail.com * Date : 7 March 2012 *LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 'reinit' 'set display color white' 'c' figname='cyclone_tracks' outeps=figname%'.eps' 'enable print 'figname ****************************************************************************** * 2) Stanard setting of the "vpage" ('xmin' 'xmax' 'ymin' 'ymax') * No need to change for a portrait page orientation. ****************************************************************************** xMn=0.0 xMx=8.5 yMn=0.0 yMx=11.0 SuWt=7 SuHt=5 LfMgn=0.4 TpMgn=0.5 VrtSpc=0.0 HztlSpc=0.0 *================= io=1 jo=1 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Calculating location of subplot sxMn=LfMgn+(io-1)*(SuWt+HztlSpc) sxMx=LfMgn+io*SuWt+(io-1)*HztlSpc syMn=yMx-(TpMgn+jo*SuHt+(jo-1)*VrtSpc) syMx=yMx-(TpMgn+(jo-1)*(SuHt+VrtSpc)) *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ****************************************************************************** * Specify number of cyclone tracks to be plotted ****************************************************************************** trkNo=4 ****************************************************************************** * Specify ascii file names containing lat lon cordinates of cyclone track. * No of files should be same as the variable 'trkNo' specified earlier ****************************************************************************** *trkFile.1='/home/sumesh/NIO-systems/1994-cyclones/cyclone-track/track1.asc' *trkFile.2='/home/sumesh/NIO-systems/1994-cyclones/cyclone-track/track2.asc' *trkFile.3='/home/sumesh/NIO-systems/1994-cyclones/cyclone-track/track3.asc' *trkFile.4='/home/sumesh/NIO-systems/1994-cyclones/cyclone-track/track4.asc' trkFile.1='track1.asc' trkFile.2='track2.asc' trkFile.3='track3.asc' trkFile.4='track4.asc' *trkFile.3='/users/martin/Desktop/trk_dta2.asc' * For ploting more tracks add corresponding file name to the compound variable ****************************************************************************** * Specifying number of points to be plotted for each cyclone track using a * compoud variable. ****************************************************************************** trk1.1=12 trk1.2=11 trk1.3=11 trk1.4=12 *TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT * [C] Defining contour properties and legend details *LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL * Again, different compound variables are used... *============================================================== * LnStyl(3) => Specifies line style for contours 1,2 and 3 corresponding to * cyclone tracks. * MkrStyl(3) => Specifies marker style for contours 1,2 and 3 corresponding * cyclone tracks. * LnClr (3) => Specifies line and marker color for, for first second and * third cyclone track * lgnds (4x3) => Specifies legends (cyclone details) to be written on the plot. *------------------------------------------------------------------- * [1] First, define the line style for each contour *Here, for example, LnStyl.1=1 means for first data (contour) in each *subplot the line style used is a solid line style(=1). * Check following URL for the GrADS convetions for the line style *http://www.iges.org/grads/gadoc/gadocindex.html " lines options" LnStyl.1=1;*Solid line First cyclone track LnStyl.2=1;*Solid line Second cyclone track LnStyl.3=1;*Solid line Third cyclone track LnStyl.4=1;*Solid line Fourth cyclone track *LnStyl.3=1;*Solid line Third cyclone track *------------------------------------------------------------------- * [2] Second, define the marker style. *Here, for example, MkrStyl.1=3 means for first data (contour) in each *subplot the marker style used is a solid solid circle (=3). * Check following URL for the GrADS convetions for the line style *http://www.iges.org/grads/gadoc/gadocindex.html MkrStyl.1=2;* First , marker open circle MkrStyl.2=3;* Second, marker closed circle MkrStyl.3=4;* Third, marker open square MkrStyl.4=5;* Fourth, marker closed square *MkrStyl.3=9;* third, marker solid triangle *------------------------------------------------------------------- * [3] Third, define the color for contours and markers. *Here, for example, LnClr.1=1 means for first data(LnClr.1) *the line as well as marker color used is black (=1). LnClr.1=1 LnClr.2=1 LnClr.3=1 LnClr.4=1 * [4] Define the string for plot legends. *Here, for eg., lgnds.1='scs_june' means the legend used for first track is * "scs_june" (='scs_june'). * Note:- do not use any space in between (replace space with underscores) lgnds.2='SCS_June'; lgnds.4='SCS_November'; lgnds.3='SCS_October'; lgnds.1='SCS_April'; * Define position of legends on each subplot. Starting position of first * legend is given in fraction (0 to 1) of x (Lft to Rgt) and y(Btm to Top) axis. * This program uses a grads script 'legend_lin_mkr.gs' to draw the legend. * If there is more than one legend in the plot, subsequnt legeds are * drawn below the first one with a spacing specified by the variable 'lgndSpce' lgndY=0.95;lgndX=0.75 ;* at top left corner, 90% of y-axis, 10% of x axis lgndSpce=0.04 *================================================================== * opening a file just for following set commands to work properly 'sdfopen sst.nc' 'set t 1' * 'set xlint 5' 'set lon 50 100' 'set lat 0 30' 'set lev 0' *============================================================================== *Parameters for setting dimensions of figure (set vpage 'xmin' 'xmax' 'ymin' 'ymax') *============================================================================== 'set vpage 'xMn' 'xMx' 'yMn' 'yMx 'set parea 'sxMn' 'sxMx' 'syMn' 'syMx ******************************************************************************** * 13d) Main title ******************************************************************************* 'set strsiz 0.12 0.12' 'set string 1 bl 5 0' 'draw string 1.7 10.6 Cyclones over North Indian Ocean during 1994' 'set xlint 5' 'set ylint 5' 'set map 5 1 5' 'set grads off' 'set mpdraw off' 'set grid off' * 'set grid on 1 0' * 'set clab forced' 'set font 4' 'set ylopts 1 4 .11' 'set ylab on' 'set xlopts 1 4 .11' 'set xlab on' * Displaying a proxy data which will help in plotting basemap. The contour * intervals selected for the proxy data plotted here is much larger than * the actual data in that file. Hence the proxy data wont modify the figure. 'set gxout contour' 'set clevs -200 200' 'd sst' *'run /home/sumesh/NIO-systems/1994-cyclones/cyclone-track/basemap.gs L' 'run /users/martin/work/supporting_files/grads/basemap.gs L' dta1=trkNo dta=0 while(dta1>0) dta=dta+1 dtaFile=trkFile.dta say 'reding from file 'dtaFile res=read(dtaFile) ;* skipping first line of cyclone track data file say 'title line 'res raws=trk1.dta res=read (dtaFile);* Reading first lat lon points anslin2=sublin(res,2) say 'second raw ' res lonpt1=subwrd (anslin2,1) latpt1=subwrd (anslin2,2) 'q w2xy 'lonpt1' 'latpt1 *'q w2xy 100 28' will give result as 'X = 6.22321 Y = 8.08214' * 'x1 = subwrd(result,3)', will take '6.22321', which is in 3rd position in 'result' * and save it in 'x1' x1=subwrd(result,3) y1=subwrd(result,6) while(raws>1) res=read (dtaFile) anslin2=sublin(res,2) lonpt2=subwrd (anslin2,1) latpt2=subwrd (anslin2,2) 'q w2xy 'lonpt2' 'latpt2 x2=subwrd(result,3) y2=subwrd(result,6) 'set line 'LnClr.dta' 'LnStyl.dta;*set line color#