PRO js_stats,files,time,newfiles ;This procedure is used sort darkfiles. The directory path and file ;name must be entered in quatations ;(i.e pathfiles = 'c:\....\filename(s)'). If the path is of the form ; c:\images\dark\cam0(1)\ , then the procedure will look for files ; with filenames of the form, ???...time.??? , where 'time' is a ;two digit integer. If no time is specified then by default time=60. ;If the files are of the form, c:\images\dark\cam0(1)\???...time.??? ;then they are files created from dark exposure of the CCD. From these ;files the year,month,day and seconds in to the day at which the dark ;files was aquired is taken. Using a procedure called ;'ymds2js(year,month,day,second)' the date and time at which the dark ;file was aquired is changed into Julian Seconds. This provides ;a convinient number to associate with the darkfiles. These numbers ;are stored in a file named, c:\idl\data\dark\julian0(1).sts. Each time the ;procedure is run it check all the Julian Seconds from the new files ;,assuming they are of the right type, against the one stored in ;the in the file julian0(1).sts.Only the files that have dates ;in Julian Seconds, which are not in the file julian0(1).sts ;will have their filenames returned in the STRING of names 'newfiles'. ;This procedure is exactly the same as 'julian.pro', except that ;'julian.pro' writes to the files c:\idl\data\dark\julian0(1).drk. This ;is done because julian.pro is used in average.pro to check for ;new darkfiles, while js_stats.pro is used in the procedure drk_stats.pro ;to check for new darkfiles. To keep the darkfiles used by each procedure ;seperate, js_stats.pro and julian.pro where created. in=expose(files,time) camnum=STRMID(files(0),18,1) CASE camnum OF '0':BEGIN infiles=FINDFILE('c:\idl\data\dark\julian0.sts',count=count0) IF count0 NE 1 THEN BEGIN OPENW,unit,'C:\idl\data\dark\julian0.sts',/GET_LUN initial=ASSOC(unit,DBLARR(1)) initial(0)=[0] CLOSE,unit FREE_LUN,unit ENDIF OPENR,unit,'C:\idl\data\dark\julian0.sts',/GET_LUN filestat=FSTAT(unit) number=filestat.size/8 julsec=DBLARR(number) READU,unit,julsec CLOSE,unit FREE_LUN,unit newfiles=[''] FOR i=0, N_ELEMENTS(in)-1 DO BEGIN rdkihd,in(i),header Kih=gethd(header) year=Kih.misc.dt.year month=FIX(Kih.misc.dt.month) day=FIX(Kih.misc.dt.day) second=FIX(Kih.misc.tm.hour)*3600. + FIX(Kih.misc.tm.minute)*60. +$ FIX(kih.misc.tm.second) js=ymds2js(year,month,day,second) dummy=WHERE(Julsec EQ js,label) IF label EQ 0 THEN BEGIN julsec=[julsec,js] newfiles=[newfiles,in(i)] ENDIF ENDFOR IF N_elements(newfiles) GT 2 THEN BEGIN newfiles=newfiles(1:*) OPENW,unit,'C:\idl\data\dark\julian0.sts',/GET_LUN WRITEU,unit,julsec CLOSE,unit FREE_LUN,unit ENDIF ELSE BEGIN OPENW,unit,'C:\idl\data\dark\julian0.sts',/GET_LUN WRITEU,unit,julsec CLOSE,unit FREE_LUN,unit ENDELSE END '1':BEGIN infiles=FINDFILE('c:\idl\data\dark\julian1.sts',count=count1) IF count1 NE 1 THEN BEGIN OPENW,unit,'C:\idl\data\dark\julian1.sts',/GET_LUN initial=ASSOC(unit,DBLARR(1)) initial(0)=[0] CLOSE,unit FREE_LUN,unit ENDIF OPENR,unit,'C:\idl\data\dark\julian1.sts',/GET_LUN filestat=FSTAT(unit) number=filestat.size/8 julsec=DBLARR(number) READU,unit,julsec CLOSE,unit FREE_LUN,unit newfiles=[''] FOR i=0, N_ELEMENTS(in)-1 DO BEGIN rdkihd,in(i),header Kih=gethd(header) year=Kih.misc.dt.year month=FIX(Kih.misc.dt.month) day=FIX(Kih.misc.dt.day) second=FIX(Kih.misc.tm.hour)*3600. + FIX(Kih.misc.tm.minute)*60. +$ FIX(kih.misc.tm.second) js=ymds2js(year,month,day,second) dummy=WHERE(Julsec EQ js,label) IF label EQ 0 THEN BEGIN julsec=[julsec,js] newfiles=[newfiles,in(i)] ENDIF ENDFOR IF N_elements(newfiles) GE 2 THEN BEGIN newfiles=newfiles(1:*) OPENW,unit,'C:\idl\data\dark\julian1.sts',/GET_LUN WRITEU,unit,julsec CLOSE,unit FREE_LUN,unit ENDIF ELSE BEGIN OPENW,unit,'C:\idl\data\dark\julian1.sts',/GET_LUN WRITEU,unit,julsec CLOSE,unit FREE_LUN,unit ENDELSE END ELSE:BEGIN MESSAGE, 'None of the files are from camera 0 or 1.',$ /INFORMATIONAL newfiles=[''] END ENDCASE END