; ROOFGLOW.PRO ; ; Originally written to show images from Polar Camera initial field test ; at Ryning Farm Observatory ; Modified 1993/1/29 by DPS to handle images from image tree structure ; on /jasper/cnsr3_data1 ; Modified 16 July 1993 from show.pro ; ; create byte-valued input parameters mask=BYTARR(256,256) ; load various string-valued arrays needed s='' !ORDER=1 ; set colour table loadct,13 ; ask user for factors by which to multiply background image before ; subtracting it PRINT,'Enter background reduction factors for the OH Q and R branch images' PRINT,'(default values are 0.04 for Q, 0.044 for R; press if ok)' fac='' READ,fac f=isnumber(fac,fq) IF f NE 0 THEN BEGIN IF f GT 0 $ THEN fr=0.044 $ ELSE BEGIN f=isnumber(getwrd(fac,1),fr) IF f EQ 0 THEN fr=0.044 ENDELSE ENDIF ELSE BEGIN fq=0.04 fr=0.044 ENDELSE ; Prompt user for fixed saturation brightness PRINT,'If you want to assign the top of the color bar to a fixed number of counts,' PRINT,'enter that number now, otherwise enter anything else for auto-scaling.' tops='' READ,tops flag=isnumber(tops,topnum) ; topnum=0 if tops doesn't represent a number ; create title for image plot wtitle='Polar Camera OH Filter Images, 14 July 1993, Science B Roof' ; define mask for images, with fixed horizon at 150 superpixels prad=150 d256=SHIFT(dist(256),128,128) & base=WHERE(d256 GT 150) wprad=WHERE(d256 LE prad) & mask(wprad)=1 ; define paths to desired images ohrpath='/jasper/cnsr3_data1/air/c0/f0/' ohqpath='/jasper/cnsr3_data1/air/c1/f0/' bgdpath='/jasper/cnsr3_data1/air/c1/f1/' ; make lists of available files of desired type ohqfiles=FINDFILE(ohqpath+'g14??060.*',COUNT=nohq) ohrfiles=FINDFILE(ohrpath+'g14??060.*',COUNT=nohr) bgdfiles=FINDFILE(bgdpath+'g14??060.*',COUNT=nbgd) ; keep only valid images ohqfiles=ohqfiles(5:*) & nohq=nohq-5 ohrfiles=ohrfiles(5:*) & nohr=nohr-5 bgdfiles=bgdfiles(5:*) & nbgd=nbgd-5 ; ensure file names are sorted chronologically and return UT seconds also timesort,ohqfiles,14,7,1993,nohq,ohqJsecs timesort,ohrfiles,14,7,1993,nohr,ohrJsecs timesort,bgdfiles,14,7,1993,nbgd,bgdJsecs ; read approximate dark frames rdmeandk,0,60,dk0 rdmeandk,1,60,dk1 inf=0 inl=nohq-1 ; create and label image display window X_charheight=10 ; try to keep scalings that apply in X windows X_charwidth=8 barwidth=16 ninrow=4 nincol=3 ninwin=ninrow*nincol edge=256 wwidth=ninrow*edge+barwidth wheight=nincol*edge+4*X_charheight IF !D.NAME EQ 'X' THEN $ WINDOW,0,XSIZE=wwidth,YSIZE=wheight $ ELSE DEVICE,/COLOR,BITS_PER_PIXEL=8 ; PostScript csz=((1.*X_charheight)/wheight)/((1.*!D.Y_CH_SIZE)/!D.Y_VSIZE) ; keep 'X' char size XYOUTS,scl(res=120.,(wwidth-barwidth)/2) $ ,scl(res=120.,wheight-3*X_charheight),wtitle $ ,/DEVICE,ALIGNMENT=0.5,CHARSIZE=2.0*csz,WIDTH=twidthn twidthd=CONVERT_COORD([twidthn,0.],/NORMAL,/TO_DEVICE) twidthd=twidthd(0) ; we only need the x-component ; get user's name and display it SPAWN,'whoami',username XYOUTS,scl(res=120.,wwidth-X_charwidth),scl(res=120.,wheight-3.9*X_charheight) $ ,'User '+STRUPCASE(username),ALIGNMENT=1.0,/DEVICE,CHARSIZE=csz ; get date/time and display them SPAWN,'date -u',datetime XYOUTS,scl(res=120.,wwidth-X_charwidth),scl(res=120.,wheight-2.5*X_charheight) $ ,STRMID(datetime,11,9)+' UT',ALIGNMENT=1.0,/DEVICE,CHARSIZE=csz XYOUTS,scl(res=120.,wwidth-X_charwidth),scl(res=120.,wheight-1.1*X_charheight) $ ,STRMID(datetime,4,7)+STRMID(datetime,24,4),ALIGNMENT=1.0,/DEVICE,CHARSIZE=csz ; create and display color bar bar=REBIN(BINDGEN(256,barwidth),nincol*edge,barwidth) bar=ROTATE(bar,3) mtv,bar,ninrow*edge,0,res=120. ; read in each image, decode the header, subtract dark frame, rebin to ; 256x256 if necessary, scale to 8 bits and display ip=-1 FOR i=inf,inl DO BEGIN rdkimg,ohqfiles(i),hbq,imq & hq=gethd(hbq) rdkimg,ohrfiles(i),hbr,imr & hr=gethd(hbr) rdkimg,bgdfiles(i),hbb,imb & hb=gethd(hbb) ; extract start time of image from header itime=BYTARR(4) FOR itptr=0,3 DO itime(itptr)=hq.misc.tm.(itptr) utsecs=TOTAL(itime*[3600,60,1,.01]) ; subtract approximate dark frames ciq=(imq-dk0)>0 cir=(imr-dk1)>0 cib=(imb-dk1)>0 ; approximately subtract background image diq=(ciq-fq*cib)>0 dir=(cir-fr*cib)>0 ; do median smoothing on difference images si=INTARR(2*edge,edge) si(0,0)=MEDIAN(diq,3) si(edge,0)=MEDIAN(dir,3) IF MAX(si) LE 255 THEN si=BYTE(si) FOR j=0,1 DO BEGIN ; first display Q branch image, then R branch im=si(j*edge:j*edge+255,*) ; If autoscaling is desired, find lmaxi, otherwise use topnum IF topnum EQ 0 THEN BEGIN ; Identify useful min and max values for byte-scaling ih=HISTOGRAM(im(wprad),MIN=0,BIN=1) ; histogram of exposed image ihc=ih ; next line computes cumulative pixel value pdf FOR jj=1,N_ELEMENTS(ihc)-1 DO ihc(jj)=ihc(jj)+ihc(jj-1) ihc=ihc/FLOAT(MAX(ihc)) ; normalize to unity lmaxi=MAX(WHERE(ihc LE .999)) ; top 0.1% of pixels saturate ENDIF ELSE lmaxi=topnum lmaxbh=0 ip=ip+1 ; index number for screen position of image ; show image orientation, one time only IF ip EQ 0 THEN BEGIN azrad=0 ; plot arrows showing the azimuth leftend=scl(res=120.,wwidth/2.)-twidthd/2. maxlen=(leftend-scl(res=120.,1.5*X_charwidth)) $ /scl(res=120.,(COS(azrad)+SIN(azrad))*X_charheight) arlen=MIN([FIX(maxlen),4])*X_charheight tailx=REPLICATE(scl(res=120.,0.5*X_charwidth+SIN(azrad)*arlen),2) taily=REPLICATE(scl(res=120.,nincol*edge),2) headx=[tailx(0)-scl(res=120.,arlen*SIN(azrad)), $ tailx(1)+scl(res=120.,arlen*COS(azrad))] heady=[scl(res=120.,nincol*edge+arlen*COS(azrad)), $ scl(res=120.,nincol*edge+arlen*SIN(azrad))] arrow,tailx,taily,headx,heady,/device,hsize=-0.2 XYOUTS,headx(0)+scl(res=120.,X_charwidth) $ ,MIN([heady(0),scl(res=120.,wheight-X_charheight)]) $ ,'N',ALIGNMENT=0,/DEVICE,CHARSIZE=csz XYOUTS,headx(1)+scl(res=120.,X_charwidth),heady(1),'E' $ ,ALIGNMENT=0.5,/DEVICE,CHARSIZE=csz ENDIF ; display the image mtv,ROTATE(im*mask,5),low=lmaxbh,high=lmaxi,res=120. $ ,(ip MOD ninrow)*edge,(nincol-1-(ip MOD ninwin)/ninrow)*edge ; mtv,im*mask,low=lmaxbh,high=lmaxi,res=120. $ ; ,(ip MOD ninrow)*edge,(nincol-1-(ip MOD ninwin)/ninrow)*edge ; display image sequence number XYOUTS,scl(res=120.,(ip MOD ninrow)*edge+1) $ ,scl(res=120.,(nincol-(ip MOD ninwin)/ninrow)*edge-1-X_charheight) $ ,STRING(j,extension(ohqfiles(i)),FORMAT='(I1,"0:",A3)') $ ,/DEVICE,ALIGNMENT=0.0 $ ,CHARSIZE=csz,COLOR=0.8*!D.N_COLORS ; and image time XYOUTS,scl(res=120.,(ip MOD ninrow)*edge+1) $ ,scl(res=120.,(nincol-1-(ip MOD ninwin)/ninrow)*edge+3+X_charheight) $ ,/DEVICE,ALIGNMENT=0.0,CHARSIZE=csz,COLOR=0.8*!D.N_COLORS $ ,STRING(itime(0:2),FORMAT='(I2.2,":",I2.2,":",I2.2)') ; and exposure time XYOUTS,scl(res=120.,(ip MOD ninrow)*edge+1) $ ,scl(res=120.,(nincol-1-(ip MOD ninwin)/ninrow)*edge+1) $ ,STRING(hr.misc.exp_scale*hr.exp.exposure/1000. $ ,FORMAT='(F5.1,1X,"s")'),/DEVICE,ALIGNMENT=0.0,CHARSIZE=csz $ ,COLOR=0.8*!D.N_COLORS ; and maximum displayed DN XYOUTS,scl(res=120.,((ip MOD ninrow)+1)*edge-1) $ ,scl(res=120.,(nincol-(ip MOD ninwin)/ninrow)*edge-1-X_charheight) $ ,STRING(FIX(lmaxi),FORMAT='("< ",I0.0," DN")') $ ,/DEVICE,ALIGNMENT=1.0,CHARSIZE=csz,COLOR=0.8*!D.N_COLORS ; and minimum displayed DN XYOUTS,scl(res=120.,((ip MOD ninrow)+1)*edge-1) $ ,scl(res=120.,(nincol-1-(ip MOD ninwin)/ninrow)*edge+1) $ ,STRING(FIX(lmaxbh),FORMAT='("> ",I0.0," DN")'),/DEVICE $ ,ALIGNMENT=1.0,CHARSIZE=csz,COLOR=0.8*!D.N_COLORS PRINT,'.',FORMAT='(A,$)' IF (ip+1) MOD ninwin EQ 0 THEN PRINT,'|',FORMAT='(A,$)' IF GET_KBRD(1) EQ 'q' THEN GOTO,DONE ENDFOR ENDFOR DONE: PRINT,'' END