function img_summ_sub1, struct, item, labels, last_month, sernum=sernum, code=code, nsets=nsets, fix=fix
;
;
;
if (n_elements(code) eq 0) then code = 'TOTAL'
if (keyword_set(sernum)) then code = 'SERNUM'
nmon = fix(int2secarr(last_month, '1-sep-91')/86400./30.+.5)
mon = 9
yr = 91
;
out = lonarr(nmon+1)
if ((code ne 'TOTAL') and (code ne 'SERNUM')) then out = fltarr(nmon+1)
labels = strarr(nmon+1)
;
for imon=0,nmon-1 do begin
    st_tarr = [0,0,0,0,1,mon,yr]
    st_date = anytim2ints(st_tarr)
    mon2 = mon + 1
    yr2 = yr
    if (mon2 ge 13) then begin & mon2 = 1 & yr2 = yr2 + 1 & end
    en_tarr = [0,0,0,0,1,mon2,yr2]
    en_date = anytim2ints(en_tarr)

    labels(imon) = strmid( gt_day(st_date,/str, /lower), 3, 6)
    ;
    ss = where( (int2secarr(struct, st_date) ge 0) and (int2secarr(struct, en_date) le 0), count)
    nsets = count
    ;
    tot = 0
    if (count ne 0) then begin
	case code of
	    'SERNUM': tot = item(1,ss(count-1)) - item(0,ss(0))
	    'TOTAL':  tot = total(item(ss))
	    'AVERAGE': tot = total(item(ss)) / nsets
	    'DCLEVEL': begin
				get_sdl_info, struct(ss), item(ss), avg, dev
				tot = total(avg) / nsets
			end
	    'DCSPIKE1': begin
				tot = total(item(ss).hist(48+1:*)) / nsets
			end
	    'DCSPIKE2': begin
				tot = total(item(ss).hist(64+1:*)) / nsets
			end
	    'DUR_WARM': begin
				t1 = gt_temp_ccd(item(ss).avg_temp_ccd)
				t2 = gt_temp_ccd(item(ss+1).avg_temp_ccd)
				dummy = where( (t1 le -20) and (t2 gt -20), tot)	;number of times going warm
				if (tot ne 0) then begin
				    ;--- MDM patch 11-Apr-95 for warm periods spanning a month
				    t1 = gt_temp_ccd(item(ss(0):*).avg_temp_ccd)
				    t2 = gt_temp_ccd(item(ss(1):*).avg_temp_ccd)
				    ss = [ss, indgen(20)+max(ss)+1]	;extend the SS array
				    ;
				    dummy2 = where( (t1 ge -20) and (t2 lt -20), tot)	;number of times going cold
				    if (tot gt 0) then $
				    tot = item(ss(dummy2)).day - item(ss(dummy)).day 	;number of days warm
				end
		     end
	    'WARM_TEMP': begin
				t1 = gt_temp_ccd(item(ss).avg_temp_ccd)
				t2 = gt_temp_ccd(item(ss+1).avg_temp_ccd)
				dummy = where( (t1 le -20) and (t2 gt -20), tot)	;number of times going warm
				if (tot ne 0) then begin
				    ss = [ss, indgen(3)+max(ss)+1]	;MDM added 11-Apr-95
				    tot = gt_temp_ccd(max(item(ss).max_temp_ccd))
				end
		     end
	    'FRONT_TEMP': begin
				t1 = gt_temp_hk(item(ss).avg_temp_hk, 2)
				tot = total(t1) / n_elements(t1)
		    end
	endcase
    end
    ;
    if ((yr eq 93) and (mon eq 2)) then begin	;MDM added 12-AUg-93
	case code of
	    'DCLEVEL': tot = 42.2781
	    'DCSPIKE1': tot = 13895
	    'DCSPIKE2': tot = 2090
	    else:
	endcase
    end

    out(imon) = tot

    mon = mon2
    yr = yr2
end

out(nmon) = total(out)
labels(nmon) = 'Total '
if ((code ne 'TOTAL') and (code ne 'SERNUM')) then begin
    labels(nmon) = 'Avg   '
    out(nmon) = out(nmon) / (n_elements(out)-1)
