* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * subdiv_total.gs * * Plots annual, seasonal, or monthly climatological rainfall totals * for subdivisions of India. Requires a DODS-enabled version of GrADS * and three supplemental files: indiaregions, india_polygons.asc, * and readpolygons.gsf. See http://monsoondata.org/customize for * further information. * * Usage: subdiv_total * Where: type can be a (annual), s (seasonal), or m (monthly). * year is between 1871 and 2000 * month# is between 1-12 * If no arguments are given, the script will prompt the user. * * Example: subdiv_total m 1900 6 * * Written by J.M. Adams March 2003 * function main(args) * Make sure GrADS is in landscape mode 'q gxinfo' pagesize = sublin(result,2) xsize = subwrd(pagesize,4) ysize = subwrd(pagesize,6) if (xsize != 11 & ysize != 8.5) say 'You must be in LANDSCAPE MODE for this script to work properly.' return endif 'reinit' rc = gsfallow("on") * Parse the args if (args = '') prompt 'Annual, Seasonal, or Monthly Totals? (a/s/m) -> ' pull type if (type!='a' & type!='s' & type!='m') say 'Invalid choice. Exiting ...' return endif prompt 'Enter the 4-digit year (1871-2000) -> ' pull year if (type='m') prompt 'Enter the month (1-12) -> ' pull mon endif else type = subwrd(args,1) year = subwrd(args,2) mon = subwrd(args,3) if (year='') prompt 'Enter a 4-digit year -> ' pull year endif if (type='m' & mon='') prompt 'Enter the month (1-12) -> ' pull mon endif endif if (type='m') months = "jan feb mar apr may jun jul aug sep oct nov dec" month = subwrd(months,mon) endif * Set up the map 'set display color white' 'clear' * Load the polygon info into a script variable rc = readpolygons() * Set colors and levels dorgb() i = 1 _nlevs = 13 while (i <= _nlevs) _pcols.i = i + 66 i = i + 1 endwhile if (type='m') _plevs.1 = 20 _plevs.2 = 40 _plevs.3 = 60 _plevs.4 = 80 _plevs.5 = 100 _plevs.6 = 120 _plevs.7 = 140 _plevs.8 = 160 _plevs.9 = 200 _plevs.10 = 240 _plevs.11 = 280 _plevs.12 = 320 endif if (type='a' | type='s') _plevs.1 = 200 _plevs.2 = 400 _plevs.3 = 600 _plevs.4 = 800 _plevs.5 = 1000 _plevs.6 = 1200 _plevs.7 = 1400 _plevs.8 = 1600 _plevs.9 = 2000 _plevs.10 = 2400 _plevs.11 = 2800 _plevs.12 = 3200 endif * Open a data file and set the dimension environment if (type='a'); 'sdfopen http://monsoondata.org:9090/dods/iitm/subdiv/ann_total'; endif if (type='s'); 'sdfopen http://monsoondata.org:9090/dods/iitm/subdiv/seas_total'; endif if (type='m'); 'sdfopen http://monsoondata.org:9090/dods/iitm/subdiv/mon_total'; endif 'set dfile 2' 'set x 1' 'set y 1' 'set z 1' if (type='m') 'set time 'month%year else 'set time jan'year endif * Draw the polygons 'set line 99' div = 2 while (div <= 34) if (div = 2 | div = 12 | div = 15 | div = 16) 'set line 99' val = 0 else 'd p'div val = subwrd(result,4) if (val < _plevs.1 ) ; 'set line '_pcols.1 ; endif if (val < _plevs.2 & val >= _plevs.1 ) ; 'set line '_pcols.2 ; endif if (val < _plevs.3 & val >= _plevs.2 ) ; 'set line '_pcols.3 ; endif if (val < _plevs.4 & val >= _plevs.3 ) ; 'set line '_pcols.4 ; endif if (val < _plevs.5 & val >= _plevs.4 ) ; 'set line '_pcols.5 ; endif if (val < _plevs.6 & val >= _plevs.5 ) ; 'set line '_pcols.6 ; endif if (val < _plevs.7 & val >= _plevs.6 ) ; 'set line '_pcols.7 ; endif if (val < _plevs.8 & val >= _plevs.7 ) ; 'set line '_pcols.8 ; endif if (val < _plevs.9 & val >= _plevs.8 ) ; 'set line '_pcols.9 ; endif if (val < _plevs.10 & val >= _plevs.9 ) ; 'set line '_pcols.10 ; endif if (val < _plevs.11 & val >= _plevs.10) ; 'set line '_pcols.11 ; endif if (val < _plevs.12 & val >= _plevs.11) ; 'set line '_pcols.12 ; endif if ( val >= _plevs.12) ; 'set line '_pcols.13 ; endif endif _drawpolyf.div * Draw the value inside the polygon format = '%4.0f' fval = math_format(format,val) 'set font 0' 'set strsiz 0.08 0.10' 'set string 99 bc 1 ' * These are landscape mode coordinates if (div = 3) ; 'draw string 7.381 6.040 'fval; endif if (div = 4) ; 'draw string 7.964 5.410 'fval; endif if (div = 5) ; 'draw string 6.853 6.224 'fval; endif if (div = 6) ; 'draw string 6.688 4.761 'fval; endif if (div = 7) ; 'draw string 5.855 4.019 'fval; endif if (div = 8) ; 'draw string 6.061 4.893 'fval; endif if (div = 9) ; 'draw string 6.173 5.435 'fval; endif if (div = 10); 'draw string 5.270 5.588 'fval; endif if (div = 11); 'draw string 4.631 6.113 'fval; endif if (div = 13); 'draw string 4.114 6.366 'fval; endif if (div = 14); 'draw string 3.916 6.795 'fval; endif if (div = 17); 'draw string 3.135 5.780 'fval; endif if (div = 18); 'draw string 3.881 5.504 'fval; endif if (div = 19); 'draw string 4.164 4.734 'fval; endif if (div = 20); 'draw string 5.232 4.607 'fval; endif if (div = 21); 'draw string 3.366 4.739 'fval; endif if (div = 22); 'draw string 2.778 4.542 'fval; endif if (div = 23); 'draw string 3.135 3.354 'fval; endif if (div = 24); 'draw string 3.681 3.407 'fval; endif if (div = 25); 'draw string 4.158 3.738 'fval; endif if (div = 26); 'draw string 4.545 4.070 'fval; endif if (div = 27); 'draw string 4.950 2.969 'fval; endif if (div = 28); 'draw string 4.719 3.408 'fval; endif if (div = 29); 'draw string 4.521 2.584 'fval; endif if (div = 30); 'draw string 4.494 1.482 'fval; endif if (div = 31); 'draw string 3.432 2.419 'fval; endif if (div = 32); 'draw string 3.923 3.012 'fval; endif if (div = 33); 'draw string 4.191 2.144 'fval; endif if (div = 34); 'draw string 3.861 1.374 'fval; endif div = div + 1 endwhile * Draw the continental outline 'set dfile 1' 'set lat '_minlat' '_maxlat 'set lon '_minlon' '_maxlon 'set map 0' 'set mpdset indiaregions' 'set poli on' 'draw map' * Cover the neighboring coastlines 'set line 0' 'draw recf 7.6 1.5 9.1 4.38' ;* Burma 'draw polyf 5 1.43 4.6 0.68 5.5 0.68' ;* Sri Lanka 'draw polyf 1.96 5.1 2.27213 5.1493 1.96 5.8' ;* Pakistan * Draw the lines connecting values to regions 'set line 99 1 1' 'draw line 7.38 5.98 7.73 5.82';* 3 'draw line 6.85 6.19 6.93 5.81';* 5 'draw line 3.29 3.41 3.43 3.56';* 23 'draw line 3.57 2.46 3.75 2.66';* 31 'draw line 4.02 1.42 4.17 1.55';* 34 * Draw a colorbar polycolor() * Draw a title if (type='m') longmonths = "January February March April May June July August September October November December" label1 = subwrd(longmonths,mon) label1 = label1' 'year label2 = 'Total Rainfall' else label1 = year if (type='a') label2 = 'Annual Total Rainfall' else label2 = 'Seasonal Total Rainfall' endif endif label4 = '(mm)' 'set string 99 c' 'set strsiz 0.16 0.18' 'draw string 7 1.8 'label1 'draw string 7 1.5 'label2 'set strsiz 0.105 0.118' 'draw string 9.58 1.00 'label4 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * function dorgb * These are bright rainbow shades 'set rgb 66 178 247 247' 'set rgb 67 0 236 236' 'set rgb 68 1 160 246' 'set rgb 69 0 0 246' 'set rgb 70 0 255 0' 'set rgb 71 0 200 0' 'set rgb 72 0 144 0' 'set rgb 73 255 255 0' 'set rgb 74 231 192 0' 'set rgb 75 255 144 0' 'set rgb 76 255 0 0' 'set rgb 77 192 0 0' 'set rgb 78 255 0 255' 'set rgb 79 153 85 201' 'set rgb 99 1 1 1' 'set rgb 19 230 230 230' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * function polycolor * Get plot size info 'query gxinfo' rec2 = sublin(result,2) rec3 = sublin(result,3) rec4 = sublin(result,4) xsiz = subwrd(rec2,4) ysiz = subwrd(rec2,6) ylo= subwrd(rec4,4) xhi = subwrd(rec3,6) xd = xsiz - xhi * Set up constants xl = xhi + xd/2 - 0.8 xr = xl + 0.2 xwid = 0.2 xmid = xl + 0.1 ywid = 0.5 if (ywid*_nlevs > ysiz*0.88) ywid = ysiz*0.88/_nlevs endif ymid = ysiz/2 yb = ymid - ywid*_nlevs/2 'set string 99 l 5' vert = 1 * Plot colorbar 'set strsiz 0.10 0.11' num = 1 while (num <= _nlevs) col = _pcols.num val = _plevs.num 'set line 'col yt = yb + ywid if (num=_nlevs) 'draw polyf 'xl' 'yb' 'xr' 'yb' 'xmid' 'yt else if (num=1) 'draw polyf 'xl' 'yt' 'xr' 'yt' 'xmid' 'yb else 'draw recf 'xl' 'yb' 'xr' 'yt endif endif if (num<_nlevs) 'draw string '%(xr+0.05)%' 'yt' 'val endif num = num + 1 yb = yt endwhile bot = subwrd(rec4,4) top = subwrd(rec4,6) left = subwrd(rec3,4) right = subwrd(rec3,6) edge = subwrd(rec2,6) 'set line 0' 'draw recf 'left' 'top' 'right' 'edge 'set line 99' 'draw rec 'left' 'bot' 'right+1' 'top