pro uvspcolor, norm_r=norm_r, norm_g=norm_g, norm_b=norm_b, $
	       line_r=line_r, line_g=line_g, line_b=line_b, distinct=distinct,$
	       dopp_r=dopp_r, dopp_g=dopp_g, dopp_b=dopp_b, middopp=middopp

;
;
; Create the color tables used by UVSP display program
;
;

;6/93 ; create a window temporarily to get number of color indexes this system
; window,/free,xsize=10,ysize=10 & wdelete,!d.window 

 linecolors, line_r=ret_r, line_g=ret_g, line_b=ret_b, used=distinct

 maxind = !d.n_colors - distinct         ; colors in system minus linecolors
; middopp=(!p.color)/2                    ; middle value of color table
 middopp=(maxind-1)/2 			 ; middle value of color table

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Normal red (really brown) color table, white line at max color index 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ; colors to max available index
 norm_r=bytarr(maxind)  &   norm_g=norm_r  &  norm_b=norm_r  

 ; reds gun linear 0 to 255 to 68% through index, rest are 255
 r_space = fix(maxind * .68)    ; space available to squeeze in values 0-255
 norm_r(0) = indgen(r_space) * (255./r_space)
 norm_r(r_space:*) = 255        ; rest off space is fill with 255

 ; green gun zeroes 47% through index, then linear 1 to 255
 mark = fix(maxind * .47)     ; start position for non-zero values
 g_space = maxind - mark      ; space available to squeeze in values 0-255
 norm_g(mark) =  indgen(g_space) * (255./g_space)

 ; blue gun zeroes 75% through index, then linear 1 to 255
 mark = fix(maxind * .75)
 b_space = maxind - mark      	; space available to squeeze in values 0-255
 norm_b(mark) =  indgen(b_space) * (255./b_space)
   

 ; stick the distinct LINECOLORs at the beginning
 norm_r = [ret_r(0:distinct-1), norm_r]
 norm_g = [ret_g(0:distinct-1), norm_g]
 norm_b = [ret_b(0:distinct-1), norm_b]

 ; now put a white line at max index for drawing plots and letters
 norm_r(!p.color)=255  &  norm_g(!p.color)= 255  &  norm_b(!p.color)=255  

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Dopplergram color table, normal red (really brown) colors to the halfway
;	point then blue through red shift in the second half, with white
;	line at max index
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ; colors to max available index
 dopp_r=bytarr(maxind)  &   dopp_g=dopp_r  &  dopp_b=dopp_r  

 
 ; reds gun linear 0 to 255 to 68% through 1st half index, rest are 255
 r_space = fix(middopp * .68)
 dopp_r(0) = indgen(r_space) * (255./r_space)
 dopp_r(r_space:middopp) = 255

 ; second half of red gun holds doppler colors incrementing 0-255
 mark = middopp			; doppler red starts at end of normal red
 r_space = maxind - middopp	; space available for red gun doppler
 temp = indgen(r_space) * (255./r_space)  ; squeeze 0-255 into available space
 dopp_r(middopp) = temp
              
 ; green gun normal table has zeroes through 47% of 1st half then 0-255
 ;	in rest of 1st half of green indexes
 mark = fix(middopp * .47)     ; start position for non-zero values
 g_space = middopp - mark      ; space available to squeeze in values 0-255
 dopp_g(mark) =  indgen(g_space) * (255./g_space)

 ; 2nd half doppler green gun has zeroes through 29% then it increment 
 ;	0 to 124 to the mid point of the 2nd half, then decrements 124 to 0
 ;	until leaving 29% more zeroes 
 g_space = maxind-middopp 		   ; space available for green dopplers
 mark = middopp + fix(g_space * .29)       ; start pos. non-zero green doppler 

 g_sp_half = g_space/2	        	; mid point of 1st green doppler half 

 g_avail = (middopp+g_sp_half)-mark	; space available for incrementing
			                ;  part of green doppler gun
 temp = indgen(g_avail) * (124./g_avail) 
 dopp_g(mark) =temp
 dopp_g(mark+g_avail) = max(temp) - temp
 
 ; blue gun zeroes to 75% through first half of color table, 
 ;   then linear 1 to middopp
 mark = fix(middopp * .75)      ; starting index for non-zero indexes
 b_space = middopp - mark      	; space available to squeeze in values 0-255
 dopp_b(mark) =  indgen(b_space) * (255./b_space)

 ; for doppler part the rest of blue gun is filled with decreasing values
 mark = middopp 	              	; 1st doppler color
 b_space = maxind - middopp 		; space available for colors    	
 temp = indgen(b_space) * (255./b_space)  ; squeeze 0-255 into available space
 temp = byte(max(temp) - temp)		; decending order
 dopp_b(middopp) = temp

 ; stick the distinct LINECOLORs at the beginning
 dopp_r = [ret_r(0:distinct-1), dopp_r]
 dopp_g = [ret_g(0:distinct-1), dopp_g]
 dopp_b = [ret_b(0:distinct-1), dopp_b]

 middopp = middopp + distinct 	 ; middle value of dopp with linecolors 

 ; white line at max value
 dopp_r(!p.color) = 255   &  dopp_g(!p.color)= 255  &  dopp_b(!p.color)=255 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Make color table for colorful plotting lines
;; make 5 colors, one for each detector  
;;    index 0 is black, 1 is green, 2 is red, 3 is blue, 4 is magenta, 
;;	   5 is yellow, all the rest are the same as NORM_*
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; line_r=norm_r &   line_g=norm_g  &  line_b=norm_b
;
; if maxind ge 6 then begin		
; ; Can make my 6 colors. Load to end of normal so those 
; ;   image won't look to bad while this table is in effect
; ;   White is already at !p.color
;
;  overwrite = !p.color-6
;
;  ;            	      spare	det 5       det 4    det 3    det 2    det1    
;  ;                   blue  	yellow      magenta  red      cyan     green
;
;  line_r(overwrite) = [  0,        255,      255,     255,       0,       0]
;  line_g(overwrite) = [  0,        255,        0,       0,     255,     255]
;  line_b(overwrite) = [255,          0,      255,       0,     255,       0]
;
; endif

end