;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; NAME: ; LOAD_CTBL ; PURPOSE: ; Loads (and optionally displays) the specified Climsat ASCII color table. ; KEYWORD PARAMETERS: ; Keywords: ; FILENAME Name of ASCII color table. ; NC Number of colors to load (maximum 256). ; CMIN=cmin Minimum color value (default 0). ; CMAX=cmax Maximum color value (default 255). ; DISPLAY=display Display the loaded color table. ; MODIFICATIONS: ; Original author: Wesley Berg, CIRES/CDC, 1996(?) ; Don Anderson, 2/17/99, Added display option. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRO load_ctbl, filename, nc, cmin=cmn, cmax=cmx, display=display ; Initialize variables common colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr if n_elements(cmn) eq 0 then cmn=0 if n_elements(cmx) eq 0 then cmx=255 ; Open and read the color table file print,'filename = ', filename openr, unit, filename, /get_lun, error=err print,'err = ', err if (err ne 0) then begin print, 'Error opening specified color table file, using default!' openr, unit, './rain.tbl', $ /get_lun, error=err if (err ne 0) then begin print, 'Unable to open default color table, program exiting!' goto, stop endif endif readf, unit, ncolors ; Create R,G,B value arrays a = bytarr (3, ncolors) r = bytarr (ncolors) g = bytarr (ncolors) b = bytarr (ncolors) ; Fill the R,G,B arrays with values in file readf, unit, a r = a (0,*) g = a (1,*) b = a (2,*) ; Adjust requested number of colors to available colors if n_elements(nc) EQ 0 then nc=!d.table_size if (nc GT ncolors) then nc=ncolors ; Interpolate if necessary if (nc lt ncolors) then begin p = lindgen(nc) p(cmn) = (lindgen(nc-cmn) * (cmx-cmn)) / (nc-1-cmn) + cmn r = r(p) g = g(p) b = b(p) endif ; Not sure what this does ... r_orig = r g_orig = g b_orig = b r_curr = r_orig g_curr = g_orig b_curr = b_orig ; Load the IDL display color translation tables from the specified variables tvlct, r, g, b if (nc GT cmx) then nc = cmx+1 ; Display color table if requested if keyword_set(display) then begin colorbar, /horizontal, /right, vmin=cmn, vmax=ncolors, cmin=cmn, cmax=ncolors endif ; End of story close, unit free_lun, unit stop: end