PRO checkhead,yr,mo,day ; ; This procedure should be run after image files are created from ; a backup set on a DAT tape. It generates two files in ; /jasper/cnsr3_data1/ilist, containing time-ordered lists of images ; acquired by the two PoCa cameras. These lists can then be used ; to select time sequences of images for display. ; ; Algorithm: ; For each camera: ; For each image type: ; For each filter: ; Create the file name template ; Generate a list of files with FINDFILE ; Create a corresponding list of image start UTs with ; rdkihd and gethd ; Concatenate the file list to the master list for this camera ; Concatenate the time list to the master list for this camera ; For each camera: ; Generate the sorting array for each master time list ; Use it to sort the image times and file names ; Store the sorted lists in an ASCII file: time filename ; Done ; ; Set up preliminaries ; root='/jasper/cnsr3_data1' imagetype=['aur','bias','cal','dk','flat','air'] filestart=['a','b','c','d','f','g'] filelist0='' filelist1='' timelist0=0. timelist1=0. headname0='' headname1='' year=yr IF year LT 1900 THEN year=FIX(1900+year) ; FOR i0=0,1 DO BEGIN ; loop through cameras FOR i1=0,N_ELEMENTS(imagetype)-1 DO BEGIN ; loop through image types rt=root+'/'+imagetype(i1) rtc=rt+'/'+STRING(i0,FORMAT='("c",I1)') ; Create the file name template IF (i1 NE 1) AND (i1 NE 3) THEN BEGIN ; 'aur','cal','flat','air' FOR i2=0,4 DO BEGIN ; loop through filters IF i1 NE 0 THEN BEGIN ; 'cal','flat','air' path=rtc+STRING(i2,filestart(i1),day,i0,i2 $ ,FORMAT='("/f",I1,"/",A1,I2.2,2I1,"???.*")') IF i0 EQ 0 $ THEN update_lists,year,mo,day,path,filelist0,timelist0,headname0 $ ELSE update_lists,year,mo,day,path,filelist1,timelist1,headname1 ENDIF ELSE BEGIN ; 'aur' FOR i3=0,6 DO BEGIN path=rtc+STRING(i2,day,i0,i2,i3 $ ,FORMAT='("/f",I1,"/a",I2.2,2I1,"0",I1,"?.*")') IF i0 EQ 0 $ THEN update_lists,year,mo,day,path,filelist0,timelist0,headname0 $ ELSE update_lists,year,mo,day,path,filelist1,timelist1,headname1 ENDFOR ENDELSE ENDFOR ENDIF ELSE BEGIN ; 'bias','dark' path=rtc+STRING(filestart(i1),day,i0 $ ,FORMAT='("/",A1,I2.2,I1,"????.*")') IF i0 EQ 0 $ THEN update_lists,year,mo,day,path,filelist0,timelist0,headname0 $ ELSE update_lists,year,mo,day,path,filelist1,timelist1,headname1 ENDELSE ENDFOR ENDFOR ; If no files found, tell the user and delete any outdated image list files IF (N_ELEMENTS(filelist0) EQ 1) AND $ (N_ELEMENTS(filelist1) EQ 1) THEN BEGIN MESSAGE,'No files found for this date!' date=STRING(year,mo,day,FORMAT='(3I2.2)') ilname='/jasper/cnsr3_data1/ilist/'+date+'.0.ilist' il=FINDFILE(ilname,COUNT=nil) IF nil GT 0 THEN BEGIN cmd='rm '+ilname SPAWN,cmd ENDIF ilname='/jasper/cnsr3_data1/ilist/'+date+'.1.ilist' il=FINDFILE(ilname,COUNT=nil) IF nil GT 0 THEN BEGIN cmd='rm '+ilname SPAWN,cmd ENDIF RETURN ENDIF ; Drop the dummy entries at the front of the arrays IF N_ELEMENTS(filelist0) GT 1 THEN BEGIN filelist0=filelist0(1:*) timelist0=timelist0(1:*) headname0=headname0(1:*) n0=N_ELEMENTS(filelist0) ENDIF ELSE n0=0 IF N_ELEMENTS(filelist1) GT 1 THEN BEGIN filelist1=filelist1(1:*) timelist1=timelist1(1:*) headname1=headname1(1:*) n1=N_ELEMENTS(filelist1) ENDIF ELSE n1=0 PRINT,n0,n1,FORMAT='("Total ",I4," camera 0 images, ",I4," camera 1 images.")' ; Now sort the arrays for each camera ; First do Camera 0 IF n0 GT 0 THEN BEGIN ts0=SORT(timelist0) filelist0=filelist0(ts0) timelist0=timelist0(ts0) headname0=headname0(ts0) ENDIF ; Then do Camera 1 IF n1 GT 0 THEN BEGIN ts1=SORT(timelist1) filelist1=filelist1(ts1) timelist1=timelist1(ts1) headname1=headname1(ts1) ENDIF ; Now check whether there are any mismatches between actual and ; correct file names. mismatch0=REPLICATE(' ',n0) mismatch1=REPLICATE(' ',n1) FOR k0=0,n0-1 DO BEGIN actual=STRMID(filelist0(k0),STRLEN(filelist0(k0))-12,12) IF actual NE STRTRIM(headname0(k0),2) THEN mismatch0(k0)='X' ENDFOR FOR k1=0,n1-1 DO BEGIN actual=STRMID(filelist1(k1),STRLEN(filelist1(k1))-12,12) IF actual NE STRTRIM(headname1(k1),2) THEN mismatch1(k1)='X' ENDFOR ; Now output the arrays to files, first Camera 0, then Camera 1 IF n0 GT 0 THEN BEGIN name0=STRING(root,year MOD 100,mo,day $ ,FORMAT='(A19,"/ilist/",3I2.2,".0.check")') OPENW,unit,name0,/GET_LUN FOR k0=0,n0-1 DO PRINTF,unit,timelist0(k0),filelist0(k0),headname0(k0) $ ,mismatch0(k0),FORMAT='(F8.2,2X,A45,2X,A12,2X,A1)' CLOSE,unit FREE_LUN,unit PRINT,name0+' created.' ENDIF IF n1 GT 0 THEN BEGIN name1=STRING(root,year MOD 100,mo,day $ ,FORMAT='(A19,"/ilist/",3I2.2,".1.check")') OPENW,unit,name1,/GET_LUN FOR k1=0,n1-1 DO PRINTF,unit,timelist1(k1),filelist1(k1),headname1(k1) $ ,mismatch1(k0),FORMAT='(F8.2,2X,A45,2X,A12,2X,A1)' CLOSE,unit FREE_LUN,unit PRINT,name1+' created.' ENDIF ; I think we're done! RETURN END