************************************** * Identifying Flanking Field Objects * ************************************** 12.15.99 1. Get a picture of the slitmask. Visually ID the HDF proper objects, find the corresponding object on the Hawaii image, then note both the Hawaii XY and the slitmask XY. 2. Use map.pro to get a transformation between slitmask XY and Hawaii XY from the HDF proper objects. Use the result to predict the Hawaii XY from the slitmask XY. 3. Use haw.pro to draw the slit. ID the serendips like usual. WARNING! The slitmask has x and y run in such a fashion that no mere transformation can be made between the two coordinate systems. (The slitmask y axis is backwards; no stretching, shifting, or rotating can fix this.) Hence, map.pro flips all slitmask y values. This should never, never affect you. Just read off and use the slitmask y values in a self-consistent way. Don't attempt to fix the problem at the front end! It's fixed in the code, so further attempts to fix it will just screw life up. Now go get 'em, tiger. *********** * map.pro * *********** pro map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This is a mean square fitting algorithm to generate ; ; a transformation from slitmask xy (mm) to position ; ; (pix). The direction of the transformation is ; ; slitmask xy --> image position. The arrays of interest ; ; are: ; ; ; ; s = mapx mapy 1 0 ; ; mapy -mapx 0 1 ; ; ... ; ; ; ; t = imagex ; ; imagey ; ; ... ; ; ; ; a = s*cos(theta) ; ; s*sin(theta) ; ; x_0 ; ; y_0 ; ; ... ; ; ; ; Input file should look like: ; ; mapx mapy imagex imagey ; ; ; ; The reference for this stuff is a handout by Carl ; ; Heiles associated with the undergrad astro lab. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Read data file to find array length: ; Enter this line at prompt: $wc mar98.dat > lengthinfo openr,unit,'lengthinfo',/get_lun readf,unit,len close,unit ; Declare variables: mapx=fltarr(len) mapy=fltarr(len) imagex=fltarr(len) imagey=fltarr(len) coords=fltarr(4,len) s=fltarr(4,2*len) t=fltarr(1,2*len) a=fltarr(1,4) ; Read data file and generate arrays for fit: openr,unit,'mar98.dat',/GET_LUN readf,unit,coords mapx=coords(0,*) mapy=-coords(1,*) imagex=coords(2,*) imagey=coords(3,*) close,unit j=0 for i=0,len-1 do begin s[0,j]=mapx(i) s[1,j]=-mapy(i) s[2,j]=1 s[3,j]=0 s[0,j+1]=mapy(i) s[1,j+1]=mapx(i) s[2,j+1]=0 s[3,j+1]=1 t[0,j]=imagex(i) t[0,j+1]=imagey(i) j=j+2 endfor ; The equation of condition is S A = T. ; The normal equation is SS A = ST. ; Write the normal equation and solve. ss = transpose(s)##s ssi = invert(ss) st = transpose(s)##t a = ssi##st ; Calculate rotation, scale, and shift from fit parameters. ; Print the image values as predicted by the fit, with error. ; (These should match the input image values!) scale=sqrt(a(0,0)^2 + a(0,1)^2) theta=(atan(a(0,1)/a(0,0))) x0=a(0,2) y0=a(0,3) print & print,'Scale: ',scale print,'Rotation: ',theta*!radeg print,'x_0: ',x0 print,'y_0: ',y0 print print,'Image points according to fit:' BT=S##A err=fltarr(2*len) for k=0,2*len-1 do begin err(k)=sqrt((BT(0,k)-T(0,k))^2 + (BT(0,k+1)-T(0,k+1))^2) print,BT(0,k),BT(0,k+1),err(k) k=k+1 endfor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Prompt for slitmask coordinates; transform to image: ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; slit=fltarr(4,2) slit(2,0)=1 slit(3,0)=0 slit(2,1)=0 slit(3,1)=1 label1: print read,newx,prompt='Enter slitmask x:' read,newy,prompt='Enter slitmask y:' slit(0,0)=newx slit(0,1)=-newy slit(1,0)=-slit(0,1) slit(1,1)=slit(0,0) out=fltarr(2) out=slit##A newimagex=out(0,0) newimagey=out(0,1) print & print,newx,newy print,'maps to:' print,newimagex,newimagey & print query=' ' read,query,prompt='Again? (y/n)' if query eq 'y' then goto, label1 else goto, label2 label2: print print & print,'Later!' & print end *********** * haw.pro * *********** ; This version carries display settings and angle ; parameters suitable for displaying and manipulating ; the Hawaii Flanking Field Image. ; angle = 0.01107 rad ; z1 = 0 ; z2 = 80 ; platescale = 0.1885 "/pix ; ps_open,'hdf4_555.1',/color,thick=3,/ps_fonts ; ps_close window,0 image=readfits('/pupusa/sdawson/hdf/coords/hawaii.fits',h) image2=image[726.32:1426.32,921.81:1621.81] positionangle = 102.46 platescale = 0.1885 slitwidth = 1.5 / platescale x0 = 351 y0 = 351 requested = 2.90 del1 = 7.24 del2 = 42.11 arcsecpmm = 1./0.725 loadct,0 invct sz=size(image2) xmax=sz(2) ymax=sz(1) xs=(findgen(sz(2)) - xmax) * platescale ys=(findgen(sz(1)) - ymax) * platescale display2,(image2>(0)<(80)),/asp,/nolabel,/noticks ; Trig for drawing box: ; --------------------- angle = positionangle*!PI/180. + 0.01107 delta2 = (requested + del1) * arcsecpmm / platescale delta1 = (requested + del2) * arcsecpmm / platescale delta = delta1 + delta2 phi1 = slitwidth / 2 * tan(angle) phi2 = slitwidth / 2 / cos(angle) x1 = x0 + ((delta2 + phi1)*sin(angle)) - phi2 y1 = y0 - (delta2 + phi1)*cos(angle) x3 = x1 - (delta*sin(angle)) y3 = y1 + (delta*cos(angle)) plots,x1,y1 plots,x1+(slitwidth*cos(angle)),y1+(slitwidth*sin(angle)),/continue,thick=1 plots,x1,y1 plots,x3,y3,/continue,thick=1 plots,x3+(slitwidth*cos(angle)),y3+(slitwidth*sin(angle)),/continue,thick=1 plots,x1+(slitwidth*cos(angle)),y1+(slitwidth*sin(angle)),/continue,thick=1 ; Thick solid box around image with title: ; ---------------------------------------- plots,0,0 plots,0,sz(2)+1,/continue,thick=5 plots,sz(1)+1,sz(2)+1,/continue,thick=5 plots,sz(1)+1,0,/continue,thick=5 plots,0,0,/continue,thick=5 xyouts,5,sz(2)+10,'HDF 3-951.1 98feb (hawaii)',charsize=1.2 ; Scale bar (barx,bary is left edge of bar): ; ------------------------------------------ barx = 50 bary = 700 plots,barx,bary plots,barx+250,bary,/continue,thick=1 xyouts,barx+110,bary+10,'10"',charsize=1.2 plots,barx,bary-10 plots,barx,bary+10,/continue,thick=1 plots,barx+250,bary-10 plots,barx+250,bary+10,/continue,thick=1 ;ps_close end