PRO pair,year,month,day,filter,number0,number1,psres=psres ; This procedure (converted from program SEQ.PRO) plots a single ; pair of simultaneous images from the two Polar Cameras and ; annotates them. ; ; 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 1993/5/11 from SHOW.PRO to display images from both cameras ; in the order they were acquired. ; ; load various string-valued arrays needed initialize,filters,months,days,modes,mpaths,firstchars s='' !ORDER=1 ; set colour table loadct,13 ; uncover screen where text is to be printed IF !D.NAME EQ 'X' THEN WDELETE,0 ; ensure a 4-digit year for display; make reasonable assumptions IF year LT 1900 THEN BEGIN IF year LT 50 THEN year=year+2000 IF year GT 50 THEN year=year+1900 ENDIF ; create titles for image plot wtitle=STRING(year,months(month-1),day $ ,FORMAT='("Polar Camera",2X,I4,1X,A3,1X,I0.2)') ltitle=filters(filter) rtitle=filters(filter+5) ; 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=BYTARR(256,256) mask(wprad)=1 ; read in required files images=INTARR(512,256) headbytes=BYTARR(512,2) exptime=INTARR(2) FOR i=0,1 DO BEGIN path=mpaths(0) IF KEYWORD_SET(number1) THEN BEGIN IF i EQ 0 THEN number=number0 ELSE number=number1 ENDIF ELSE number=number0 fpath=path+STRING(i,filter,day,i,filter,number $ ,FORMAT='("/c",I1,"/f",I1,"/a",I2.2,I1,I1,"???.",I3.3,"*")') files=FINDFILE(fpath,COUNT=nfiles) IF nfiles EQ 0 THEN BEGIN PRINT,'No auroral images found; trying for airglow images...' path=mpaths(5) fpath=path+STRING(i,filter,day,i,filter,number $ ,FORMAT='("/c",I1,"/f",I1,"/a",I2.2,I1,I1,"???.",I3.3)') files=FINDFILE(fpath,COUNT=nfiles) IF nfiles EQ 0 THEN BEGIN PRINT,'No airglow images found either; get your act together!' RETURN ENDIF ENDIF IF nfiles GT 1 THEN BEGIN FOR j=0,nfiles-1 DO PRINT,j,files(j),FORMAT='(I2,2X,A56)' PRINT,'Enter the number of the correct file:' READ,fnum files=files(fnum) ENDIF rdkimg,files(0),hb,im headbytes(0,i)=hb h=gethd(hb) exptime(i)=h.misc.exp_scale*h.exp.exposure/1000 rdmeandk,i,exptime(i),dkim images(256*i,0)=(im-dkim)>0 ENDFOR ; create and label image display window X_charheight=10 ; try to keep scalings that apply in X windows X_charwidth=8 barwidth=24 ninrow=2 nincol=1 ninwin=ninrow*nincol wwidth=ninrow*256+2*barwidth wheight=nincol*256+5*X_charheight IF NOT KEYWORD_SET(psres) THEN psres=100. 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=psres,(wwidth-2*barwidth)/2) $ ,scl(res=psres,wheight-8.*X_charheight/3.),wtitle $ ,/DEVICE,ALIGNMENT=0.5,CHARSIZE=1.5*csz,WIDTH=twidthn XYOUTS,scl(res=psres,128) $ ,scl(res=psres,wheight-14.*X_charheight/3.),ltitle $ ,/DEVICE,ALIGNMENT=0.5,CHARSIZE=csz,WIDTH=twidthn XYOUTS,scl(res=psres,384) $ ,scl(res=psres,wheight-14.*X_charheight/3.),rtitle $ ,/DEVICE,ALIGNMENT=0.5,CHARSIZE=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=psres,wwidth) $ ,scl(res=psres,wheight-14.*X_charheight/3.) $ ,'User '+STRUPCASE(username),ALIGNMENT=1.0,/DEVICE $ ,CHARSIZE=0.75*csz ; get date/time and display them SPAWN,'date -u',datetime XYOUTS,scl(res=psres,wwidth) $ ,scl(res=psres,wheight-9.*X_charheight/3.) $ ,STRMID(datetime,11,9)+' UT',ALIGNMENT=1.0,/DEVICE $ ,CHARSIZE=0.75*csz XYOUTS,scl(res=psres,wwidth) $ ,scl(res=psres,wheight-4.*X_charheight/3.) $ ,STRMID(datetime,4,7)+STRMID(datetime,24,4),ALIGNMENT=1.0 $ ,/DEVICE,CHARSIZE=0.75*csz ; create and display color bar bar=BINDGEN(256,barwidth) bar=ROTATE(bar,3) mtv,bar,ninrow*256+barwidth,0,res=psres ; scale each image to 8 bits and display itime=BYTARR(4) FOR i=0,1 DO BEGIN im=images(256*i:256*i+255,0:255) KIh=gethd(headbytes(*,i)) ; decode the image header FOR k=0,3 DO itime(k)=KIh.misc.tm.(k) ; identify useful min and max values for byte-scaling ih=HISTOGRAM(im(wprad),MIN=0,BIN=1) ; histogram of exposed image cih=ih ; next line computes cumulative pixel value pdf FOR jj=1,N_ELEMENTS(cih)-1 DO cih(jj)=cih(jj)+cih(jj-1) cih=cih/FLOAT(MAX(cih)) ; normalize to unity lmaxi=MAX(WHERE(cih LE .999)) ; top 0.1% of pixels saturate ; if viewing sky image, take dark 'skirt' as min value bh=HISTOGRAM(im(base),MIN=0,BIN=1) maxbh=MAX(bh,lmaxbh) ; bottom = most prob. skirt value ; show image orientation, one time only IF i EQ 0 THEN BEGIN azimuth=13.1 azrad=!DTOR*azimuth ; plot arrows showing the azimuth leftend=scl(res=psres,(wwidth-2.*barwidth)/2.)-twidthd/2. maxlen=(leftend-scl(res=psres,1.5*X_charwidth)) $ /scl(res=psres,(COS(azrad)+SIN(azrad))*X_charheight) arlen=MIN([FIX(maxlen),4])*X_charheight tailx=REPLICATE(scl(res=psres,0.5*X_charwidth+SIN(azrad)*arlen),2) taily=REPLICATE(scl(res=psres,256+X_charheight),2) headx=[tailx(0)-scl(res=psres,arlen*SIN(azrad)), $ tailx(1)+scl(res=psres,arlen*COS(azrad))] heady=[taily(0)+scl(res=psres,arlen*COS(azrad)), $ taily(1)+scl(res=psres,arlen*SIN(azrad))] arrow,tailx,taily,headx,heady,/device,hsize=-0.2 XYOUTS,tailx(0),heady(0)-scl(res=psres,X_charheight),'N' $ ,ALIGNMENT=0,/DEVICE,CHARSIZE=csz XYOUTS,headx(1)+scl(res=psres,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=psres,256*i,0 ; display image camera, filter, and sequence numbers IF KEYWORD_SET(number1) THEN BEGIN IF i EQ 0 THEN number=number0 ELSE number=number1 ENDIF ELSE number=number0 XYOUTS,scl(res=psres,256*i+1),scl(res=psres,256-1-X_charheight) $ ,STRING(number,FORMAT='(I3.3)') $ ,/DEVICE,ALIGNMENT=0.0,CHARSIZE=0.75*csz $ ,COLOR=0.8*!D.N_COLORS ; and image time XYOUTS,scl(res=psres,i*256+1) $ ,scl(res=psres,3+X_charheight) $ ,/DEVICE,ALIGNMENT=0.0,CHARSIZE=0.75*csz,COLOR=0.8*!D.N_COLORS $ ,STRING(itime(0:2),FORMAT='(I2.2,":",I2.2,":",I2.2)') ; and exposure time XYOUTS,scl(res=psres,i*256+1),scl(res=psres,1) $ ,STRING(exptime(i),FORMAT='(F5.1,1X,"s")'),/DEVICE,ALIGNMENT=0.0 $ ,CHARSIZE=0.75*csz,COLOR=0.8*!D.N_COLORS ; and maximum displayed DN XYOUTS,scl(res=psres,(i+1)*256-1),scl(res=psres,256-1-X_charheight) $ ,STRING(FIX(lmaxi),FORMAT='("< ",I0.0," DN")') $ ,/DEVICE,ALIGNMENT=1.0,CHARSIZE=0.75*csz,COLOR=0.8*!D.N_COLORS ; and minimum displayed DN XYOUTS,scl(res=psres,(i+1)*256-1),scl(res=psres,1) $ ,STRING(FIX(lmaxbh),FORMAT='("> ",I0.0," DN")'),/DEVICE $ ,ALIGNMENT=1.0,CHARSIZE=0.75*csz,COLOR=0.8*!D.N_COLORS ENDFOR RETURN END