; VIDEO.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 1994/2/7 by DPS to read images from associated files, ; where the latter are formatted as 512-byte headers followed by ; 256x256 bytes. The images are scaled to 8 bits for storage, and ; are reconstituted by multiplying by 2^p, where the value of p is ; stored in byte 290 of the header (counting from 0). ; COMMON skypixels,sigpix COMMON headbytes,oldfname,hbytes,utsec,exptimes,fwtemps,bad_image ; create byte-valued input parameters cam=0 & filt=cam & day=cam & month=cam ; load various string-valued arrays needed @isitdos take2=0B !ORDER=0 IF !D.WINDOW EQ 0 THEN WDELETE,0 ; tell user what imaging modes and filters are available cam_filt,filters ; prompt user and get input PRINT,'Enter the year, month, day, camera, and filter desired' READ,year,month,day,cam,filt PRINT,'Enter the hour, minute, and second to start (default 00:00:00 UT)' get_hms,sthms,hour,minute,second PRINT,'Enter the minimum time between image refreshes (default = 1.0s)' interval=1.0 ir='' READ,ir IF isnumber(ir,irv) NE 0 THEN interval=FLOAT(irv) ptype='' READ,'Map the images to a coordinate grid? ([Y]/N) ',ptype ptype=STRUPCASE(ptype) IF ptype EQ 'N' THEN BEGIN !ORDER=1 fac=3 image_height=fac*256 ENDIF ELSE BEGIN mtype='' REPEAT BEGIN READ,'Geographic coordinates or an MLT/MLat dial? (G/M) ',mtype mtype=STRUPCASE(mtype) ENDREP UNTIL (mtype EQ 'G') OR (mtype EQ 'M') fac=2 image_height=fac*383 IF mtype EQ 'G' THEN BEGIN ctr='' READ,'Center the plot on the geomagnetic pole or Eureka? ([P]/E) ' $ ,ctr pole=(STRUPCASE(ctr) NE 'E') IF NOT pole THEN BEGIN rotstr='' READ,'Rotate the plot to the correct "MLT" orientation? ([Y]/N) ' $ ,rotstr rot=(STRUPCASE(rotstr) NE 'N') ENDIF ELSE rot=1B grid='' READ,"Show coastlines ('c') and/or coordinates ('g')? ",grid ENDIF ELSE BEGIN rot=0B pole=0B ENDELSE eheight=[87,100,300,120,100,87,100,120,97,100] PRINT,'Default emission height is '+STRTRIM(eheight(5*cam+filt),2) $ +' km; enter preferred height or to accept this one:' htstr='' READ,htstr IF htstr NE '' THEN eht=ROUND(FLOAT(htstr)) ELSE eht=eheight(5*cam+filt) READ,'Enter the van Rhijn background (R) to subtract: ',vRbg sat='' PRINT,'If you want to overplot a satellite footprint, enter the standard' READ,'2-line element name: ',sat IF sat NE '' THEN satname=STRTRIM(STRUPCASE(sat),2) 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 ; Is timing important? synch='' READ,'Do you want to control image refresh from the keyboard? (Y/[N]) ',synch synch=(STRUPCASE(synch) EQ 'Y') ; 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 title for image plot site_names=['','Spyhill Airglow Observatory','Rabbit Lake, SK' $ ,'Eureka AStrO Lab'] site=site_names(PoCasite(year,month,day)) wtitle=STRING(filters(cam*5+filt),FORMAT='("Polar Camera",2X,A)') wtitle=[wtitle,site+' '+ymd2date(year,month,day,format='d$ n$ y$')] ; Display only those pixels viewing the sky mk,mask ;sigpix=rdsigpix(cam) ;mask(sigpix)=1 getsig,year,month,day,mask0,mask1 CASE cam of 0: mask=mask0 1: mask=mask1 ENDCASE ; define path to desired images dir='/jasper/cnsr3_data1/save/' ; define file name for desired file template=STRING(year MOD 100,month,day,cam,filt,FORMAT='(3I2.2,2I1,".*")') ; make list of available files of desired type files=FINDFILE(dir+template,COUNT=nfiles) CASE nfiles OF 0: BEGIN PRINT,'No files found; quitting.' GOTO,DONE END 1: BEGIN PRINT,files(0)+' available; opening file' template=files(0) END ELSE: BEGIN PRINT,'Files available:' FOR i=0,nfiles-1 DO PRINT,i,files(i),FORMAT='(I1,2X,A)' PRINT,'Select the file to display' READ,nd template=files(nd) END ENDCASE ; Open the file as a series of small (header-size) units and get ; the header information nimages=rdhbytes(template) ; Load (or create) the data to correct for the reduced transmission. reltrans,oldfname,filtemp,filtrans ; identify image sequences and prompt user for sequence(s) to display dt=ABS(utsec-SHIFT(utsec,1)) ; rectify big negative number in front seqstart=WHERE(dt GT 600) ; semi-arbitrary large number (10 min) RESTART: IF seqstart(0) GE 0 THEN BEGIN PRINT,'Sequences begin with the following image numbers(s):' PRINT,seqstart ENDIF mnex=MIN(exptimes,MAX=mxex) IF mnex NE mxex THEN BEGIN PRINT,mnex,mxex $ ,FORMAT='("Exposure times range from ",F4.1," to ",F4.1," s")' PRINT,'Enter the exposure time of interest ( for all)' texp='' READ,texp selexp=isnumber(texp,expt) ENDIF ELSE BEGIN selexp=0 expt=FIX(ROUND(mnex)) ENDELSE IF NOT take2 THEN BEGIN IF sthms EQ '' THEN BEGIN PRINT,'Enter the range of image numbers to display ( for all images)' instring='' & READ,instring f=isnumber(instring,inf) IF f NE 0 THEN BEGIN ; user entered at least one number inf=FIX(inf) IF f GT 0 $ ; user entered only one number THEN inl=nimages-1 $ ELSE BEGIN f=isnumber(getwrd(instring,1),inl) IF f NE 0 THEN inl=FIX(inl) ELSE inl=nimages-1 ENDELSE ENDIF ELSE BEGIN inf=0 inl=nimages-1 ENDELSE ENDIF ELSE BEGIN startut=(hour*60L+minute)*60L+second inf=MIN(WHERE(utsec GE startut)) inl=nimages-1 ENDELSE ENDIF ; Set up image display barwidth=32 fill='' READ,'Do you want the plot window to fill the screen? ([Y]/N) ',fill fill=(STRUPCASE(fill) NE 'N') ; Open plotting window IF fill $ THEN WINDOW,0,XPOS=0,YPOS=38,XSIZE=1264,YSIZE=980 $ ELSE WINDOW,0,XPOS=0,YPOS=118,XSIZE=1230,YSIZE=900 TVSCL,BINDGEN(256) ; wake up the X window and set !D.N_COLORS correctly psres=100. ; dummy value ; Now load the colour table cf=5*cam+filt CASE cf OF 2: ct=3 7: ct=1 8: ct=8 ELSE: ct=0 ENDCASE loadct,ct,/silent ; title image display window disptitl,wtitle,fac,image_height,psres ; Calculate coordinates of LL corner of images llx=(!D.X_SIZE-image_height)/2 lly=0 ; create and display color bar barlength=image_height nquad=2*!ORDER+1 bar=ROTATE(congrid(BINDGEN(256,barwidth),barlength,barwidth,/minus_one),nquad) mtv,BYTSCL(bar,TOP=!D.N_COLORS-1),llx+image_height,lly,res=psres ; Open the single big file and associate it to variable. OPENR,imunit,template,/GET_LUN files=ASSOC(imunit,BYTARR(66048)) ; read in each image, decode the header, and renormalize as necessary ip=-1 FOR i=inf(0),inl(0) DO BEGIN whbad=WHERE(bad_image EQ i,nwhbad) IF nwhbad EQ 0 THEN BEGIN file=files(i) im=BYTE(file,512,256,256) ; If file was renormalized to fit 8 bits, reverse this. IF file(290) GT 0 THEN BEGIN IF file(291) EQ 1 THEN im=LONG(im)*(2^file(290)) IF file(291) EQ 0 THEN im=LONG(im)*file(290) ENDIF KIh=gethd(hbytes(*,i)) ; extract filter temperature, determine reduced filter transmission, ; and divide image by reduced transmission to recover actual emission ; brightnesses fwtemp=fwtemps(i) imtrans=interpol(filtrans,filtemp,fwtemp) im=ROUND(im/imtrans(0)) ; Update the image pointer. ip=ip+1 ; extract exposure time if necessary IF selexp THEN BEGIN thisexp=KIh.misc.exp_scale*KIh.exp.exposure/1000. go_on=(ABS(thisexp-expt) LT 1.0) ENDIF ELSE go_on=1 IF go_on THEN BEGIN ; If autoscaling is desired, find lmaxi, otherwise use topnum IF topnum EQ 0 $ ; Is there any useful information left in the image? ; identify useful min and max values for byte-scaling THEN lmaxi=percentile(im,0.999) $ ELSE lmaxi=topnum im(255,98)=lmaxi ; force image to scale properly lmaxbh=percentile(im,0.001) ; show image orientation, one time only IF (i EQ inf(0)) AND (ptype EQ 'N') $ THEN compass,KIh.misc.az,barlength,fac,psres ; wait until the previous image has been up for at least the time ; interval requested by the user IF KEYWORD_SET(otime) THEN $ REPEAT stime=SYSTIME(1) UNTIL (stime-otime GT 1.1*interval) ; generate the image to plot IF ptype EQ 'N' $ THEN pimg=ROTATE(im*mask,5) $ ELSE BEGIN IF mtype EQ 'M' $ THEN map_pgm,hbytes(*,i),im*mask,eht,88.664 $ ,-83.444,pimg,vRbg=vRbg $ ,fullscale=[lmaxbh,lmaxi],/annotate $ ELSE map_geo,hbytes(*,i),im*mask,eht,pimg $ ,vRbg=vRbg,fullscale=[lmaxbh,lmaxi] $ ,/annotate,grid=grid,rot=rot,pole=pole $ ,sat=satname ifac=(lmaxi-lmaxbh)/255. pimg=ROUND(ifac*TEMPORARY(pimg))+lmaxbh pimg=FIX(TEMPORARY(pimg)) ENDELSE ; display the image psize=SIZE(pimg) CASE 1 OF psize(1) GE psize(2): grow=image_height/psize(1) psize(1) LT psize(2): grow=image_height/psize(2) ENDCASE IF synch THEN k=GET_KBRD(1) mtv,REBIN(pimg,grow*psize(1),grow*psize(2),/SAMPLE) $ ,llx,lly,low=lmaxbh,high=lmaxi,res=psres ; label the image (if it hasn't already been done) IF ptype EQ 'N' $ THEN labelimg,hbytes(*,i),lmaxi,lmaxbh,llx,lly $ ,image_height,image_height,fac $ ,psres=psres,color=0.8*!D.N_COLORS $ ,/sun ; Interpret user's latest keystroke EMPTY otime=SYSTIME(1) PRINT,'.',FORMAT='(A,$)' IF (ip+1) MOD 80 EQ 0 THEN PRINT,FORMAT='()' k=GET_KBRD(0) CASE STRUPCASE(k) OF 'Q': GOTO,DONE 'X': GOTO,DONE ELSE: ENDCASE ENDIF EMPTY ENDIF ENDFOR DONE: FREE_LUN,imunit PRINT,FORMAT='()' END