pro mk_sfs, infil, outdir, run_time=run_time
;
;+
;NAME:
;       mk_sfs
;PURPOSE:
;       Given a set of FFI files, read the roadmaps and save the 
;		open/open, diffuser (compressed), and UV flood images
;INPUT:
;       infil   - an array of input file names
;       outdir  - the output directory where the file should be written
;HISTORY:
;       Written 7-Aug-92 by M.Morrison
;	29-Nov-93 (MDM) - Modified to deleted the output file first
;-

if (n_elements(outdir) eq 0) then outdir = getenv('DIR_SXT_SFS')
;
progverno=1.00
start_time = systime(1)
run_time = 0.
prefix = 'sfs'

if (infil(0) eq '') then return			;no SFR files

rd_roadmap, infil, roadmap, filidx=filidx

aspect = mask(roadmap.periph, 7, 1)
ok_filt = ( (gt_filta(roadmap) eq 4) or (gt_filta(roadmap) eq 3) or ((gt_filta(roadmap) eq 1) and (gt_filtb(roadmap) eq 1)) )
ss=where( (gt_comp(roadmap) eq 0) and (gt_expmode(roadmap) eq 0) and (aspect eq 1) and (ok_filt) and (roadmap.percentd eq 255))
if (ss(0) eq -1) then return	;no matches
;
n = n_elements(ss)
ds=mk_dset_str(filidx,ss)

append = 0
for i=0,n-1 do begin
	rd_sda,infil(ds(i).ifil),ds(i).dset,index1,data1	

	print,i,' ',fmt_tim(index1)

	if (i eq 0) then begin
	    tim2orbit, index1, wid=wid
            wid = wid + '.' + string(fix(progverno), format='(i2.2)')
            filename = concat_dir(outdir, prefix+wid)
	    file_delete, filename
	end

	sav_sda,filename,index1,data1,append=append
	append = 1
end
	
end_time = systime(1)
run_time = (end_time-start_time)/60.
end

