PRO oldmbkgrd,filename,hh,mm,ss,span,minim,pixchg,rutsec,exp=exp COMMON header,fname,hbytes,nimages,utsec,exptimes,keep IF NOT KEYWORD_SET(exp) THEN exp=60. ELSE exp=FLOAT(exp) IF (N_ELEMENTS(fname) EQ 0) OR (fname NE filename) THEN BEGIN ; Open the file as a series of small (header-size) units and get ; the header information fname=filename OPENR,hbunit,filename,/GET_LUN hbfile=ASSOC(hbunit,BYTARR(512)) hbstat=FSTAT(hbunit) hbbytes=hbstat.SIZE nimages=hbbytes/66048L PRINT,'There are '+STRTRIM(nimages,2)+' images' hbytes=BYTARR(512,nimages) utsec=LONARR(nimages) exptimes=FLTARR(nimages) FOR i=0L,nimages-1 DO BEGIN hbytes(0,i)=hbfile(129*i) header=gethd(hbytes(*,i)) utsec(i)=3600L*header.misc.tm.hour $ + 60L*header.misc.tm.minute $ + 1L*header.misc.tm.second exptimes(i)=header.misc.exp_scale*header.exp.exposure/1000. IF (i GT 0) AND (i MOD 20 EQ 0) THEN PRINT,i,FORMAT='(I4,$)' IF (i GT 0) AND (i MOD 400 EQ 0) THEN PRINT,FORMAT='()' ENDFOR PRINT,FORMAT='()' CLOSE,hbunit FREE_LUN,hbunit ENDIF minim=INTARR(256,256)+16383 butsec=3600L*hh+60L*mm+1L*ss eutsec=ROUND(butsec+FLOAT(span)*3600) OPENR,unit,filename,/GET_LUN files=ASSOC(unit,BYTARR(66048)) keep=WHERE(exptimes eq exp) IF keep(0) EQ -1 THEN BEGIN exp=STRTRIM(exp,2) MESSAGE,'This file does not contain any '+exp+' second exposure images!',$ /INFORMATIONAL minim=-1 pixchg=-1 rutsec=-1 RETURN ENDIF ELSE BEGIN rutsec=utsec(keep) nimages=N_ELEMENTS(rutsec) nhh=hh & nmm=mm & nss=ss start=MIN(WHERE(rutsec GE butsec,any_images)) note=butsec-MIN(rutsec) flag=eutsec-MAX(rutsec) IF any_images NE 0 THEN BEGIN finish=MAX(WHERE(rutsec LE eutsec,number)) IF note LT 0 THEN BEGIN start=0 nhh=rutsec(0)/3600L nmm=(rutsec(0)-nhh*3600L)/60L nss=(rutsec(0)-nhh*3600L-nmm*60L) print,'The file chosen does not contain the start time requested.' print,nhh,nmm,nss,FORMAT='("The actual start time is ",I2.2,":",I2.2,":",I2.2,1X,"UT.")' ENDIF IF flag GT 0 THEN BEGIN finish=nimages print,'The file chosen does not span the time interval requested.' ehh=rutsec(finish-1)/3600L emm=(rutsec(finish-1)-ehh*3600L)/60L ess=(rutsec(finish-1)-ehh*3600L-emm*60L) print,nhh,nmm,nss,ehh,emm,ess,$ FORMAT='("The file spans ",2(I2.2,":"),I2.2," to ",2(I2.2,":"),I2.2," UT.")' ENDIF pixchg=FLTARR(finish-start) FOR i=start,finish-1 DO BEGIN file=files(keep(i)) im=BYTE(file,512,256,256) ; If file was renormalized to fit 8 bits, reverse this. IF file(290) GT 0 THEN BEGIN IF file(291) EQ 1 THEN im=LONG(im)*(2^file(290)) IF file(291) EQ 0 THEN im=LONG(im)*file(290) ENDIF wless=WHERE(im LT minim,count) IF wless(0) GE 0 THEN minim(wless)=im(wless) pixchg(i-start)=count ;stop ENDFOR rutsec=rutsec(start:finish-1) ENDIF ELSE BEGIN MESSAGE,'The file chosen does not contain any images from the time requested.',$ /INFORMATIONAL minim=-1 rutsec=-1 pixch=-1 RETURN ENDELSE FREE_LUN,unit ENDELSE RETURN END