pro sxtpnt_sum, sttim0, entim0, outfil, outfile=outfil_key, hc=hc, qstop=qstop, minsep=minsep
;
;+
;NAME:
;	sxtpnt_sum
;PURPOSE:
;	To generate a summary listing of the SXT images taken for a time
;	span sorting by different PFI pointings
;SAMPLE SEQUENCE CALL:
;	sxtpnt_sum, sttim, entim
;	sxtpnt_sum, '5-oct-93 13:00', '6-sep-93 1:00', /hc
;	sxtpnt_sum, '5-oct-93 13:00', '6-sep-93 1:00', outfil='harvey1.txt'
;INPUT:
;	sttim	- The starting time
;	entim	- The ending time
;OPTIONAL INPUT:
;	outfil	- The name of the output file.  If not passed, it will 
;		  make the file "sxtpnt_sum.txt" in your home directory.
;OPTIONAL KEYWORD INPUT:
;	hc	- If set, then print the file to the laser printer.
;	minsep	- The minimum change in pointing in arcminutes before 
;		  flagging it as a new region.  Default is 0.75 arcmin.
;HISTORY:
;	Written 19-Oct-93 by M.Morrison
;	27-Oct-93 (MDM) - Added the MINSEP keyword option
;-
;
if (n_elements(minsep) eq 0) then minsep = 0.75
if (n_elements(outfil_key) ne 0) then outfil = outfil_key
if (n_elements(outfil) eq 0) then begin
    outfil = concat_dir(getenv('HOME'), 'sxtpnt_sum.txt')
    print, 'Output file will be: ', outfil
end
;
rd_obs, sttim0, entim0, bcs, sxtf, sxtp, /sxtp
if (get_nbytes(sxtp) lt 10) then return
x = int2secarr(sxtp)
sxtp = sxtp(uniq(x,sort(x)))	;needed because of temporary OBS database
nn = n_elements(sxtp)
;
;;;pnt = gt_center(sxtp, /helio, /str, /cmd)
;;;ss_upnt = uniq(pnt)    ;do not sort. ss is the LAST image of a uniq pointing
;
pnt = gt_center(sxtp)
ss_upnt = 0
ilast = 0
for i=1,nn-1 do begin
    del = sqrt( (pnt(0, i)-pnt(0,ilast))^2 + (pnt(1, i)-pnt(1,ilast))^2 ) * 2.45 /60.
    if (del gt minsep) then begin
	ss_upnt = [ss_upnt, i]
	ilast = i
    end
end
;
if (keyword_set(qstop)) then stop
;
n = n_elements(ss_upnt)
for i=0,n-1 do begin
    ;;;entim = sxtp(ss_upnt(i))
    ;;;if (i eq 0) then sttim = sxtp(0) else sttim = sxtp(ss_upnt(i-1)+1)
    sttim = sxtp(ss_upnt(i))
    if (i eq n-1) then entim = sxtp(nn-1) else entim = sxtp(ss_upnt(i+1)-1)
    obs_summary, sttim, entim, outfil=outfil, append=(i ne 0)
end
;
if (keyword_set(hc)) then dprint, outfil, /land
end

