PRO make_tlog,year,month,day ; ; This procedure creates or appends to ASCII log files of all ; temperature measurements obtained by both units of the Polar ; Camera on the specified day, month, and year. The file is sorted ; by UNIX and stored in the appropriate subdirectory. ; If year GE 100 THEN year=year MOD 100 t=[5,0,2,1,4] nsamples=INTARR(5) ; ; Get list of directories where images might be stored ; OPENR,unit,'/jasper/cnsr3_data1/image.dirs',/GET_LUN READF,unit,subdirs dirs=STRARR(subdirs) READF,unit,dirs CLOSE,unit & FREE_LUN,unit ; ; Open log files for both cameras: OPENU if one exists, OPENW if not ; logpath='/jasper/cnsr3_data1/tlog/' logname=STRARR(2) unit=LONARR(2) FOR i=0,1 DO BEGIN logname(i)=STRING(year,month,day,i,FORMAT='("tlog.",3I2.2,".",I1)') dummy=FINDFILE(logpath+logname(i),COUNT=filefound) IF filefound GT 0 THEN BEGIN OPENU,tmp,logpath+logname(i),/GET_LUN unit(i)=tmp ENDIF ELSE BEGIN OPENW,tmp,logpath+logname(i),/GET_LUN unit(i)=tmp topline='DATE(UT) TIME(UT) FILTER WHEEL INTERNAL DOME EXTERNAL CCD' PRINTF,unit(i),topline topline='yy mm dd hh mm ss max min mean max min mean max min mean max min mean max min mean heater' PRINTF,unit(i),topline ENDELSE ENDFOR ; ; for each directory, get the filenames for the desired day ; FOR i=0,subdirs-1 DO BEGIN template=dirs(i) daystr=STRING(day,FORMAT='(I2.2)') qm=STRPOS(template,'??') STRPUT,template,daystr,qm files='' nfiles=0 FOR j=0,6 DO BEGIN tst=STRING(j,FORMAT='(I2.2,"?.*")') tmp=FINDFILE(template+tst,COUNT=ntmp) IF ntmp NE 0 THEN BEGIN files=[files,tmp] nfiles=nfiles+ntmp ENDIF ENDFOR IF nfiles GT 0 THEN files=files(1:*) ; ; for each file in the list, get the header ; IF nfiles GT 0 THEN BEGIN PRINT,'Processing '+STRTRIM(nfiles,2)+' files '+template FOR j=0,nfiles-1 DO BEGIN rdkihd,files(j),hb KIh=gethd(hb) fdate=KIh.misc.dt rightday=((fdate.day EQ day) AND (fdate.month EQ month) $ AND (fdate.year MOD 100 EQ year)) ; ; If the day, month, and year are right, store the date, time, all ; temperatures, and the heater status in a single line in the log ; file ; IF rightday THEN BEGIN ftime=KIh.misc.tm outstr=STRING(fdate.year MOD 100,fdate.month,fdate.day, $ ftime.hour,ftime.minute,ftime.second, $ FORMAT='(2(3(I2.2," ")," "))') FOR k=0,4 DO BEGIN ftemp=KIh.misc.temp.(t(k)) nsamples(k)=ftemp.num tstr=STRING(ftemp.max/10.,ftemp.min/10.,ftemp.mean/10., $ FORMAT='(3(F5.1," ")," ")') outstr=outstr+tstr ENDFOR outstr=outstr+STRING(KIh.misc.heater/96,FORMAT='(I1)') fcam=KIh.misc.cam IF MAX(nsamples) GT 0 THEN PRINTF,unit(fcam),outstr ENDIF ENDFOR ENDIF ELSE PRINT,'No files match '+template ENDFOR ; ; Close the output files and quit (for now) ; FOR i=0,1 DO BEGIN CLOSE,unit(i) FREE_LUN,unit(i) sortcom=STRING(year,month,day,i, $ FORMAT='("$HOME/scripts/rsort 2 /jasper/cnsr3_data1/tlog/tlog.",3I2.2,".",I1)') SPAWN,sortcom ENDFOR RETURN END