PRO timesort,filelist,day,month,year,numfiles,Jsecs ; ; This procedure takes a list of PoCa image files generated under ; KI, extracts from the header of each file in turn the exposure ; date and time, and creates an auxiliary array of exposure times, ; expressed in Julian seconds (see ~steele/idl/jhuapl/pro/... for ; information about this time unit). The input string array ; 'filelist' is then sorted on the basis of the Julian seconds ; array, and returned to the calling program, along with the number ; of elements in 'filelist.' ; ; It also returns to the calling program only those file names ; corresponding to files created on the specified date. ; ; first get needed auxiliary information initialize,filters,months,days,modes,mpaths,firstchars okfiles='' ; define type tags onto which to concatenate Jsecs=0.0D0 ; acceptable filenames and Julian seconds FOR i=0,numfiles-1 DO BEGIN rdkihd,filelist(i),h KIh=gethd(h) fday=KIh.misc.dt.day fmonth=KIh.misc.dt.month fyear=KIh.misc.dt.year IF (day EQ fday) AND (month EQ fmonth) AND (year EQ fyear) THEN BEGIN okfiles=[okfiles,filelist(i)] ; add this filename to the OK list dt_tm=STRING(days(KIh.misc.dt.dayofweek), $ ; make the date_ months(KIh.misc.dt.month-1), $ ; time string KIh.misc.dt.day,KIh.misc.tm.hour, $ KIh.misc.tm.minute,KIh.misc.tm.second, $ KIh.misc.dt.year, $ FORMAT='(A3,1X,A3,1X,I2,1X,I2.2,":",I2.2,":",I2.2,1X,I4)') Jsecs=[Jsecs,dt_tm_tojs(dt_tm)] ; add the Julian second to the list ENDIF ENDFOR IF N_ELEMENTS(okfiles) GT 1 THEN BEGIN okfiles=okfiles(1:*) ; drop the null string ('') at the front Jsecs=Jsecs(1:*) ; drop the 0.0D0 at the front filelist=okfiles(SORT(Jsecs)) ; sort based on Jsecs numfiles=N_ELEMENTS(filelist) ; number of filenames returned ENDIF ELSE numfiles=0 RETURN END