'open imergf.ctl'
'set display color white'
'clear'
'environ_shaded.ch'
'set grads off'
'set poli on'
'set mpdset hires'
'run rgbset.gs'
'set map 1 1 11'
'set lat LATLL LATUR'
'set lon LONLL LONUR'
'set xlint XLINT'
'set ylint YLINT'
*'set parea 0 10 0 15'

count=1
'sumprecip = 0.5*prate'
while (count < MAXLOOP)
count=count+1
sat 'count = 'count
'set t ' count
'tempprecip = sumprecip'
'sumprecip = tempprecip + 0.5*prate'
endwhile

'set grads off'
'set gxout shaded'
'set rgb 40 0 0 0'
'set rgb 41 0 236 236'
'set rgb 42 1 160 246'
'set rgb 43 0 0 246'
'set rgb 44 0 255 0'
'set rgb 45 0 200 0'
'set rgb 46 0 144 0'
'set rgb 47 255 255 0'
'set rgb 48 231 192 0'
'set rgb 49 255 144 0'
'set rgb 50 255 0 0'
'set rgb 51 214 0 0'
'set rgb 52 192 0 0'
'set rgb 53 255 0 255'
'set rgb 54 153 85 201'
'set clevs  1  2  5  10 15 20 25 50 75 100 125 150'
'set ccols 0 41 42 43 44 45 46 47 48 49  50  51  52'
'd sumprecip'
'run cbar.gs'

'set gxout contour'
* Draw Kenya county shapefiles
'set line 1 1 3'
* Updated on 2/18/2016
'draw shp Kenya_admin_2014_WGS84 1 46'
*'draw shp kenya_counties'

'set string 1 c 10 0'
'set strsiz 0.19'
'draw string 5.5 10.75 IMERG Final ACCUM-h Accumulated Precipitation (mm)'
'set strsiz 0.14'
'draw string 5.5 10.45 Valid for period ending HHz DD MON YYYY'

text = "Writing PNG file for IMERG-Final ACCUM-h precip at YYYYMMDD_HHz"
'gxprint ./imergfACCUMh.png png xXPIX yYPIX white'

* Placeholder for google earth image production.
*'set gxout kml'

* Close the control files and get outta here!
'close 1'
'quit'

