'reinit'
VAR=TMIN

tit=Maxima
if (VAR=TMIN)
 tit=Minima
endif
color='(255,255,255)->(2,1,129)->(51,102,255)->(1,204,255)->(30,156,129)->(1,108,2)->(93,187,2)->(170,255,151)->(254,255,127)->(254,205,6)->(255,142,12)->(255,1,1)->(187,2,1)->(255,1,255)->(255,152,205)->(165,145,170)->(130,130,130)'

'open /share/ioper/tempo/SAMeT/DAILY/'VAR'/SAMeT_CPTEC_'VAR'.ctl'
'open /share/ioper/tempo/SAMeT/CLIMATOLOGY/DAILY_AVERAGE/'VAR'/SAMeT_CPTEC_'VAR'.ctl'
'open /lustre_xc50/ioper/users/alex/BRAZIL.ctl'

'set lat -33.7643 5.3893000'
'set lon -73.8329 -34.8515000'

* Media atual 2022
'set dfile 1'
'tmedAtual=ave('VAR',time=00Z01jun2022,time=00Z28jun2022)'

* Climatologia Diaria
'set dfile 2'
'tmedClim=ave(t'VAR',time=00Z01jun2020,time=00Z28jun2020)'

*Anomalia 
'tmedAnom=tmedAtual-tmedClim'

'set display color white'
'c'
'set grads off'
'set mpdset brmap_hires'
'set gxout shaded'
'set grads off'
'color 0 45 0.5 -kind 'color' -xcbar 0.5 8.0 0.4 0.6 -fw 0.14 -fh 0.14 -edge rectangle -line off -fs 10'
'd tmedAtual'
'mk=const(img.3(t=1,z=1),0,-u)'
'set dfile 3'
'set cstyle 1'
'set ccolor 1'
'set clab off'
'set gxout fgrid'
'set fgvals  0 0'
'set grads off'
'd mk'
'draw title SAMeT INPE Temperatura 'tit'(C)\ 12Z01Jun2022 ate 12Z30Jun2022'
'printim SAMeT_'VAR'_MedJunho.png x1854 y2400 '

'set display color white'
'c'
'set grads off'
'set mpdset brmap_hires'
'set gxout shaded'
'color 0 45 0.5 -kind 'color' -xcbar 0.5 8.0 0.4 0.6 -fw 0.14 -fh 0.14 -edge rectangle -line off -fs 10'
'd tmedClim'
'mk=const(img.3(t=1,z=1),0,-u)'
'set dfile 3'
'set cstyle 1'
'set ccolor 1'
'set clab off'
'set gxout fgrid'
'set fgvals  0 0'
'set grads off'
'd mk'
'draw title SAMeT INPE Temperatura 'tit'(C)\ Climatologia'
'printim SAMeT_'VAR'_Clim_Junho.png x1854 y2400 '



'set display color white'
'c'
'set grads off'
'set mpdset brmap_hires'
'set gxout shaded'
'color -5 5 0.1 -kind red->white->blue -xcbar 0.5 8.0 0.4 0.6 -fw 0.14 -fh 0.14 -edge rectangle -line off -fs 10'
'd tmedAnom'
'set dfile 3'
'set cstyle 1'
'set ccolor 1'
'set clab off'
'set gxout fgrid'
'set fgvals  0 0'
'set grads off'
'd mk'
'draw title SAMeT INPE Temperatura 'tit'(C)\ Anomalia'
'printim SAMeT_'VAR'_Anom_Junho.png x1854 y2400 '

'quit'

