; FCAFIRST.PRO ; Modified to allow user to specify the fields of view to sample. ; D P Steele, 18 Oct 1994. ; ; Modified from SHOWRAY.PRO by D P Steele on Wed Sep 28 15:44:18 MDT 1994 ; ; 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 date,year,month,day ; create byte-valued input parameters cam=0 & filt=cam & day=cam & month=cam @isitdos s='' psplot=0B take2=0B !ORDER=1 IF !D.WINDOW EQ 0 THEN WDELETE,0 ; tell user what imaging modes and filters are available PRINT,"Num Cam0 Filters Cam1 Filters" wavelengths=STRARR(5) FOR i=0,4 DO BEGIN wv=STRTRIM(filters(i),2) tmp=STRMID(wv,0,STRPOS(wv,'nm')+2) wavelengths(i)=tmp+spc(24-STRLEN(tmp)) ENDFOR col2=wavelengths & maxlen2=MAX(STRLEN(col2)) FOR i=0,4 DO BEGIN wv=STRTRIM(filters(i+5),2) tmp=STRMID(wv,0,STRPOS(wv,'nm')+2) wavelengths(i)=tmp+spc(24-STRLEN(tmp)) ENDFOR col3=wavelengths & maxlen3=MAX(STRLEN(col3)) FOR i=0,4 DO BEGIN line=STRING(i,col2(i),col3(i),FORMAT='(I1,5X,2A24)') PRINT,line ENDFOR ; prompt user and get input PRINT,'Enter the year, month, day, camera, and filter desired' READ,year,month,day,cam,filt hour=0 minute=0 second=0 PRINT,'Enter the hour, minute, and second to start (default 00:00:00 UT)' sthms='' READ,sthms IF sthms NE '' THEN BEGIN nw=nwrds(sthms) IF nw GE 1 THEN hour=FIX(getwrd(sthms,0)) IF nw GE 2 THEN minute=FIX(getwrd(sthms,1)) IF nw GE 3 THEN second=FIX(getwrd(sthms,2)) ENDIF ; 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 ; Display only those pixels viewing the sky 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/' ; dir=saveroot+dd ; 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=rFINDFILE(dir+template,COUNT=nfiles) ; files=files(SORT(files)) ; 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)' ; READ,'Select the file to display: ',nd ; template=files(nd) ; END ; ENDCASE template=FiLocate(year,month,day,cam,filt) ; Open the file as a series of small (header-size) units and get ; the header information ON_IOERROR,go_on OPENR,hbunit,template,/GET_LUN hbfile=ASSOC(hbunit,BYTARR(512)) hbstat=FSTAT(hbunit) hbbytes=hbstat.SIZE nimages=hbbytes/66048L PRINT,'There are '+STRTRIM(nimages,2)+' images' hbytes=BYTARR(512,nimages) utsec=LONARR(nimages) exptimes=FLTARR(nimages) FOR i=0L,nimages-1 DO BEGIN hbytes(0,i)=hbfile(129*i) header=gethd(hbytes(*,i)) utsec(i)=3600L*header.misc.tm.hour $ + 60L*header.misc.tm.minute $ + 1L*header.misc.tm.second exptimes(i)=header.misc.exp_scale*header.exp.exposure/1000. IF (i GT 0) AND (i MOD 20 EQ 0) THEN PRINT,i,FORMAT='(I4,$)' IF (i GT 0) AND (i MOD 400 EQ 0) THEN PRINT,FORMAT='()' GOTO,endloop go_on: IF KEYWORD_SET(bad_image) $ THEN bad_image=[bad_image,i] $ ELSE bad_image=[i] endloop: ENDFOR PRINT,FORMAT='()' CLOSE,hbunit FREE_LUN,hbunit IF NOT KEYWORD_SET(bad_image) THEN bad_image=[-1] 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")' texp='' READ,'Enter the exposure time of interest ( for all): ',texp selexp=isnumber(texp,expt) ENDIF ELSE BEGIN selexp=0 expt=FIX(ROUND(mnex)) ENDELSE v=REPLICATE(1.,256,256) IF sthms EQ '' THEN BEGIN instring='' READ,'Enter the range of image numbers to display ( for all images): ',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 ; Get field-of-view specifications from user READ,'Enter the number of fields of view to sample: ',nfov fovparms=FLTARR(5,nfov) ; save zenith angle, azimuth, half-angle, ; distance East of camera (X), and distance ; North of camera (Y) READ,'Enter the nominal altitude of the emission feature (km): ',eht PRINT,'Enter all angles in degrees.' FOR i=0,nfov-1 DO BEGIN READ,'Enter the zenith, azimuth, and half angles of FOV ' $ +STRTRIM(i,2)+': ',zz,aa,hh dist=za2dist(zz,eht,/deg,radius=relc(80.0533)) fovparms(*,i)=[zz,aa,hh,dist*SIN(aa*!DTOR),dist*COS(aa*!DTOR)] ENDFOR ; Generate mask pixel numbers wm=LONARR(1000,nfov) ; save no. of FOV pixels, followed by pixel ; indices maxn=0 FOR i=0,nfov-1 DO BEGIN tmp=fovpix(year,month,day,cam,fovparms(0,i),fovparms(1,i) $ ,fovparms(2,i),/deg) ntmp=N_ELEMENTS(tmp) wm(0:ntmp,i)=[ntmp,tmp] maxn=MAX([ntmp,maxn]) ENDFOR wm=wm(0:maxn,*) ; truncate so only needed elements kept mbfov=FLTARR(nfov) ; Open the single big file and associate it to variable. OPENR,imunit,template,/GET_LUN files=ASSOC(imunit,BYTARR(66048)) ; Make the file name for the single big output file ; outpath='/jasper/cnsr3_data1/fca/' outpath=fcaroot+dd outname=outpath+STRING(year MOD 100,month,day,5*cam+filt $ ,FORMAT='(3I2.2,I1)') ; outtime=SYSTIME() ; date2ymd,outtime,nyr,nmo,nda ; dt_tm_brk,outtime,dst,tst ; now=STRING(nyr MOD 100,nmo,nda,FORMAT='(3I2.2,".")') ; now=now+STRMID(tst,0,2)+STRMID(tst,3,2) ; outname=outname+now+'.corr' ; outname=outname+now+fca_suffix already=rfindfile(outname+'*'+fca_suffix,count=nalready) outname=outname+STRING(nalready,FORMAT='(I1)')+fca_suffix PRINT,'Output file name is ',outname ; Open it OPENW,fcaunit,outname,/GET_LUN PRINTF,fcaunit,nfov PRINTF,fcaunit,[TRANSPOSE(FINDGEN(5)),TRANSPOSE(fovparms)] ; read in each image, decode the header, subtract dark frame, rebin to ; 256x256 if necessary, scale to 8 bits and display ip=-1 mid=-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 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 ; extract start time of image from header itime=BYTARR(4) FOR itptr=0,3 DO itime(itptr)=KIh.misc.tm.(itptr) utsecs=TOTAL(itime*[3600,60,1,.01]) ip=ip+1 ; index number for screen position of image ; compute mean brightnesses at three positions FOR j=0,nfov-1 DO mbfov(j)=mean(im(wm(1:wm(0,j)-1,j))) PRINTF,fcaunit,utsecs,mbfov ; If this is the first image, set up a plot of small-field brightnesses ; vs time. IF ip EQ 0 THEN BEGIN PLOT,[0,1],/NODATA $ ,XRANGE=[MIN(utsec,MAX=mxuts)/3600,CEIL(mxuts/3600.)] $ ,XSTYLE=1,XTITLE='Universal Time (hours)' $ ,YRANGE=[0,1000],YTITLE='Mean Brightness (R)' loadct,13 whitetop ENDIF PLOTS,REPLICATE(utsecs/3600.,nfov),mbfov $ ,COLOR=BYTSCL(INDGEN(nfov)+1,MIN=0 $ ,MAX=nfov+1,TOP=!D.N_COLORS-1) $ ,PSYM=3 ENDIF ENDIF ENDFOR FREE_LUN,fcaunit DONE: END