;+
;NAME:
;	do_disp_mmap1
;PURPOSE:
;	An interactive driver for the DISP_MMAP routine
;HISTORY:
;	Written 15-Mar-94 by M.Morrison
;	30-Mar-94 (MDM) - Modified to describe to the user how to 
;			  analyze LFFT datasets
;	 4-Apr-94 (MDM) - Modified to be able to do several positions
;-
;
print, '------------------------------------------------------------'
print, 'For LFFT sets, the following parameters are needed:
print, '    "Bogus" image offset:                            ', 1
print, '    # Images per position:                           ', 27
print, '    Dark Image # within the "one position" series    ', 6
print, '    Obs Image # within the "one position" series     ', 0
print, '    Image # of first of 20 Michelson tuning          ', 7
print, 'There are 9 positions available (answer 0-8)
print, '------------------------------------------------------------'
print, ' '
;
setenv, 'ys_batch='
set_plot, 'x'
;
;if (n_elements(dir) eq 0) then dir = '/data0/log/sci160k'
if (n_elements(dir) eq 0) then dir = '/disk6/log/sci160k'
;
yesnox, 'Do you wish to select the latest telemetry file', ans, 'Yes'
if (ans) then begin
    ff = file_list(dir, '*_01.tfr')
    seq = ff(n_elements(ff)-1)
    seq = strmid(seq, 0, strlen(seq)-7)	;strip _01.tfr
end
;
if (n_elements(seq) eq 0) then 		seq = '$MDI_SCI160K_LOG_DIR/940312_052339'
if (n_elements(img_shift) eq 0) then 	img_shift = 0
if (n_elements(nimg_per_pos) eq 0) then	nimg_per_pos = 22
if (n_elements(idark) eq 0) then	idark = 1
if (n_elements(iobs) eq 0) then		iobs = 0
if (n_elements(ist1) eq 0) then		ist1 = 2
if (n_elements(qsave) eq 0) then	qsave = 1
if (n_elements(qhc) eq 0) then		qhc = 1 
;
yes_no_arr = ['No ', 'Yes']
print, '********************************************************************************'
print, 'Absolute image numbers start counting at zero (first image = image #0)
print, 'Telemetry File Name (including directory):       ', seq
print, 'Directory for the telemetry files:               ', dir
print, '"Bogus" image offset:                            ', strtrim(img_shift,2)
print, '# Images per position:                           ', strtrim(nimg_per_pos,2)
print, 'Dark Image # within the "one position" series    ', strtrim(idark,2)
print, 'Obs Image # within the "one position" series     ', strtrim(iobs,2)
print, 'Image # of first of 20 Michelson tuning          ', strtrim(ist1,2)
print, 'Automatically save Michelson maps                ', yes_no_arr(qsave)
print, 'Automatically generate a hardcopy                ', yes_no_arr(qhc)
print, '********************************************************************************'
;
yesnox, 'Do you wish to change any of the above parameters? ', ans, 'N'
print, ' '
if (ans) then begin
    input, 'Telemetry File Name:                           ', seq, seq
    input, 'Telemetry directory name:                      ', dir, dir
    input, '"Bogus" image offset:                          ', img_shift, img_shift
    input, '# Images per position:                         ', nimg_per_pos, nimg_per_pos
    input, 'Dark Image # within the "one position" series  ', idark, idark
    input, 'Obs Image # within the "one position" series   ', iobs, iobs
    input, 'Image # of first of 20 Michelson tuning        ', ist1, ist1
    yesnox, 'Automatically save Michelson maps             ', qsave, yes_no_arr(qsave)
    yesnox, 'Automatically generate a hardcopy             ', qhc, yes_no_arr(qhc)
end
;
if (n_elements(str_ipos) eq 0) then str_ipos = '0'
if (n_elements(irep) eq 0) then irep = 0
;
print, '--------------------------------------------------------------------------------'
print, 'To run all 9 positions of "mdilaser" enter:    0,1,2,3,4,5,6,7,8'
input, 'Enter position(s) to run ', str_ipos, str_ipos
input, 'Enter the repeat to run ', irep, irep
;
yesnox, 'Ready to run DISP_MMAP now? ', ans, 'Yes'
if (ans) then begin
    pos_arr = fix(str2arr(str_ipos))
    for i=0,n_elements(pos_arr)-1 do begin
	ipos = pos_arr(i)
	imgnum = [idark, iobs, indgen(20)+irep*20+ist1] + ipos*nimg_per_pos + img_shift
	comment = 'Dark,Obs=' + arr2str(imgnum(0:1)) + '  !cM1=' + arr2str(imgnum(2:11)) + '  !cM2='+arr2str(imgnum(12:21))
	disp_mmap, seq, ipos, sub10=irep, imgnum=imgnum, comment=comment, save=qsave
	;
	qdohc = qhc
	if (qhc eq 0) then yesnox, 'Would you like a hardcopy of this result', qdohc, 'No'
	if (qdohc) then disp_mmap, seq, ipos, sub10=irep, imgnum=imgnum, comment=comment, /hc
    end
end

end
