;----------------------------------------------------------------------- function calcslt,ut,glon slt = ut+glon/15. if (slt lt 0.) then slt = slt+24. if (slt ge 24.) then slt = slt-24. return,slt end ; ;----------------------------------------------------------------------- ; 9/07: This clrbar is adapted from /home/tgcm/tgcmproc_idl/clrbar.pro ; pro clrbar,bw,bh,xo,yo,labels,BOTCOLOR=botcolor,TOPCOLOR=topcolor,$ LABCOLOR=labcolor,CHARSIZE=charsize,LABLEFT=lableft,LABTOP=labtop,$ LABOFFSET=laboffset,COLORTAB=colortab ; if (bw le 0. or bw gt 1. or bh le 0. or bh gt 1. or $ xo lt 0. or xo gt 1. or yo lt 0. or yo gt 1.) then begin print,'>>> clrbar: bad arg (all coords and sizes ',$ 'must be in normalized coords (0->1.)): bw,bh=',bw,bh,$ ' xo,yo=',xo,yo return endif if (keyword_set(charsize)) then chsize=charsize else chsize = 1.5 if (keyword_set(labcolor)) then iclab = labcolor else iclab = !p.color if (keyword_set(topcolor)) then itopclr = topcolor else $ itopclr = !d.table_size-1 if (keyword_set(botcolor)) then ibotclr = botcolor else ibotclr = 0 nc = itopclr-ibotclr+1 if (nc le 0) then begin print,'>>> clrbar: no colors?? nc=',nc,' bot,top color indices=',$ ibotclr,itopclr return endif nlab = n_elements(labels) if (nlab gt 0 and nlab ne nc+1) then begin print,' ' print,'>>> clrbar: please provide a label for each color plus 1' print,' (labels can be empty strings): ncolors = ',nc return endif if (keyword_set(laboffset)) then begin laboff = laboffset endif else begin laboff = .035 if (keyword_set(labtop)) then laboff = .025 endelse ; ; Horizontal color bar: ; if (bw ge bh) then begin cellw = bw/float(nc) ii = 0 for i=ibotclr,itopclr do begin x0 = xo + float(ii)*cellw x1 = x0+cellw x = [x0,x0,x1,x1] y = [yo,yo+bh,yo+bh,yo] polyfill,x,y,color=i,/norm ii = ii+1 endfor ; ; Labels: ; ii = 0 for i=ibotclr,itopclr+1 do begin x0 = xo + float(ii)*cellw if (nlab gt 0) then begin if (keyword_set(labtop)) then yl = yo+bh+laboff else yl = yo-laboff xyouts,x0,yl,labels(ii),/norm,align=.5,charsize=chsize plots,[x0,x0],[yo,yo+bh],/norm,color=iclab endif ii = ii+1 endfor endif else $ print,'>>> this code makes horizontal color bar only:',$ ' please make bw > bh' ; ; Border: ; x = [xo,xo,xo+bw,xo+bw,xo] y = [yo,yo+bh,yo+bh,yo,yo] plots,x,y,color=iclab,/norm end ; ;----------------------------------------------------------------------- ; pro utcontour,f,time,yy,glon,nlevels,xtitle,ytitle,title,filelabel,missing,jpg=jpg,ps=ps ; ; Set plot position: ; xll = .10 & yll = .33 xur = .95 & yur = yll+.7*(xur-xll) axespos = [xll,yll,xur,yur] xmid = .5*(xur+xll) ; ; For horizontal color bar at bottom: ; barw = xur-xll-.05*(xur-xll) & barh = .03 xbar = xmid-.5*barw ybar = yll-barh-.12 baroff = .035 ; ; chsize = 1.2 chsize = 1.0 ; ; Contour levels: ; fmin = min(f(where(f ne missing))) fmax = max(f(where(f ne missing))) step = (fmax-fmin)/nlevels ; print,'step=',step,' round(step)=',round(step) ; step = round(step) if (step le 0.) then begin print,format=$ "('>>> utcontour: bad contour interval=',e12.4,' fmin,max=',2e12.4,' nlevels=',i3)",$ step,fmin,fmax,nlevels return endif clevels = indgen(nlevels)*step+fmin c_colors = indgen(nlevels)+3 ; ; First contour call: save xtick values with xtick_get, but do not draw xaxes ; or data yet. ; contour,f,time,yy,position=axespos,/nodata,$ xstyle=5,ystyle=5,xtick_get=xtickv ; xstyle=5,ystyle=5,xticks=nxticks,xtick_get=xtickv ; ; This uses the time coord var calculated in timeaxis function ; to make major x-axis tick labels month/day/year. date_label = label_date(date_format="%N/%D/%Y!C") ; ; Set number of minor tick marks: ; for i=0,1 do begin caldat,xtickv[i],calmon,calday,calyear,calhr,calmin,calsec if (i gt 0) then dticks = xtickv[i]-xtickv[i-1] endfor if (dticks eq 1.0) then begin ; 1 days between major ticks xminor = 12 endif else if (dticks eq 0.5) then begin ; 12 hours between major ticks xminor = 12 endif else if (dticks eq 1./24.) then begin ; 1 hour between major ticks xminor = 6 endif else xminor = 0 ; ; Second contour call with data and axes: ; Use color=!p.color (foreground color) for writing jpg files ; (images have black background, white foreground) ; Use color=1 for ps files, or X ; icolor = 1 if keyword_set(jpg) then icolor=!p.color ; ; Use IDL pro label_date from above: contour,f,time,yy,position=axespos,/noerase,$ /fill,ytitle=ytitle,title=title,xminor=xminor,$ charsize=chsize,min_value=fmin,$ xstyle=1,ystyle=1,xtickformat='LABEL_DATE',$ c_colors=c_colors,levels=clevels,background=255,$ max_value=fmax,color=icolor ; ; Add local time to xtick labels below date label: ; (note 0.5 days are added to the julian day xtick value since ; julian days start at 12 noon (s.a., timeaxis function above) ; nxtick = n_elements(xtickv) for i=0,nxtick-1 do begin caldat,xtickv[i]+0.5,calmon,calday,calyear,calhr,calmin,calsec uthr = float(calhr)+float(calmin)/60. ; slt = calcslt(uthr,loc_lons[iloc]) slt = calcslt(uthr,glon) lthr = fix(slt) ltmin = fix((slt-float(lthr))*60.) ; ; Get day of year: ; function monthday_to_dayofyear, imonth,iday dayofyear = monthday_to_dayofyear(calmon,calday) dayofyear = dayofyear-1 ; because the julian day starts at noon ; sltlab = string(format="('day ',i3.3,' lt ',i2.2,':',i2.2)",$ dayofyear,lthr,ltmin) xnorm = convert_coord(xtickv[i],0.,/to_normal) ; xyouts,xnorm[0,0],yll-.055,sltlab,/norm,align=0.5,charsize=chsize-0.2 if keyword_set(ps) then $ xyouts,xnorm[0,0],yll-.050,sltlab,/norm,align=0.5,charsize=chsize-0.2 $ else $ xyouts,xnorm[0,0],yll-.055,sltlab,/norm,align=0.5,charsize=chsize-0.2 endfor ; ; X-axis label xyouts,xmid,yll-.09,xtitle,/norm,align=0.5,charsize=chsize ; ; Place vertical dashed line at any year-boundaries: ; ; if (nyrbound gt 0) then begin ; for i=0,nyrbound-1 do begin ; oplot,[iyrbound[i],iyrbound[i]],[zplev[0],zplev[nzp-1]],linestyle=2 ; dashed line ; endfor ; endif ; ; Min,max label: ; cint = clevels[1]-clevels[0] ; assume constant contour interval minmaxlabel = string(format="('Min,Max = ',g10.4,', ',g10.4,' Interval = ',g10.4)",$ fmin,fmax,cint) xyouts,xmid,yll-.24,minmaxlabel,/norm,align=0.5,charsize=chsize ; ; Files label: ; xyouts,xmid,yll-.28,filelabel,/norm,align=0.5,charsize=chsize ; ; Color bar: ; form = "(g10.4)" ; form = "(f9.3)" cblabels = strarr(nlevels+1) cblabels[*] = ' ' cblabels[0] = strcompress(string(format=form,fmin),/remove_all) for i=2,nlevels-2,2 do begin ; label every other level on color bar cblabels[i] = strcompress(string(format=form,clevels[i]),/remove_all) endfor cblabels[nlevels] = strcompress(string(format=form,fmax),$ /remove_all) clrbar,barw,barh,xbar,ybar,cblabels,botcolor=3,topcolor=nlevels+3-1,$ charsize=chsize,laboffset=baroff,labcolor=1 if (not keyword_set(ps)) then begin cursor,xcurs,ycurs,4 endif end ; pro utcontour