;+
; NAME:
; 	LCBDA
; PURPOSE:
; 	Plot out some or all of the light curves for the BCS channels
; CALLING SEQUENCE:  
;	LCBDA,index [,chans=[2,3,4],psym=psym,charsize=charsize,/log,/landsc]
;	LCBDA,index [,chans='2-3',.....]
; INPUTS:
;	index	index (or roadmap) structure
; OPTIONAL INPUTS:
;	chans	channels to be plotted (1=Fe XXV1, 2=Fe XXV, 3=Ca XIX, 4= SV)
;		if more than one, specify as an array (e.g. [3,4] )
;		OR 
;		Specify as a string with regexp (e.g. '2-4', '*', '1,2') 
;	psym 	plot symbol (default = 0)
;	charsize Character size
;	log  	keyword switch to turn on log plots
;                 Only data greater than 1 are plotted, anything below
;		  1 will be rounded up to 1, if log plot selected.
;	landscape If plot device is ps then use landscape orientation
;
;	obselete keyword
;         bcs = [0,1,2,3] - array of values 0 = FeXXVI 
;					    1 = FeXXV
;					    2 = CaXIX
;					    3 = SXV
;	 OR 
;	  bcs = '1,2,3,4' - string with regexp
;
; OUTPUTS:
;
; OPTIONAL OUTPUTS:
;
; RESTRICTIONS:
;
; PROCEDURE:
;         Plot is produced, either on Xterminal (idl7) or to postscript.
;
; MODIFICATION HISTORY:
; 	atp  27/3/92 	vn 0.3
;	RDB  18-Jul-92	CHAN keyword, changed plot stuff
;			used GT_BLOCKID
;	atp  23/11/92   v 0.5 rationalised changes btween mssl isas
;			cleaned up channel selection
;-
pro lcbda,index,psym=psym,log=log,chans=chans,bcs=bcs,charsize=charsize, $
 	landscape=landscape
;defaults;
;
if (not keyword_set(psym)) then psym = 0
if (keyword_set(log)) then ytype = 1 else ytype = 0
if (n_params() eq 0) then begin
	print,'Lcbda, index   or Lcbda,roadmap  '
	return
	endif

if (keyword_set(bcs)) then begin
	if ((size(bcs))(0) eq 0 and (size(bcs))(1) eq 7) then begin
	 ;have a string
	 range,bcs,3,channel,ier,0
	  if ier ne 0 then begin
	   print,'Range error'
	   return
	   endif
	 channels = [channel] + 1
	endif else begin
	 channels = [bcs] + 1
	endelse
	endif

if (keyword_set(chans)) then begin
	if ((size(chans))(0) eq 0 and (size(chans))(1) eq 7) then begin
	 ;have a string
	 range,chans,4,channel,ier,1
	 if ier ne 0 then begin
	  print,'Range error'
	  return
	  endif
	 channels = [channel] 
	endif else begin
	 channels = [chans] 
	endelse
	endif

if n_elements(channels) eq 0 then channels = [1,2,3,4]

nplots = n_elements(channels)

;	create vector of where counts are good and get the data

goodat = where(gt_blockid(index) eq 0)

bcs_fexxvi = gt_total_cnts(index(goodat),1) > 0
bcs_fexxv  = gt_total_cnts(index(goodat),2) > 0
bcs_caxix  = gt_total_cnts(index(goodat),3) > 0
bcs_sxv    = gt_total_cnts(index(goodat),4) > 0

;	logrithmically plotted data should start at 1

if ytype eq 1 then begin
  bcs_fexxvi = bcs_fexxvi > 1
  bcs_fexxv  = bcs_fexxv  > 1
  bcs_caxix  = bcs_caxix  > 1
  bcs_sxv    = bcs_sxv    > 1
  endif

!p.multi = [0,1,nplots,0,0]

if (!d.name eq 'X') then window,7,xs=600,ys=800 
if (!d.name eq 'PS') then begin 
	if (keyword_set(landscape)) then device,/landscape else begin
	 device,/portrait
	 ps_reset
	 ps_long 
	 endelse
        endif

!p.font=-1
chars=!p.charsize
if (keyword_set(charsize)) then !p.charsize = charsize else !p.charsize=1.4

;	plot the requested channels

for ii = 0,nplots-1 do begin

case channels(ii) of
 '1': utplot,index(goodat),bcs_fexxvi,psym=psym,/ynozer,ytype=ytype,title='BCS Time Profile FeXXVI',ytitle='Counts/sec'
 '2': utplot,index(goodat),bcs_fexxv,psym=psym,/ynozer,ytype=ytype,title='BCS Time Profile FeXXV',ytitle='Counts/sec'
 '3': utplot,index(goodat),bcs_caxix,psym=psym,/ynozer,ytype=ytype,title='BCS Time Profile CaXIX',ytitle='Counts/sec'
 '4': utplot,index(goodat),bcs_sxv,psym=psym,/ynozer,ytype=ytype,title='BCS Time Profile SXV',ytitle='Counts/sec'
  else: print,'Error in selection of plots - usage: lcbda,index[,bcs=[0,1,2,3],psym=symbol,/log]'
  endcase

endfor
!p.multi = 0
!p.charsize=chars 
!y.type = 0
ps_reset

end


