;+ ; NAME: SELBGSIM ; ; PURPOSE: ; To return an array of indices into .bgs images that identify images ; spanning a certain time, and ones that have been subtracted by a minimum ; image produced over the same interval. ; ; CATEGORY: ; ; CALLING SEQUENCE: ; SELBGSIM,KEEP,UTSEC,YEAR,MONTH,DAY,CN,FN,HH,MM,SS,SPAN ; ; INPUTS: ; YEAR, MONTH, DAY: The year, month and day the images were produced. ; CN, FN: The camera and filter number. ; HH, MM, SS: The hour, minute and second the images start. ; SPAN: The period (hours) from the start time during which images ; will be included. ; ; KEYWORD PARAMETERS: ; LIST: Will list all available image sets. Note, if this keyword is ; set then only the YEAR, MONTH, DAY, CN, and FN have to be ; entered. ; expt: Set the exposure time of the images. (default=60) ; CAM: The camera number of the images used to make the minimum image ; that was subtracted from the .ray images to make the .bgs images. ; (default=CN) ; FILT: The filter number of the images used to make the minimum image ; that was subtracted from the .ray images to make the .bgs images. ; (default=FN) ; VRHIJN: The minimum image used for subtraction puposes will be a van ; Rhijn layer. (default = original minimum image) ; ; OUTPUTS: ; KEEP: An array of indices into the .bgs images identifying images ; spanning the interval set by the user, subject to the condition ; of the keywords. ; UTSEC: The times, (UT seconds) of all images stored in the .bgs file ; corresponding to the value of the inputs. ; ; NOTE: If no images satisfy the inputs and the keywords, then KEEP ; and UTSEC will be set to -1. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; None. ; ; RESTRICTIONS: ; None known. ; ; PROCEDURE: ; ... ; ; MODIFICATION HISTORY: ; Written August 1994, by T A Oliynyk. ; ;- PRO selbgsim,keep,utsec,year,month,day,cn,fn,hh,mm,ss,span $ ,list=list,expt=expt,cam=cam,filt=filt,vrhijn=vrhijn ; If no parameters specified, print the online documentation. IF N_PARAMS() LT 11 THEN BEGIN doc_library,'selbgsim' RETURN ENDIF ; Set up OS-specific parameters. @isitdos IF N_ELEMENTS(expt) EQ 0 THEN expt=60 sy=STRING(year MOD 100,FORMAT='(I2.2)') sm=STRING(month,FORMAT='(I2.2)') sd=STRING(day,FORMAT='(I2.2)') date=sy+'/'+sm+'/'+sd scn=STRING(cn,FORMAT='(I1)') sfn=STRING(fn,FORMAT='(I1)') ; path=saveroot+dd ; filename=path+sy+sm+sd+scn+sfn+'.bgs' filename=FiLocate(year,month,day,cam,filt,/bgs) ; get header bytes from the .bgs file. OPENR,hbunit,filename,/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) interval=BYTARR(nimages) hour=interval minute=interval second=interval vrh=interval camera=interval filter=interval FOR i=0L,nimages-1 DO BEGIN hbytes(0,i)=hbfile(129*i) header=gethd(hbytes(*,i)) ; get the header information from the .bgs images utsec(i)=3600L*header.misc.tm.hour $ ; store the time of the images + 60L*header.misc.tm.minute $ ; (in UT seconds) + 1L*header.misc.tm.second exptimes(i)=header.misc.exp_scale*header.exp.exposure/1000. interval(i)=header.proc.bkgd_mlength ; the interval (minutes) over which the ; minimum image used to make the .bgs ; images was produced. hour(i)=header.proc.bkgd_hstart ; start hour of the interval over which ; the minimum image was produced. minute(i)=header.proc.bkgd_mstart ; start minute ... second(i)=header.proc.bkgd_sstart ; start second ... vrh(i)= header.proc.bkgd_source ; the zenith brightness of the van ; Rhijn layer produced from the ; minimum image (= 255 if the original ; minimum image was used) camera(i)=header.proc.bkgd_camera ; the camera number of the images used filter(i)=header.proc.bkgd_filter ; the filter number of the images used 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='()' ENDFOR PRINT,FORMAT='()' FREE_LUN,hbunit input=0B IF KEYWORD_SET(list) THEN BEGIN input=1B ENDIF ELSE BEGIN thh=hh tmm=mm tss=ss ENDELSE ; if the keyword list has been set then display all the possible image sets IF input EQ 1B THEN BEGIN hold=hour*3600L+minute*60L+LONG(second) cf=LONG(filter) c1=WHERE(camera EQ 1) convert=LONARR(N_ELEMENTS(filter)) IF c1(0) NE -1 THEN convert(c1)=5L cf=(cf+convert)*100000L hold=hold+cf cint=interval*1000000L hold=hold+cint hold=hold(SORT(hold)) hold=[hold(uniq(hold))] nh=N_ELEMENTS(hold) intv=FIX(hold/1000000L) cf=FIX((hold-intv*1000000L)/100000L) c=cf/5 f=cf MOD 5 hr=FIX((hold-intv*1000000L-cf*100000L)/3600L) mn=FIX((hold-intv*1000000L-cf*100000L-hr*3600L)/60L) sec=FIX(hold-intv*1000000L-cf*100000L-hr*3600L-mn*60L) PRINT, " " PRINT, " All of the possible image sets are listed below." PRINT, " " PRINT, " - CAM/FILT identify the camera and filter from which the minimum " $ +"background image was" PRINT, " produced, that was used for background subtraction." PRINT, " " PRINT, " - START TIME is the start of the interval from which the minimum " $ +"background image was" PRINT, " produced and also identifies the start time of the images that " $ +"will be looked at." PRINT, " " PRINT, " - DURATION is the length of time from the START TIME over which " $ +"images were used to" PRINT, " produce the minimum image. In addition, the images to be looked " $ +"at will be from the" PRINT, " interval spanned by DURATION starting at START TIME." PRINT, " " FOR i=0,nh-1 DO BEGIN PRINT,i+1,hr(i),mn(i),sec(i),c(i),f(i),intv(i) $ ,FORMAT='(I3,1X,"Start Time: ",I2.2,":",I2.2,":",I2.2," UT, Cam: "' $ +',I1,", Filt: ",I1,", Duration: ",I3," min.")' PRINT,' ' ENDFOR IF nh GT 1 THEN BEGIN ans=0 PRINT,N_ELEMENTS(hold),FORMAT='($,"Choose one of the sets (1-",I0,")")' READ,ans PRINT,' ' ENDIF ELSE ans=1 WHILE (ans LT 1) OR (ans GT nh) DO BEGIN PRINT,FORMAT='($,"Choice is not valid. Choose again") READ,ans PRINT,' ' ENDWHILE choice=ans-1 c_num=c(choice) f_num=f(choice) thh=hr(choice) tmm=mn(choice) tss=sec(choice) int=intv(choice) span=FIX(int/60) ENDIF ELSE int=FIX(span*60) stime=thh*3600L+tmm*60L+tss ; start time for the interval etime=stime+FIX(3600L*span) ; end time for the interval ethh=etime/3600L etmm=(etime-ethh*3600L)/60L etss=etime-ethh*3600L-etmm*60L IF input EQ 0B THEN BEGIN IF (N_ELEMENTS(cam) GT 0) OR (N_ELEMENTS(FILT) GT 0) THEN BEGIN IF N_ELEMENTS(cam) GT 0 THEN c_num=cam(0) ELSE c_num=cn IF N_ELEMENTS(filt) GT 0 THEN f_num=filt(0) ELSE f_num=fn ENDIF ELSE BEGIN c_num=cn f_num=fn ENDELSE ENDIF keep=WHERE(exptimes EQ expt) IF keep(0) EQ -1 THEN BEGIN PRINT,expt $ ,FORMAT='("There are no ",I2.2," second images contained in the file.")' keep=-1 & utsec=-1 RETURN ENDIF kc=WHERE(camera(keep) EQ c_num) IF kc(0) EQ -1 THEN BEGIN PRINT,c_num,FORMAT='("None of the images were produced by camera ",I1,".")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kc) kt=WHERE((utsec(keep) GT (stime-3L)) AND (utsec(keep) LT (etime+3L))) IF kt(0) EQ -1 THEN BEGIN PRINT,thh,tmm,tss,ethh,etmm,etss,$ FORMAT='("None of the images were produced during the interval, "' $ +',I2.2,":",I2.2,":",I2.2," to ",I2.2,":",I2.2,":",I2.2," UT.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kt) kf=WHERE(filter(keep) EQ f_num) IF kf(0) EQ -1 THEN BEGIN PRINT,f_num,FORMAT='("None of the images are filter ",I1," images.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kf) kint=WHERE(interval(keep) EQ int) IF kint(0) EQ -1 THEN BEGIN PRINT,int,$ FORMAT='("None of the images have been subtracted by a minimum background "/' $ +'"image produced from a ",F4.1," minute interval.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kint) kh=WHERE(hour(keep) EQ thh) IF kh(0) EQ -1 THEN BEGIN PRINT,"None of the images have been subtracted by a minimum background " $ +"image produced from" PRINT,thh,tmm,tss,$ FORMAT='("images starting at ",I2.2,":",I2.2,":",I2.2," UT.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kh) km=WHERE(minute(keep) EQ tmm) IF km(0) EQ -1 THEN BEGIN PRINT,"None of the images have been subtracted by a minimum background " $ +"image produced from" PRINT,thh,tmm,tss,$ FORMAT='("images starting at ",I2.2,":",I2.2,":",I2.2," UT.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(km) ks=WHERE(second(keep) EQ tss) IF ks(0) EQ -1 THEN BEGIN PRINT,"None of the images have been subtracted by a minimum background " $ +"image produced from" PRINT,thh,tmm,tss,$ FORMAT='("images starting at ",I2.2,":",I2.2,":",I2.2," UT.")' keep=-1 & utsec=-1 RETURN ENDIF keep=keep(ks) IF NOT KEYWORD_SET(vrhijn) THEN BEGIN kv=WHERE(vrh(keep) EQ 255) ENDIF ELSE BEGIN kv=WHERE(vrh(keep) NE 255) ENDELSE IF kv(0) EQ -1 THEN BEGIN PRINT,"None of the background images are of the proper type." keep=-1 & utsec=-1 RETURN ENDIF keep=keep(kv) kutsec=utsec(keep) ksec=uniq(kutsec,SORT(kutsec)) keep=keep(ksec) RETURN END