pro gobingo,num,file1,file2,fileflux ; Eclipse observation: Input for BINGO photometry. ; manual selection of bright points (BPs) ; and local background samples (LBs) ; ; Parameter: serial number of the observed image (input) ; filenames for output. ; Image form: fltarr(1024,1024) ; Output: 2 ASCII files (seq.no, x, y, value): ; file1 of BPs and file2 of LBs. ; 1 ASCII file with fluxes and "full" areas of BPs ; if n_params() ne 4 then begin print,'usage: inbingo, imag.number,file1,file2,fileflux' stop endif ; !!!! TO BE CHANGED WITH RESPECT TO WHERE THE IMAGES ARE STORED !!!! stra=string('/scratch/sob/') strb=string('imn.') ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! window,0,xsize=512,ysize=512 scale=0.124 ; scale arcsec/pix ; reading the input image ima=fltarr(1024,1024) dcn=strtrim(num,2) if strlen(dcn) eq 3 then str='0'+dcn if strlen(dcn) eq 2 then str='00'+dcn if strlen(dcn) eq 1 then str='000'+dcn print,'Now reading image:' print,strb+str openr,1,stra+strb+str readu,1,ima close,1 ; selection of zoomed area ima=ima(250:761,315:826) ; area of interest... tvscl,ima newbox: print,'set the center position for zoom' cursor,x0,y0,/device,/down print,'center position is at',x0,y0 dx=50 ; setting parameters of zoom window dy=50 fact=5. ; the following block assures that the zoom is always inside the array uly=y0+dy lly=y0-dy ulx=x0+dx llx=x0-dx if uly gt 511 then begin y0=511-dy print,'top limit: new center position',x0,y0 endif if lly lt 0 then begin y0=dy print,'bottom limit: new center position',x0,y0 endif if ulx gt 511 then begin x0=511-dx print,'right limit: new center position',x0,y0 endif if llx lt 0 then begin x0=dx print,'left limit: new center position',x0,y0 endif box=ima(x0-dx:x0+dx,y0-dy:y0+dy) ; selected box zoo=rebin(box,fact*(2*dx+1),fact*(2*dy+1),/sample) ; zoom window,2,xsize=fact*(2*dx+1),ysize=fact*(2*dy+1) tvscl,zoo print,'do you accept this box? (y/n) if get_kbrd(1) eq 'n' then goto,newbox ; From now, all the coordinates are related to the selected box! ; selection of pixels representing BPs and LBs bpsel: flbox=fltarr(2*dx+1,2*dy+1,21) x=fltarr(21) y=fltarr(21) v=fltarr(21) xloadct print,'NOW SELECT BRIGHT FEATURES' n=0 curs1: print,'selection of maximum - left, middle; quit - right (mouse)' cursor,xr,yr,/device,/down if (!err eq 1) or (!err eq 2) then begin ; start of the large curs. loop n=n+1 xx=fix(xr/fact) yy=fix(yr/fact) print,n,xx,yy,box(xx,yy) x(n)=xx*scale y(n)=yy*scale v(n)=box(xx,yy) ; ............. selection of flux polygons ............... ;taking the data print,'mark the polygonal vertices of the flux area' polig=intarr(2*dx+1,2*dy+1) maska=polig verx=intarr(10) very=intarr(10) label0: k=-1 label1: cursor,xp,yp,/device,/down if !err ne 4 then begin k=k+1 verx(k)=fix(xp/fact) very(k)=fix(yp/fact) print,'...next vertice... (right to quit)' goto,label1 endif print,'end of selection of the polygon vertices' verx=verx(0:k) & very=very(0:k) ; constructing the polygon for i=0,k do begin vx1=verx(i) & vy1=very(i) if i eq k then begin vx2=verx(0) & vy2=very(0) endif else begin vx2=verx(i+1) & vy2=very(i+1) endelse ; decide if you interpolate in x or y... if abs(vx2-vx1) ge abs(vy2-vy1) then begin ; interpolation in x if vx1 gt vx2 then begin vv=vx2 vx2=vx1 vx1=vv vv=vy2 vy2=vy1 vy1=vv endif for ix=vx1,vx2 do begin iy=vy1+float(vy2-vy1)*(ix-vx1)/float(vx2-vx1) iy=fix(iy) polig(ix,iy)=1 endfor endif else begin ; interpolation in y if vy1 gt vy2 then begin vv=vx2 vx2=vx1 vx1=vv vv=vy2 vy2=vy1 vy1=vv endif for iy=vy1,vy2 do begin ix=vx1+float(vx2-vx1)*(iy-vy1)/float(vy2-vy1) ix=fix(ix) polig(ix,iy)=1 endfor endelse endfor ; filling the polygon (in the array maska) fill_9,polig,maska,xx,yy,1 fill_9,polig,maska,xx,yy,-1 iter: na=0 for j=0,2*dy do begin for i=1,2*dx do begin di=maska(i,j)-maska(i-1,j) case 1 of (di gt 0): begin if polig(i-1,j) eq 0 then begin fill_9,polig,maska,i-1,j,-1 na=na+1 endif end (di lt 0): begin if polig(i,j) eq 0 then begin fill_9,polig,maska,i,j,1 na=na+1 endif end else: endcase endfor endfor if na ne 0 then goto,iter ; the final mask (zeros - outside, ones - inside, incl. border) maska=maska/9+polig flbox(*,*,n)=box*maska wset,0 tvscl,rebin(flbox(*,*,n),fact*(2*dx+1),fact*(2*dy+1),/sample) wset,2 goto,curs1 endif ; end of the large cursor loop print,'selected',n,'bright features' x=x(0:n) y=y(0:n) v=v(0:n) flbox=flbox(*,*,0:n) print,'selection ok? (y/n)' if get_kbrd(1) eq 'n' then goto,bpsel openw,1,file1 printf,1,n for i= 1,n do printf,1,i,x(i),y(i),v(i) close,1 nbp=n lbsel: x=fltarr(100) y=fltarr(100) v=fltarr(100) xloadct print,'NOW SELECT BACKGROUND POINTS' n=0 curs2: print,'selection - left, middle; quit - right (mouse)' cursor,xr,yr,/device,/down if (!err eq 1) or (!err eq 2) then begin n=n+1 xx=fix(xr/fact) yy=fix(yr/fact) print,n,xx,yy,box(xx,yy) x(n)=xx*scale y(n)=yy*scale v(n)=box(xx,yy) goto,curs2 endif print,'selected',n,'background points' x=x(0:n) y=y(0:n) v=v(0:n) print,'selection ok? (y/n)' if get_kbrd(1) eq 'n' then goto,lbsel openw,1,file2 printf,1,n for i= 1,n do printf,1,i,x(i),y(i),v(i) close,1 print,'end of selection' ; running BINGO spawn,'bingo3.exe' ; computing fluxex of BPs backg=fltarr(2,nbp) openr,1,'BACK.TMP' readf,1,backg ; the "background" value on n-th BP is in backg(1,n-1) print,'background values from BINGO:' print,backg(1,*) close,1 openw,1,fileflux printf,1,'FLUXES AND AREAS OF BPs:' printf,1,' no. flux flux_excess area(pix) area(arcsec^2)' print,'fluxes and areas of BPs:' for i=1,nbp do begin flbx=flbox(*,*,i) setp=where(flbx ge backg(1,i-1)) flux=total(flbx(setp)) area=n_elements(flbx(setp)) exflux=flux-area*backg(1,i-1) ; flux excess over the background are=area*scale*scale print,i,flux,exflux,area,are printf,1,i,flux,exflux,area,are endfor close,1 end