pro save_mmap, head0, serial, pos, sub10, q900, image, $
		item=item, ifile=ifile, $
		map_ver=map_ver, laspos=laspos, uncert=uncert, sum_arr=sum_arr
;
;HISTORY:
;       Written Feb-94 by M.Morrison
;       18-Feb-94 (MDM) - Expanded to allow AMP, OFFSET and PHASE to be saved
;                       - Added keyword ITEM=ITEM so that the extension could
;                         be directly specified.
;			*********************
;			- Modified so that it saved only one image at a time.
;	25-Feb-94 (MDM) - Modified so that "head0" does not have to be defined
;	 4-Mar-94 (MDM) - Renamed from SAVE_DO1POS to SAVE_MMAP
;	15-Mar-94 (MDM) - Modified to delete the output file if it exists
;
;
mmap1pos, ver_mmap, /progver
maplaser, ver_maplaser, /progver
;
head = [mk_fits_head(image), 'END                                                                             ']
if (n_elements(head0) ne 0) and (data_type(head0) eq 7) then head = [head(0:4), head0(5:*)]
head = head(where(strtrim(head,2) ne ''))
sxaddpar, head, 'HISTORY', '--------------------- Processing Done -------------------'
sxaddpar, head, 'CREATED', strmid(!stime, 0, 20)
if (keyword_set(map_ver)) then begin
    sxaddpar, head, 'MMAP1POS', 'Ver: ' + ver_mmap
    sxaddpar, head, 'MAPLASER', 'Ver: ' + ver_maplaser
end
if (keyword_set(uncert)) then sxaddpar, head, 'TR_UNCERT', uncert
if (keyword_set(sum_arr)) then begin
    sxaddpar, head, 'AVG_OFF1', sum_arr(0)
    sxaddpar, head, 'AVG_OFF2', sum_arr(1)
    sxaddpar, head, 'AVG_AMP1', sum_arr(2)
    sxaddpar, head, 'AVG_AMP2', sum_arr(3)
    sxaddpar, head, 'AVG_SAVG', sum_arr(4)
    sxaddpar, head, 'AVG_DARK', sum_arr(5)
end
if (keyword_set(laspos)) then begin
    sxaddpar, head, 'LASPOS_X', laspos(0)
    sxaddpar, head, 'LASPOS_Y', laspos(1)
end
;
filnam = map_filnam(serial, pos, sub10, q900=q900, ifile=ifile, item=item ) 
print, 'Saving: ', filnam
sxaddpar, head, 'FILENAM', filnam
if (file_exist(filnam)) then file_delete, filnam
wrt_fits, filnam, head, image
;
end