end
if (keyword_set(fix)) then out = long(out)
;
return, out
end
;-------------------------------------------------------------------------------------------------
;
;Ver 2.0  9-Mar-93 (MDM) - 
;Ver 2.1 10-Aug-93 (MDM) - Dark spike count columns used to be:
;				Labeled:	# Over 48	# Over 64
;				Actual		# Over 48	# Over 32
;			   Changed it to (label and actual):
;						# Over 48	# Over 64
;Ver 2.2 12-Aug-93 (MDM) - Hardwired Feb-93 dark current information after
;			   calculating it by interpolating two images.
;Ver 2.3 28-Jul-94 (MDM) - Modified so that only the last 29 months are listed.
;			   Set "nlist = 999" if you want all months
;Ver 2.4 24-Aug-94 (MDM) - Modified to exclude saturated dark images
;			   (bad dark image taken 11-Jul-94 19:36:32)
;Ver 2.5 11-Apr-95 (MDM) - Added question to enter the output file name
;			 - Corrected warm up situation over a month boundary
;Ver 2.6 27-Apr-95 (MDM) - Modified to eliminate fill data from the dark
;			   pixel counts.
;			 - Avoid images right after cool down (temperature
;			   read -21.73 for 2-Mar-95 20:51:31 but it was
;			   actually warmer than the nominal -20.9919 C)
;
progver =  'Ver 2.6 17-Apr-95'
if (n_elements(outfil) eq 0) then outfil = 'progress_summary.txt'
if (getenv('ys_batch') ne '1') then input, 'Enter output file name:', outfil, outfil
;
if (n_elements(ssl) eq 0) then rd_ssl, '1-sep-91', !stime, ssl
if (n_elements(last_month) eq 0) then last_month = !stime
;match = 'where((gt_res(index0) eq 1) and (gt_dpe(index0) eq 23))'
 match = 'where((gt_res(index0) eq 1) and (gt_dpe(index0) eq 23) and (gt_percentover(index0) le 2))'	;MDM 24-Aug-94
if (n_elements(sdl) eq 0) then begin
    rd_sdl, '1-sep-91', !stime, index, sdl, match = match
    tim2orbit, index, saa=saa
    ss = where((not saa) and (gt_temp_ccd(index) lt -20) and (index.sxt.percentd eq 255) and $
					(sdl.hist(170) lt 1024) and (gt_temp_ccd(index) gt -21) )
    if (ss(0) ne -1) then begin
	index0 = index
	index = index(ss)
	sdl   = sdl(ss)
    end else begin
	print, 'All SDL data is within SAA.  Stopping'
	stop
    end
end
if (n_elements(sot) eq 0) then begin
    rd_sot, '1-sep-91', !stime, index2, sot
    ss = where(gt_filta(index2) eq 2)
    index2 = index2(ss)
    sot = sot(ss)
    res = 2^gt_res(index2)
    expdur = gt_expdur(index2)/1000.
    y_sot = sot.find_limb(7)/res^2/expdur
    ss = where(y_sot gt 500)
    index2 = index2(ss)
    y_sot = y_sot(ss)
    sot = sot(ss)
end
;
openw, lun, outfil, /get_lun
;
if (getenv('YS_GUIDE') ne '') then printf, lun, '\begin{verbatim}
    printf, lun, 'PROGRESS_SUMMARY.PRO ' + progver
    printf, lun, 'Program Run: ', !stime
    printf, lun, '  '
    ;

if (n_elements(ffi_got) eq 0) then begin
    temp1 = img_summ_sub1(ssl, ssl.ffi_qt, labarr, last_month)
    temp2 = img_summ_sub1(ssl, ssl.ffi_buff, labarr, last_month)
    ffi_got = temp1 + temp2		;Full Frame - Total

    or_qt_got = img_summ_sub1(ssl, ssl.pfi_qt(1), labarr, last_month)
    or_fl_got = img_summ_sub1(ssl, ssl.pfi_fl(1), labarr, last_month)
    or_got = or_qt_got + or_fl_got	;Observing Regions - total

    temp1 = img_summ_sub1(ssl, ssl.pfi_qt(0), labarr, last_month)
    temp2 = img_summ_sub1(ssl, ssl.pfi_fl(0), labarr, last_month)
    pfi_got = temp1 + temp2

    ffi_abstot = img_summ_sub1(ssl, ssl.ffi_sernum, labarr, last_month, /sernum)	;ffi taken, not necessarily received
    or_abstot = img_summ_sub1(ssl, ssl.pfi_sernum, labarr, last_month, /sernum)		;pfi taken, not received

    or_lost = or_abstot - or_got
    ffi_lost = ffi_abstot - ffi_got

    p_lost = or_lost / float(or_abstot) * 100.
end
;
    printf, lun, '------------------------------------------------------------------------------
    printf, lun, '  Month           Full Frame Images       Observing Region Images
    printf, lun, '             Received   Lost                Received           Lost    Loss %
    printf, lun, '                                      QT       FL      Tot    
    printf, lun, '  '
                 ; AUG-92        6572     2978        24207    11154    35361    13550   27.70
    printf, lun, '   '

    ;fmt = '(1x, a6, 3x, 2i9, 4x, 4i9, f8.2)'
    fmt = '(1x, a11, 2i9, 4x, 4i9, f8.2)'
    if (n_elements(nlist) eq 0) then nlist = 29
    ist = (n_elements(labarr)-nlist)>0
    if (ist gt 0) then begin
	ss0 = indgen(ist)
	str = string('Thru ' + labarr(ist-1), total(long(ffi_got(ss0))), total(long(ffi_lost(ss0))), total(long(or_qt_got(ss0))), $
	    total(long(or_fl_got(ss0))), total(long(or_got(ss0))), total(long(or_lost(ss0))), total(p_lost(ss0))/ist, format=fmt)
	print, str
	printf, lun, str
    end

    for i=ist,n_elements(labarr)-1 do begin
	str = string(labarr(i) + '      ', ffi_got(i), ffi_lost(i), or_qt_got(i), $
			or_fl_got(i), or_got(i), or_lost(i), p_lost(i), format=fmt)
	print, str
	printf, lun, str
    end
