pro plot_sxl, sxl, ss, ymax, log=log
;+
;NAME:
;	plot_sxl
;PURPOSE: 
;	Plot SXL data (x-ray summary log of intensity of each SFD image)
;SAMPLE CALLING SEQUENCE:
;	plot_sxl, sxl, ss, ymax, [log=log]
;INPUT:
;	sxl	- index-recs from sxl data files
;	ss	- which indices to plot
;	ymax	- max value to plot
;	log	- switch to do log plot.
;HISTORY:
;	Written by M.Morrison in 1991
;	18-Nov-93 (GAL) - ADDED MINIMUMAL DOCUMENTATION HEADER FOR PLOT_SXL
;-            	
;
ref_time = sxl(0)
x = int2secarr(sxl, ref_time)
xrange = [0, max(x)]
yrange = [0, ymax]
ytit = 'DN/sec/HR Pix'
;
xx = x(ss)
yy = sxl(ss).img_avg		;
dx = deriv_arr(xx)/60/60/24		;days
sss = where(dx gt 3)	;
;
if (keyword_set(log)) then yrange(0) = 1
if ((ymax(0) eq 0) and (keyword_set(log))) then yrange(1) = max(yy)
;
utplot, xx, yy, ref_time, xrange=xrange, yrange=yrange, xstyle=1, $
	ytit=ytit, tit = 'Totals from SFD images for filter: '+gt_filtb(sxl(ss(0)),/str), ytype=keyword_set(log), /year
if (sss(0) ne -1) then for i=0,n_elements(sss)-1 do begin
    xxx = [xx(sss(i)),xx(sss(i)+1)]
    yyy = [yy(sss(i)),yy(sss(i)+1)]
    outplot, xxx, yyy, color=0
end
;
;utplot, sxl(ss2), smooth(sxl(ss2).img_avg<600,10), ref_time, xrange=xrange, ytit=ytit, tit = 'Totals from SFD images for filter: '+gt_filtb(2,/str)+ ' smooth 10'
;utplot, sxl(ss3), smooth(sxl(ss3).img_avg<400,10), ref_time, xrange=xrange, ytit=ytit, tit = 'Totals from SFD images for filter: '+gt_filtb(3,/str)+' smooth 10'
;plottime, 0, 0, 'PLOT_SXL  Ver 1.0
;plottime
end
;-----------------------------------------------------------------
;
;+
;NAME:
;	plot_sxl
;PURPOSE:
;	To plot the average intensity of the SFD images over the mission
;SAMPLE CALLING SEQUENCE:
;	.run plot_sxl
;HISTORY:
;	Written Fall, 91 by M.Morrison
;V2.5	25-Oct-93 (MDM) - Changed criteria for removing bad points to be
;			  less than 2000 (instead of less than 5000)
;V2.6	18-Nov-93 (GAL) - Updated for layered structure of sxl.
;	18-Nov-93 (MDM) - Added /year switch to UTPLOT
;-
;
print, 'You can create a 2 element array with the y-max desired'
print, '     sxl_ymax = [600, 300]
;
if (n_elements(sxl) eq 0) then rd_sxl, '1-sep-91', !stime, sxl, /summary
if (n_elements(sxl_ymax) eq 0) then sxl_ymax = [0,0]
;
!p.multi=[0,1,2]
;
for ytype=0,1 do begin
    plot_sxl, sxl, where((gt_filtb(sxl) eq 2) and (sxl.img_avg lt 2000)), sxl_ymax(0), log=ytype
    plot_sxl, sxl, where((gt_filtb(sxl) eq 3) and (sxl.img_avg lt 2000)), sxl_ymax(1), log=ytype
    plottime, 0, 0, 'PLOT_SXL  Ver 2.6'			;updated vers. #
    plottime
    if (ytype eq 0) then pause
end
;
!y.type = 0
!p.multi = 0
clear_utplot
end


