PRO update_lists,year,mo,day,path,filelist,timelist,headname ; This sequence of instructions is repeated so often that it makes ; more sense to call it as a subroutine. PRINT,path,FORMAT='(A45,$)' headnames_too=(N_PARAMS() EQ 7) firstchars=['e','a','g','b','c','d','f'] ; 'e' is a dummy type ; Generate a list of filenames flist=FINDFILE(path,COUNT=nflist) IF nflist GT 0 THEN BEGIN ; Get the file start times for the ok files slist=BYTARR(nflist) tlist=FLTARR(nflist) IF headnames_too THEN nlist=STRARR(nflist) FOR j0=0,nflist-1 DO BEGIN rdkihd,flist(j0),hb kih=gethd(hb) ; Check the date first slist(j0)=(kih.misc.dt.year EQ year) AND $ (kih.misc.dt.month EQ mo) AND $ (kih.misc.dt.day EQ day) IF slist(j0) THEN BEGIN ; right month! ; Get the image start time tm=BYTARR(4) FOR j1=0,3 DO tm(j1)=kih.misc.tm.(j1) tlist(j0)=TOTAL(tm*[3600.,60.,1.,.01]) IF headnames_too THEN $ nlist(j0)=STRING(firstchars(kih.misc.exposure_type) $ ,kih.misc.dt.day $ ,kih.misc.cam $ ,kih.misc.fw $ ,kih.misc.exp_scale*kih.exp.exposure/1000L $ ,kih.misc.sequence $ ,FORMAT='(A1,I2.2,2I1,I3.3,".",I3.3)') ENDIF ENDFOR ; Keep only the images acquired in the right month rm=WHERE(slist) IF rm(0) NE -1 THEN BEGIN ; images in the right month flist=flist(rm) tlist=tlist(rm) IF headnames_too THEN nlist=nlist(rm) nflist=N_ELEMENTS(flist) ENDIF ELSE nflist=0 ENDIF ; Append file names and times to the list for the appropriate camera PRINT,nflist,FORMAT='(I4," files")' IF nflist GT 0 THEN BEGIN filelist=[filelist,flist] timelist=[timelist,tlist] IF headnames_too THEN headname=[headname,nlist] ENDIF RETURN END