PRO checkrat,year,month,day,hour,minute,second $ ,subtract=subtract,interactive=interactive ; All variables entered? IF N_PARAMS() LT 6 THEN BEGIN PRINT,'Usage: checkrat,year,month,day,hour,nminute,second' RETURN ENDIF ; Open a plotting window WINDOW,0,XSIZE=512,YSIZE=512 out=INTARR(512,256) ; load map of sky-viewing pixels mask=BYTARR(128,128) OPENR,sky,'~cnsr3/941202_0.sky',/GET_LUN READU,sky,mask FREE_LUN,sky ; load image lists rdilist,2,year,month,day,hour,minute,second,n,t,f ; delete any calibration images from lists keep=WHERE((STRPOS(f(0,*),'cal') EQ -1) AND $ (STRPOS(f(1,*),'cal') EQ -1)) n=N_ELEMENTS(keep) t=t(*,keep) f=f(*,keep) ; locate first image pairs of cycles t0=REFORM(t(0,*)) dt=(t0-SHIFT(t0,1))>0 cycle=[0,WHERE(dt GT 70),n] ; seems to work for 60-s images cyclen=(SHIFT(cycle,-1)-cycle) cyclen=cyclen(0:N_ELEMENTS(cyclen)-2) cycle=cycle(0:N_ELEMENTS(cycle)-2) ncycles=N_ELEMENTS(cyclen) ; for each camera, load all the images in the cycle FOR ic=0,ncycles-1 DO BEGIN PRINT,STRSEC(t(0,cycle(ic))) nc=INDGEN(cyclen(ic))+cycle(ic) FOR cc=0,1 DO BEGIN fc=REFORM(f(cc,nc)) ; names of Camera cc images in this cycle rdkimg,fc(0),hb,im,/verb,/nofix hbs=BYTARR(512,cyclen(ic)) ; create header byte storage array hbs(0,0)=hb ; and store first image header bytes s0=SIZE(im) cols=s0(1) rows=s0(2) ims=INTARR(cols,rows,cyclen(ic)); create image storage array ims(0,0,0)=im ; and store first image FOR jc=1,cyclen(ic)-1 DO BEGIN rdkimg,fc(jc),hb,im,/verb,/nofix ; read succeeding images in cycle hbs(0,jc)=hb ; and store header bytes ims(0,0,jc)=im ; and images ENDFOR ; check that the first image was copied to all subsequent images FOR jc=0,cyclen(ic)-1 DO BEGIN ndiff=LONG(TOTAL(ims(*,rows/4:rows-1,jc) $ NE ims(*,rows/4:rows-1,0))) IF ndiff GT 0 THEN $ PRINT,ic,cc,jc,ndiff $ ,FORMAT='("Cycle ",I3,", camera ",I1,", image ",' $ +'I1," - image 0: ",I0," different pixels")' ENDFOR ; determine the average ratio between the third and first 630.0 nm images ; (Camera 0 only) IF cc EQ 0 THEN BEGIN c0f2=WHERE(STRPOS(fc,'02060') NE -1,nc0f2) IF nc0f2 GT 1 THEN BEGIN IF KEYWORD_SET(subtract) $ THEN ims(*,*,c0f2(1))=ims(*,*,c0f2(1))-ims(*,*,c0f2(0)) tmp=LONG(REBIN(REFORM(ims(*,0:rows/4-1,c0f2(1)),cols/2,rows/2) $ ,cols,rows,/SAMPLE)) lim0=pcentile(ims(*,*,0),[0.01,0.99]) lim2=pcentile(tmp,[0.01,0.99]) hist0=[0L,HISTOGRAM(ims(*,*,0)*mask,MIN=1,BIN=1,MAX=lim0(1))] pv0=MAX(hist0,pk0) hist2=[0L,HISTOGRAM(tmp*mask,MIN=1,BIN=1,MAX=lim2(1))] pv2=MAX(hist2,pk2) PRINT,"Ratio of most probable values (2nd/1st) is " $ ,FLOAT(pk2)/pk0,FORMAT='(A,F5.3)' rat=FLOAT(tmp)/FLOAT(ims(*,*,0)) rhist=[0L,HISTOGRAM(mask*rat,MIN=0.01,MAX=10,BIN=0.01)] mhist=MAX(rhist,loc) xlim=ROUND([loc/100.-1,loc/100.+1]) xhist=FINDGEN(1001)*0.01 fit=gaussfit(xhist,rhist,a) r=a(1) PRINT,"Most probable ratio (2nd/1st) is ",r $ ,FORMAT='(A,F5.3)' lims=pcentile(ims(*,*,0),[0.01,0.99]) out(0,0)=ROTATE(REBIN(ims(*,*,0)>lims(0)lims(0)