PRO bitdist2,orb,id,cam path=-1 REPEAT BEGIN path=path+1 rdimg2,path,orb,id,header,img0,img1,status IF status EQ 1 THEN BEGIN IF cam EQ 0 THEN img=img0 ELSE img=img1 ENDIF s=SIZE(img) n=s(s(0)+2) ENDREP UNTIL (n GT 1) OR (path EQ 2) IF n LE 1 THEN RETURN multi=(!P.MULTI(1) GT 0) OR (!P.MULTI(2) GT 0) csz=1./(1+multi) gain=25*2^((header(8+cam) AND 6)/2) width=4*(gain/25)+1 print,gain,width width=2^(((header(8+cam) AND 6)/2)+2)+1 print,width stop b=INTARR(8) sb=b h=HISTOGRAM(img,MIN=0,BIN=1,MAX=255) FOR j=0,255 DO BEGIN FOR k=0,7 DO sb(k)=(j AND 2^k)/2^k b=b+h(j)*sb ENDFOR b=1.*b/n PLOT,b,XTITLE='Bit Number (MSB=7)',YTITLE='Fraction of Pixels where Bit Set' $ ,TITLE=STRING(orb,id,FORMAT='("Orbit ",I3,", Image ",F6.3)') $ ,PSYM=10,XRANGE=[7.5,-0.5],XSTYLE=1,YRANGE=[0,1] PLOTS,[-0.5,0.0],[b(0),b(0)] PLOTS,[7.0,7.5],[b(7),b(7)] sb=INTARR(8) ssb=sb sh=SMOOTH(h,width) FOR j=0,255 DO BEGIN FOR k=0,7 DO ssb(k)=(j AND 2^k)/2^k sb=sb+sh(j)*ssb ENDFOR sb=1.*sb/n OPLOT,sb,PSYM=10,LINESTYLE=1 PLOTS,[-0.5,0.0],[sb(0),sb(0)],LINESTYLE=1 PLOTS,[7.0,7.5],[sb(7),sb(7)],LINESTYLE=1 gh=(b GT sb) XYOUTS,BINDGEN(8),b-0.03+0.04*gh,STRING(b,FORMAT='(F5.3)') $ ,ALIGNMENT=0.5,CHARSIZE=csz PLOTS,[7.0,6.5],[0.93,0.93] XYOUTS,6.4,0.92,'Bit distribution of raw image',CHARSIZE=csz XYOUTS,BINDGEN(8),sb+0.01-0.04*gh,STRING(sb,FORMAT='(F5.3)') $ ,ALIGNMENT=0.5,CHARSIZE=csz PLOTS,[7.0,6.5],[0.88,0.88],LINESTYLE=1 XYOUTS,6.4,0.87,CHARSIZE=csz,'Histogram smoothed by running' XYOUTS,6.4,0.84,CHARSIZE=csz,STRING(width,FORMAT='(I2,"-DN boxcar")') spike=FIX(ALOG(width)/ALOG(2))+1 ape=TOTAL((sb(0:spike-2)-b(0:spike-2))*2^BINDGEN(spike-2)) pds=(sb(spike)-0.5*(sb(spike+1)+sb(spike-1)));-(b(spike)-0.5*(b(spike+1)+b(spike-1))) ape=ape+pds*2^spike room=N_ELEMENTS(WHERE(b GT 0.2))-1 XYOUTS,room,0.1,'Average probable error due',CHARSIZE=csz XYOUTS,room,0.07,CHARSIZE=csz $ ,'to sticky bit = '+STRING(ape,FORMAT='(F4.1)')+' DN' stop RETURN END