;*****************************; ; rsl_colorbar ; ;*****************************; pro rsl_colorbar, field, xpos=xpos, ypos=ypos, color=color, $ charsize=charsize, horizontal=horizontal, thick=thick, encap=encap ; This procedure adds a colorbar to the radar image. ; ; Arguments: ; field: String specifying the radar data field to use for color ; placement, for example, 'DZ'. ; ; Keywords: ; XPOS X position of left side of color bar, in normalized ; coordinates. Default is 0.95. ; YPOS Y position of top of color bar, in normalized coordinates. ; Default is 0.9. ; HORIZONTAL Set this for horizontal color bar. Default is vertical. ; CHARSIZE: IDL graphics character size. Default is 1. ; ; TODO: Add options for height and width of colorbar. ; fieldtype = field ; Make data labels for colorbar. Fields that have the same units can ; share a field type for the purpose of labeling the color bar. For example, ; DZ, CZ and ZT are all in units of dBZ. Since labeling is defined for DZ in ; the case statement below, we can use that for all three fields. if field eq 'ZT' or field eq 'CZ' then fieldtype = 'DZ' ;if field eq 'ZD' then fieldtype = 'DR' case fieldtype of 'DZ': begin labels = ['70','65','60','55','50','45','40','35','30','25','20','15', $ '10','5','0','<0'] units = 'dBZ' end 'DW': begin labels = ['>50','50','47.5','45','42.5','40','37.5','35','32.5',$ '30','27.5','25','22.5','20', $ '17.5','15','12.5','10','7.5','5.0','0.0','<0'] ; labels = ['>50','50','45','40','35','30','25','20','15','10','5','0', $ ; '-5','-10','-15','<-15'] units = 'dBZ' end 'DK': begin labels = ['>30','30','27.5','25','22.5','20','17.5','15','12.5',$ '10','7.5','5','2.5','0', $ '-2.5','-5.0','-7.5','-10','-12.5','-15.0','-20.0','<-20'] ; labels = ['>50','50','45','40','35','30','25','20','15','10','5','0', $ ; '-5','-10','-15','<-15'] units = 'dBZ' end 'CV': begin labels = ['RF','38','30.4','22.8','15.2','7.6','0','-7.6',$ '-15.2','-22.8','-30.4',$ '-38'] units = 'm/s' end 'VE': begin labels = ['RF','13.5','11.25','9.0','6.75','4.5','2.25','0',$ '-2.25','-4.5','-6.75','-9.0','-11.25','-13.5'] units = 'm/s' end 'VR': begin labels=['RF','27.0','22.5','18.0','13.5','9','4.5','0','-4.5',$ '-9','-13.5','-18.0','-22.5','-27.0'] units = 'm/s' end 'SW': begin labels = ['RF','>21','20','18','16','14','12','10','8','6','4','2','0'] units = 'm/s' end 'DR': begin labels = ['>5.','5.0','4.5','4.0','3.5','3.0','2.5','2.0','1.5','1.0',$ '0.5','0.0','-0.5','-1.0','<-1.'] units = 'dB' end 'ZD': begin labels = ['>5.0','5.0','4.5','4.0','3.5','3.0','2.5','2.0','1.5','1.0',$ '0.5','0.0','-0.5','-1.0','-1.5','-2.0','<-2.'] units = 'dB' end 'KD': begin labels = strarr(13) labels[12] = '<0' labels[0] = '>10' labels[1:11] = strtrim(string(10-indgen(11)*1.0,format='(F4.1)'),2) units = 'deg/km' end 'KX': begin labels = ['>9.','9.0','7.5','6.0','4.5','3.0','1.5','0.0','-1.5','-3.0',$ '-4.5','-6.0','<-6.'] units = 'deg/km' end 'KC': begin labels = ['>5.0','5.0','4.5','4.0','3.5','3.0','2.5','2.0','1.5','1.0',$ '0.5','0.0','-0.5','-1.0','-1.5','-2.0','<-2.'] units = 'deg/km' end 'RH': begin labels = ['.995','.99','.985','.98','.975','.90','.88','.80','.60',$ '.40','.20','0.0'] units = '' end 'PH': begin labels = ['>360','356','320','284','248','212','176','140','108','72',$ '36','<0'] units = 'deg' end 'PC': begin labels = ['<-180','-150','-135','-120','-105','-90','-75','-60','-45',$ '-30','-15', '0'] units = 'deg' end 'LD': begin labels = ['0','-5','-10','-15','-20','-25','-30','-35','-40','-45','-50',$ '-55'] units = 'deg' end 'RR': begin vals = [0.0, 0.5, 1.0, 2.0, 4.0, 8.00, 12.5, 15.0, 25.0, 50.0, 75.0, 100.0] labels = reverse(strtrim(string(vals,format='(F8.1)'),2)) units = 'mm/hr' ; if n_elements(ypos) eq 0 then ypos = .95 end ; ; *** Retrieved DSD parms ; 'NW': begin labels = strtrim(string(7.5-indgen(16)*0.5,format='(F4.1)'),2) ; print,labels units = 'Log(Nw)' ; if n_elements(ypos) eq 0 then ypos = .95 end 'D0': begin labels = strtrim(string(7.5-indgen(16)*0.5,format='(F4.1)'),2) ; print,labels units = 'mm' end ; ; *** CSU HID stuff ; 'FHT': begin labels = ['LH','SH','WS','VI','HDG','LDG','DS','RN','DZ','UC'] units = '' end 'FHK': begin labels = ['LH','SH','WG','DG','VI','WS','DS','RN','DZ','UC'] units = '' end 'FHK11': begin labels = ['LH+R','SH+R','LH','SH','WG','DG','VI','WS','DS','RN','DZ','UC'] units = '' end 'FHSUM': begin labels = ['BD','HA','HDG','LDG','VI','WS','DS','CR','RN','DZ','UC'] units = '' end 'MC': begin labels = ['4','3','2','1'] units = '' end 'MP': begin labels = ['5','4','3','2','1'] units = '' end 'MR': begin labels = ['5','4','3','2','1'] units = '' end 'DHC': begin ; labels = ['','','','','','','LD','DR','RA','HR','RH','HA','GR','WI','DI','CR','DN'] ; labels = ['LD','DR','RA','HR','RH','HA','GR','WI','DI','CR','DN'] labels = ['DN','CR','DI','WI','GR','HA','RH','HR','RA','DR','LD'] ;0=NO_DATA ;1=CLUTTER ;2=CLUTTER2 ;3=CLEAR_AIR ;4=ATTENUATION ;5=NOT_CLASSIFIED ;6=LARGE_DROPS ;7=DRIZZLE ;8=RAIN ;9=HEAVY_RAIN ;10=RAIN_HAIL ;11=HAIL ;12=GRAUPEL ;13=WET_SNOW ;14=DRY_SNOW ;15=CRYSTALS ;16=DENDRITES units = '' end 'FHCOLD': begin labels = ['HDG','LDG','VI','AG','PL','DN','DS','WS','RN','LtRN','DZ','UC'] units = '' end 'FHB': begin labels = ['BD','LH','SH','WG','DG','VI','WS','DS','RN','DZ','UC'] units = '' end 'FHC': begin labels = ['VI','HDG','LDG','CR','AG','RN','DZ','UC'] units = '' end 'FHCP': begin labels = ['HI','HDG','LDG','WS','SN','VI','RN','DZ','UC'] units = '' end 'T': begin labels = ['20','10','0','-10','-20','-30','-40','-50','-60','-70'] units = '' end endcase ; If needed, set color bar starting coordinates. ;if n_elements(xpos) eq 0 then xs =.5 else xs = xpos if n_elements(xpos) eq 0 then xs =.9525 else xs = xpos if n_elements(ypos) eq 0 then ys =.9825 else ys = ypos ; This adjusts coordinates if !p.multi is in use. xs = !x.region[0] + xs * (!x.region[1] - !x.region[0]) ys = !y.window[0] + ys * (!y.window[1] - !y.window[0]) ;print,'xs=',xs,', ys=',ys ; testing ncolors = n_elements(labels) if not keyword_set(horizontal) then vertical = 1 else vertical = 0 ; Use window size to set colorbar size. if vertical then windowsize = !y.window[1] - !y.window[0] $ else windowsize = !x.window[1] - !x.window[0] cbpctwin = .8 cbarlen = windowsize * cbpctwin cbstart = (windowsize-cbarlen)/2. cbseg = cbarlen/ncolors IF keyword_set(encap) THEN BEGIN if vertical then begin x = xs y = cbstart + !y.window[0] thickness = 70 ; 10;TODO this should be scaled. endif else begin y = ys x = cbstart + !x.window[0] thickness = 10;18 ; TODO this should be scaled. endelse ;STOP ENDIF ELSE BEGIN if vertical then begin x = xs y = cbstart + !y.window[0] thickness = 25 ; 10;TODO this should be scaled. endif else begin y = ys x = cbstart + !x.window[0] thickness = 20;18 ; TODO this should be scaled. endelse ENDELSE if n_elements(thick) ne 0 then thickness = thick ;print, 'thickness = ', thickness ; testing ;print,'x=',x,', y=',y,', cbstart=',cbstart ; testing ;stop plots,x,y,/norm if vertical then y = y+(indgen(ncolors)+1)*cbseg $ else x = x+(indgen(ncolors)+1)*cbseg plots,x,y,/norm,/cont,col=indgen(ncolors)+1,thick=thickness ; Write value labels on color scale. Vertically center the labels. ; Note that labels need to be reversed here. This may (probably should) change. if vertical then xyouts,xs,y-.75*cbseg, $ reverse(labels),/normal,align=.5,color=0,charsize=charsize $ else begin chr_ht = float(!d.y_ch_size)/!d.y_size ylabpos = y-.4*chr_ht xyouts,x-.5*cbseg,ylabpos,reverse(labels),/normal,align=.5,color=0, $ charsize=charsize endelse ; Write units label. if(vertical) then begin xyouts,x,y[ncolors-1]+.25*cbseg,units,align=.5,charsize=charsize,/normal, $ color=color endif else begin xyouts,x[0]-0.5*cbseg,y-0.03,units,align=1.,charsize=charsize,/normal, $ color=color endelse end