pro mdiprot, seq_filnam, mat, force_calc=force_calc, qdisp=qdisp, qplot=qplot, $
			xytrend=xytrend, hc=hc, qiss=qiss, plot_list=plot_list
;+
;NAME:
;	mdiprot
;INPUT:
;	seq_filnam - The series number or telemetry file name
;INPUT/OUPTUT:
;	mat	- The matrix of cross locations
;OPTINAL KEYWORD INPUT:
;	force_calc - If set, then force the grid calculation to be done over
;		  even if it is already done.  The default is to not 
;		  recalculate the cross locations if already done.
;	hc	- If set, make a hardcopy
;	qdisp	- If set, when doing the fitting of the cross locations, 
;		  display the image and the first guess
;	qplot	- If set, when doing the fitting of the cross locations,
;		  display the fit to the cross
;	qiss	- If set, then "mdiprot.src" was run for one set of repeats
;		  with ISS off and then on.
;       plot_list - If set, only plot the plots listed in that string
;                   String items: rawp, smoop, diff, m1, m2, pol, iss_on, iss_off
;HISTORY:
;	Written 26-Apr-94 by M.Morrison (using PLOT_GROSS2 as a start)
;V1.1	12-May-94 (MDM) - Added /QISS option
;V1.2    3-Jun-94 (MDM) - Added capability to only do single plot
;                         (so that we can do guide plots)
;                         (added PLOT_LIST optional keyword input)
;-
;
progver = 'MDIPROT  Ver 1.2'
;
if (keyword_set(hc)) then begin
    save_dev = !d.name
    set_plot, 'ps
    device, /land
end
;
read_mdi, seq_filnam, images, code, txtfil, /type_info
infil = concat_dir(getenv('MDI_CAL_TXT'), txtfil+'.gcross')
;
qcalc = 1
if (file_exist(infil)) then qcalc = 0
if (keyword_set(force_calc)) then qcalc = 1
;
if (qcalc) then begin
    read_mdi, seq_filnam, images, nimg, /nimages		;should be 61
    images = indgen(nimg-1)
    idark = nimg-1			;last image is dark
    if (keyword_set(qiss)) then begin
	nn = (nimg-2)/2
	images = [indgen(nn), indgen(nn)+nn+1]
    end
    do_fit_gcross, seq_filnam, idark=idark, images=images, qdisp=qdisp, qplot=qplot, /qhr, nfit=40
end
;
if (n_elements(mat) eq 0) then mat = rd_tfile(infil, 11, 8, /conv)
n = n_elements(mat(0,*))
nrep = n/4
;
spawn, 'grep "Base:" ' + infil, result
tit0 = result(0)
;
qiss_on  = 1
qiss_off = 1
if (keyword_set(plot_list)) then begin
    qiss_on = 0
    qiss_off = 0
    if (strpos(plot_list, 'iss_on')  ne -1) then qiss_on  = 1
    if (strpos(plot_list, 'iss_off') ne -1) then qiss_off = 1
end
;
if (keyword_set(qiss)) then begin
    nrep = nrep/2	;half on, half off
    nn = nrep*4
    if (qiss_off) then plot_gcross, mat(*,0:nn-1), tit0, nrep, 4, xytrend=xytrend, /mdiprot, progver=progver, plot_list=plot_list
    if (qiss_on)  then plot_gcross, mat(*,nn:*), tit0, nrep, 4, xytrend=xytrend, /mdiprot, progver=progver, plot_list=plot_list
end else begin
    plot_gcross, mat, tit0, nrep, 4, xytrend=xytrend, /mdiprot, progver=progver, plot_list=plot_list
end
;
if (!d.name eq 'PS') then begin
    pprint
    if (n_elements(save_dev) ne 0) then set_plot, save_dev
end

end
