;+ ; NAME: ; flt2color ; PURPOSE: (one line) ; Turn a float (or array) into [blue,green,red] ; DESCRIPTION: ; Turn a float (or array) into [blue,green,red] ; CATEGORY: ; graphics ; CALLING SEQUENCE: ; b = flt2color(a, table=table, fmin=fmin, fmax=fmax, bmin=bmin, bmax=bmax) ; INPUTS: ; a - a scalar or array of floats or doubles ; OPTIONAL INPUT PARAMETERS: ; KEYWORD INPUT PARAMETERS: ; table - color table (default - current table) ; fmin - minimum float value (default min(b)) ; fmin - maximum float value (default max(b)) ; bmin - minium byte value (default - 0) ; bmax - minium byte value (default - 255) ; KEYWORD OUTPUT PARAMETERS: ; OUTPUTS: ; b = byte[3], or byte[3,N1, N2, ...] where b has dimensions [N1, N2, ..] ; COMMON BLOCKS: ; SIDE EFFECTS: ; changes the color table ; RESTRICTIONS: ; None ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2006 Jan 13, by Leslie Young, SwRI ;- function flt2color, a, table, fmin=fmin, fmax=fmax, bmin=bmin, bmax=bmax DEVICE, get_decomposed=decomposed_orig TVLCT, sample_orig, /get if n_params() gt 1 then begin loadct, table, /silent TVLCT, sample, /get endif else begin sample = sample_orig endelse ; use n_elements instead of keyword_set so 0 is a valid option if n_elements(fmin) eq 0 or n_elements(fmax) eq 0 then aminmax = minmax(a) if n_elements(fmin) eq 0 then fmin = aminmax[0] if n_elements(fmax) eq 0 then fmax = aminmax[1] if n_elements(bmin) eq 0 then bmin = 0 if n_elements(bmax) eq 0 then bmax = 255 abyte = round(linscl(float(a),fmin,fmax,bmin,bmax, /cli)) b = colorize_sample(abyte, transpose(sample)) tvlct, sample_orig device, decomposed = decomposed_orig return, b end