function fit_vis_2src,visin,xy1,xy2,sc,PLOT=plot,XYOFFSET=xyoffset,YFIT=yfit ; PURPOSE: ; Finds the best fit coefficients A,B for one-collimator visibility: ; Vis = A*exp(i*k.x1) + B*exp(i*k.x2) ; where RHESSI wavevector as a function of PA; and xy1,xy2 are vector ; source positions ; INPUTS: ; VISIN = visibility structure with the usual tags ; `XY1 and XY2 are vector positions of the sources (arcsec) relative ; to map center (unless XYOFFSET is set, dee below) ; SC = scalar in range 1-9 designating a subcollimator ; ; OPTIONAL INPUTS: ; If xyoffset is a named variable, the xyoffset is subtracted from xy1,xy2 ; Default =[0,0], for which xy1,xy2 must be relative to map center ; ; OUTPUTS: ; [A,B] ; ; HISTORY: ; EJS Dec 2006 ; revised to use regress.pro default,xyoffset,[0.,0.] x1=xy1[0]-xyoffset[0] ; if xyoffset not specified, we assume xy are relative to map center x2=xy2[0]-xyoffset[0] y1=xy1[1]-xyoffset[1] y2=xy1[1]-xyoffset[1] pitch = (hsi_grid_parameters()).pitch w=where(visin.isc eq sc,nw) if nw eq 0 then message,'No subcollimator visibilities exist' if nw lt 3 then message,'WARNING: 3 or fewer visibilities',/info u=visin[w].u v=visin[w].v PA=atan(v,u) i=complex(0,1) dx=[0,1,0,-1]*0.05 dy=[1,0,-1,0]*0.05 x1=-7.25 x2= 6.5 y1=-10.5 y2= 8.3 for mm=0,3 do begin for nn=0,3 do begin x_1=x1+dx[mm] & x_2=x2+dx[nn] y_1=y1+dy[mm] & y_2=y2+dy[nn] rho=exp(i*2*!pi*(u*x_1+v*y_1)) tau=exp(i*2*!pi*(u*x_2+v*y_2)) ;stop ; REGRESS solution XX1=[float(rho),imaginary(rho)] XX2=[float(tau),imaginary(tau)] XX=[transpose(XX1),transpose(XX2)] YY=[float(visin[w].obsvis),imaginary(visin[w].obsvis)] chisq=-1 & const=-1 & SIGMA=sigma & yfit=-1 AB=regress(XX,YY,CHISQ=chisq,CONST=const,SIGMA=sigma,YFIT=yfit) print,x_1,x_2,y_1,y_2,' chisq=',chisq endfor endfor stop if keyword_set(plot) then begin !p.multi=[0,1,2] plot,pa,abs(AB[0]*rho+AB[1]*tau) plot,pa,abs(visin[w].obsvis),psym=6 endif stop return,AB end restore,'MEMfit_sigvis_phzradset_2003-06-17_225310-225440E30-60ff.sav',/ver xyoffset=vis[0].xyoffset visin=vis xy1=[xpos[0],ypos[0]] xy2=[xpos[1],ypos[1]] sc=4 yfit=-1 AB=fit_vis_2src(visin,xy1,xy2,sc,/plot,XYOFFSET=xyoffset,yfit=yfit) A=ab[0] & B=ab[1] print,'A,B=',a,b end