;
n = n_elements(labarr)
printf, lun, '  '
printf, lun, 'Number of Full Frame Images Received:             ', ffi_got(n-1), format='(1x, a, i9)'
printf, lun, 'Number of Observing Region Images Received:       ', or_got(n-1), format='(1x, a, i9)'
printf, lun, 'Total:                                            ', ffi_got(n-1) + or_got(n-1), format='(1x, a, i9)'
printf, lun, '  '
printf, lun, '  '
;
printf, lun, '  '
avg_p_lost = p_lost(n-1)/100.
nshut = ffi_got(n-1) + ffi_lost(n-1) + pfi_got(n-1) * (1.0 + avg_p_lost)
printf, lun, 'Approximate Number of Shutter Moves/CCD Readouts: ', nshut, format='(1x, a, i9)'
;
printf, lun, '  '
printf, lun, 'NOTES: * The loss of images is mainly due to BDR overwrites, but there are also
printf, lun, '         occasional DSN dumps which are lost.
printf, lun, '       * It is common to have observing regions which contain more than 64 
printf, lun, '         lines, which requires multiple exposures to make a single observing
printf, lun, '         region image.  This is why the number of shutter moves is larger
printf, lun, '         than the number of images received plus those lost.
printf, lun, '         
printf, lun, '         
printf, lun, '  '
printf, lun, '  '
printf, lun, '  '
;
;--------------------------------------------------------------------------------
;
printf, lun, '--------------------------------------------------------------------------------
printf, lun, '  Month     Avg Dark Level     # of Dark Spikes    CCD Warmings  Front   Optical
printf, lun, '             (DN)    (e/sec)  Over 48  Over 64       High / #   Support   Trans
printf, lun, '                                                     Temp /Days  Temp     (%)  '
printf, lun, ' '
             ; APR-92      31.44     35.2     1323    49325        23.8 / 4   14.6      22.8

if (n_elements(dclevel) eq 0) then begin
    dclevel  = img_summ_sub1(index, sdl, labarr, last_month, code = 'DCLEVEL')
    dcspike1 = img_summ_sub1(index, sdl, labarr, last_month, code = 'DCSPIKE1', /fix)
    dcspike2 = img_summ_sub1(index, sdl, labarr, last_month, code = 'DCSPIKE2', /fix)
end
;
if (n_elements(eps) eq 0) then begin
    eps = (dclevel-30.5)*100/2.668 > 0
    dur_warm = img_summ_sub1(ssl, ssl, labarr, last_month, code = 'DUR_WARM', /fix)
    warm_temp = img_summ_sub1(ssl, ssl, labarr, last_month, code = 'WARM_TEMP')
    front_temp = img_summ_sub1(ssl, ssl, labarr, last_month, code = 'FRONT_TEMP')
    sot_trans = img_summ_sub1(index2, y_sot, labarr, last_month, code = 'AVERAGE') / y_sot(0) * 100
end
;
;for i=1,n_elements(labarr)-2 do begin
for i=ist,n_elements(labarr)-2 do begin
    fmt = '(1x, a6, 3x, 4a, 4x, a, f7.1, 3x, a)'
    tt = '            '
    if (warm_temp(i) ne 0) then tt = string(warm_temp(i), dur_warm(i), format='(f8.1," / ",i1)')

    tt2 = '    N/A'
    if (sot_trans(i) ne 0) then tt2 = string(sot_trans(i), format='(f7.1)')

    if (dclevel(i) ne 0) then dd1 = string(dclevel(i), format='(f8.2)') else dd1 = '     N/A'
    if (dclevel(i) ne 0) then dd2 = string(eps(i), format='(f9.1)')     else dd2 = '      N/A'
    if (dclevel(i) ne 0) then dd3 = string(dcspike1(i), format='(i9)')  else dd3 = '      N/A'
    if (dclevel(i) ne 0) then dd4 = string(dcspike2(i), format='(i9)')  else dd4 = '      N/A'

    str = string(labarr(i), dd1, dd2, dd3, dd4, tt, front_temp(i), tt2, format=fmt)
    print, str
    printf, lun, str
end
;
printf, lun, '  '
printf, lun, '  '
             ;--------------------------------------------------------------------------------
printf, lun, 'NOTES: * The dark current calculations are using full half resolution 2.668 sec
printf, lun, '         images not taken in during the SAA.  The dark current rate assumes a
printf, lun, '         "fat zero" of 30.5 DN and a gain of 100 e/DN.'
printf, lun, '       * The entrance filter failure of 13-Nov-92 eliminated the capability of
printf, lun, '         taking optical images, so the optical transmission is not available
printf, lun, '         after Nov-92.  It also caused an increase in the dark current signal,
printf, lun, '         however some of the increase shown here is an increase in the readout
printf, lun, '         noise and is not a function of exposure duration.
;
if (getenv('YS_GUIDE') ne '') then printf, lun, '\end{verbatim}
free_lun, lun
end
