; FixC0.PRO ; ; create byte-valued input parameters cam=0B & filt=cam & day=28B & month=10B !ORDER=1 & WINDOW,0,XSIZE=256,YSIZE=256 & loadct,23 PRINT,'This routine lets you "fix" the dirty Camera 0 images.' PRINT,'Enter the filter desired' READ,filt ; Create image and dark frame file path names dir=STRING(cam,filt,FORMAT='("c",I1,"f",I1,"/")') files =FINDFILE(dir+'a'+STRTRIM(FIX(day),2)+'*.0*') nfiles=N_ELEMENTS(files) ddir=STRING(cam,FORMAT='("c",I1,"dk/")') dfiles =FINDFILE(ddir+'d'+STRTRIM(FIX(day),2)+'*.0*') ndfiles=N_ELEMENTS(dfiles) ; read in each image, subtract dark frame, and accumulate 'minimum' image minim=INTARR(256,256)+16383 FOR i=0B,nfiles-1 DO BEGIN rdkimg,files(i),h,im gettime,h,date,time utsecs=TOTAL(time*[3600,60,1,.01]) ; find closest dark frame id=-1 mindif=86400. thisdif=80000. WHILE ((thisdif LT mindif) AND (id+1 LT ndfiles)) DO BEGIN IF thisdif LT mindif THEN mindif=thisdif id=id+1 rdkihd,dfiles(id),dh gettime,dh,ddate,dtime dutsecs=TOTAL(dtime*[3600,60,1,.01]) thisdif=ABS(dutsecs-utsecs) ENDWHILE IF thisdif GT mindif THEN id=id-1 rdkimg,dfiles(id),dh,dkimg dkimg=cleanmod(dkimg,2,2,2) ; subtract dark frame im=(im-dkimg)>0 ; compute new 'minimum' image wless=WHERE(im LT minim) IF wless(0) GE 0 THEN minim(wless)=im(wless) TVSCL,minim,0 PRINT,STRING(i+1,nfiles, $ FORMAT='(I2," of ",I2," images processed...")') ENDFOR ; save 'minimum' image for given camera minim=FIX(minim) ; convert to short integers out=dir+'a'+STRING(day,cam,filt,FORMAT='(I2,I1,I1,"060.min")') wrkimg,out,BYTARR(512),minim ; write out a dummy header END