PRO cleanup,year,month,day,force=force date=STRING(year MOD 100,month,day,FORMAT='(3I2.2)') ; Have quick-look data files been produced yet? qlfound=FINDFILE('/jasper/cnsr3_data1/ql/'+date+'*.ql',COUNT=nql) IF nql EQ 0 THEN BEGIN MESSAGE,'Make quick-look data files first!',/INFORMATIONAL RETURN ENDIF ; Do quick-look data files contain data from the files currently ; on disk? rdilist,0,year,month,day,0,0,0,nfiles,filetimes,filenames IF nfiles GT 0 THEN BEGIN ; Reject 'cal', 'non', and 'dk' images from imagelist before ; comparing time spans calfiles=WHERE(STRPOS(filenames,'cal') NE -1) goodfiles=setminus(INDGEN(nfiles),calfiles) nonfiles=WHERE(STRPOS(filenames,'No_') NE -1) goodfiles=setminus(goodfiles,nonfiles) dkfiles=WHERE(STRPOS(filenames,'dk') NE -1) goodfiles=setminus(goodfiles,dkfiles) filetimes=filetimes(goodfiles) rdcols,'/jasper/cnsr3_data1/ql/'+date+'02.ql',n,qlt,qli,qlsd PRINT,MIN(filetimes,MAX=maxft),maxft $ ,FORMAT='("Files on disk cover ",2F9.1," s UT")' PRINT,MIN(qlt,MAX=maxqt),maxqt $ ,FORMAT='("Quick-look files cover",2F9.1," s UT")' ql_done=((MIN(qlt)-MIN(filetimes) LT 40) AND $ (MAX(qlt)-MAX(filetimes) GT 0)) ; If not all data represented in quick-look files, and user wants ; to know about it, prompt for decision on cleaning up. IF NOT KEYWORD_SET(force) THEN BEGIN IF NOT ql_done THEN BEGIN PRINT,'Do you still want to remove the image files for '+date+' from disk? (Y/[N])' resp='' READ,resp IF STRUPCASE(resp) NE 'Y' THEN RETURN ENDIF ENDIF ENDIF ELSE BEGIN MESSAGE,'No image list files found; going ahead in case files exist' $ ,/INFORMATIONAL ENDELSE ; Quick-look data files are up to date; go ahead with cleanup PRINT,'Making image lists for '+date wrilist,year,month,day ; Copy image list for future reference ilistname=STRING(year MOD 100,month,day $ ,FORMAT='("/jasper/cnsr3_data1/ilist/",3I2.2,".2.ilist")') SPAWN,'/usr/bsd43/bin/cp '+ilistname+' '+ilistname+'.f' ; If a gzipped image list already exists for this date, compare ; the number of lines in the two lists, and retain the longer list. oldfile=FINDFILE(ilistname+'.f.gz',COUNT=noldfile) IF noldfile EQ 1 THEN BEGIN ; Count the number of lines in the new file... SPAWN,'wc -l '+ilistname+'.f',newlen newlines=FIX(newlen(0)) ; and the old file SPAWN,'gzcat '+ilistname+'.f.gz | wc -l',oldlen oldlines=FIX(oldlen(0)) IF newlines GT oldlines THEN BEGIN SPAWN,'/usr/bsd43/bin/rm '+ilistname+'.f.gz' SPAWN,'/usr/local/bin/gzip -v '+ilistname+'.f' ENDIF ELSE SPAWN,'/usr/bsd43/bin/rm '+ilistname+'.f' ENDIF ELSE SPAWN,'/usr/local/bin/gzip -v '+ilistname+'.f' PRINT,'Reading image lists for '+date kill_list='' il=FINDFILE('/jasper/cnsr3_data1/ilist/'+date+'.?.ilist',COUNT=nil) IF nil NE 0 THEN BEGIN FOR cam=0,1 DO BEGIN rdilist,cam,year,month,day,0,0,0,nfiles,times,names goodfile=WHERE(STRPOS(names,'___') EQ -1) IF MAX(goodfile) GE 0 THEN kill_list=[kill_list,names(goodfile)] ENDFOR ENDIF IF N_ELEMENTS(kill_list) GT 1 THEN BEGIN kill_list=kill_list(1:N_ELEMENTS(kill_list)-1) kill_list='rm '+kill_list PRINT,'Writing image deletion script for '+date rmname='/jasper/cnsr3_data1/rm'+date OPENW,outunit,rmname,/GET_LUN PRINTF,outunit,'#! /bin/csh -f' PRINTF,outunit,' ' FOR i=0,N_ELEMENTS(kill_list)-1 DO PRINTF,outunit,kill_list(i) CLOSE,outunit FREE_LUN,outunit chmodcmd='chmod 0700 '+rmname SPAWN,chmodcmd PRINT,'Deleting images from '+date SPAWN,'/usr/net/rsh smith '+rmname PRINT,'Checking whether script worked' wrilist,year,month,day PRINT,'Deleting script' SPAWN,'rm '+rmname ENDIF ELSE BEGIN MESSAGE,'No image files found for '+date+'!',/INFORMATIONAL ENDELSE RETURN END