; PROGRAM, dkrate ; This program calculates the dark count accumulation rate and the ; zero-time images. cam=1 ccdt=cam PRINT, 'Enter camera number' READ, cam PRINT,'Enter CCD temperature for desired mean dark images' READ,ccdt path=STRING(cam,cam,ccdt $ ,FORMAT='("/jasper/cnsr3_data1/dk/c",I1,"/dk",I1,".*s.mean.",I3,"C")') flist=FINDFILE(path,COUNT=n) expt=INTARR(n) FOR j=0,n-1 DO BEGIN ts=STRPOS(flist(j),STRING(cam,FORMAT='("dk",I1,".")'))+4 tl=STRPOS(flist(j),"s.mean")-ts expt(j)=FIX(STRMID(flist(j),ts,tl)) ENDFOR expt=expt(SORT(expt)) st = DBLARR(256,256) sts = st smi = st smis = st stmi = st ; summing exposure times and mean images over 1 - 180 second exposures FOR j = 0,n-1 DO BEGIN texp=DOUBLE(expt(j)) time = REPLICATE(texp,256,256) rdmeandk, cam,texp,mi st = st + time sts = sts + time^2 smi = smi + mi smis = smis + LONG(mi)^2 tmp=time*mi hlp,tmp stmi = stmi + time * mi hlp,stmi ENDFOR M=DBLARR(256,256) Q=M P=M corr = M M = n * sts - st^2 Q = n * smis - smi^2 P = n * stmi - smi * st rate = P / M tzero = ((M * FLOAT(smi) - P * st)/(n * M)) corr = P / SQRT(M*Q) rate=rate>0 tzero=tzero>0 TVSCL, tzero<256, 0 TVSCL, tzero<256, 0 TVSCL, rate<10, 1 TVSCL, corr, 2 ; save to 3 appropriately-named files under BYTE format. rname=STRING(cam,cam,ccdt $ ,FORMAT='("/jasper/cnsr3_data1/dk/c",I1,"/dk",I1,".rate.",I3,"C")') OPENW,unit,rname,/GET_LUN brate = BYTE((200 * rate)+0.5) WRITEU,unit,brate CLOSE,unit FREE_LUN,unit zname=STRING(cam,cam,ccdt $ ,FORMAT='("/jasper/cnsr3_data1/dk/c",I1,"/dk",I1,".bias.",I3,"C")') OPENW,unit,zname,/GET_LUN btz=BYTE(tzero + .5) WRITEU,unit,btz CLOSE,unit FREE_LUN,unit cname = STRING(cam,cam,ccdt $ ,FORMAT='("/jasper/cnsr3_data1/dk/c",I1,"/dk",I1,".corr.",I3,"C")') OPENW,unit,cname,/GET_LUN bcorr = BYTE((128 * corr) + 0.5) WRITEU,unit,bcorr END