#pragma rtGlobals=1 // Use modern global access method. #pragma IgorVersion=6.1 Function TestSmear_2D() Variable DX,NUM,X0,Y0,L1,L2,S1,S2,SIG_DET,DLAMB,LAMBDA DX = 0.5 num = 128 // x0 = 64 x0 = 114 y0 = 64 L1 = 300 //units of cm ?? L2 = 130 s1 = 5.0/2 s2 = 1.27/2 sig_det = 0.5 //not sure about this dlamb = 0.15 lambda = 6 Duplicate/O root:no_gravity_dat:no_gravity_dat_mat root:no_gravity_dat:John_mat Wave data=root:no_gravity_dat:John_mat SUB_SMEAR_2D(DX,NUM,X0,Y0,L1,L2,S1,S2,SIG_DET,DLAMB,LAMBDA,DATA) Duplicate/O root:no_gravity_dat:John_mat root:no_gravity_dat:John_mat_log Wave log_data=root:no_gravity_dat:John_mat_log log_data = log(data) end // I have changed the array indexing to [0,], so subtract 1 from the x0,Y0 center // to shift from detector coordinates to Igor array index // // // !! the wi values do not match what is written in John's notebook. Are these the // correct values for hermite integration?? // Function SUB_SMEAR_2D(DX,NUM,X0,Y0,L1,L2,S1,S2,SIG_DET,DLAMB,LAMBDA,DATA) //,Q_MODEL_NAME) Variable DX,NUM,X0,Y0,L1,L2,S1,S2,SIG_DET,DLAMB,LAMBDA Wave data Variable I,J,KI,KJ //integers Variable SUMm,THET0,Q0,R_PL,R_PD,Q0_PL,Q0_PD,LP,V_R,V_L Variable PHI,R0,SIGQ_R,SIGQ_A,Q_PL,Q_PD,DIF_PD_I Variable RES_I,RES_J,RES,DIF_PL_J,DIF_PD_J,DIF_PL_I // DIMENSION DATA(128,128),XI(3),WI(3) // EXTERNAL Q_MODEL_NAME // PARAMETER PI = 3.14159265 Variable N_QUAD = 3 Make/O/D xi_h = {.6167065887,1.889175877,3.324257432} Make/O/D wi_h = {.72462959522,.15706732032,.45300099055E-2} //C DATA XI/.4360774119,1.3358490740,2.3506049736/ // DATA XI/.6167065887,1.889175877,3.324257432/ // DATA WI/.72462959522,.15706732032,.45300099055E-2/ //C DX : PIXEL SIZE, CM //C NUM: NUMBER OF PIXELS ACROSS DETECTOR. (128) //C X0,Y0: BEAM CENTER, IN UNITS OF PIXELS. //C L1: SOURCE TO SAMPLE DISTANCE. //C L2: SAMPLE TO DETECTOR DISTANCE. //C S1: SOURCE APERTURE RADIUS. //C S2: SAMPLE APERTURE RADIUS. //C SIG_DET:STANDARD DEVIATION OF DETECTOR SPATIAL RESOLUTION. //C DLAMB: FWHM WAVLENGTH RESOLUTION. //C LAMBDA: MEAN WAVELENGTH. //C DATA: OUTPUT SMEARED ARRAY (NUM,NUM) Make/O/D/N=(128,128) sigQR, sigQA LP = 1 / ( 1/L1 + 1/L2 ) V_R = 0.25*(S1/L1)^2 + 0.25*(S2/LP)^2 + (SIG_DET/L2)^2 V_L = DLAMB^2/6. for(i=0;i 1) Abort "wave name is already in use" //executed only if name is in use elsewhere endif Wave wt = $weightStr Wave xi = $zStr // create the wave references endif Variable ii,jj,kk,ax,bx,ay,by,num Variable qx,qy,qz,qval,sqx,sqy,fs Variable qy_pt,qx_pt,res_x,res_y,res_tot,answer,sumIn,sumOut num=numpnts(s.qx) // end points of integration // limits are technically 0-inf, but wisely choose interesting region of q where R() is nonzero // +/- 3 sigq catches 99.73% of distrubution // change limits (and spacing of zi) at each evaluation based on R() //integration from va to vb Make/O/D/N=1 fcnRet,xptW,yPtw answer=0 //loop over q-values for(ii=0;ii 1) Abort "wave name is already in use" //executed only if name is in use elsewhere endif Wave wt = $weightStr Wave xi = $zStr // create the wave references endif Variable ii,jj,kk,ax,bx,ay,by,num Variable qx,qy,qz,qval,sqx,sqy,fs Variable qy_pt,qx_pt,res_x,res_y,res_tot,answer,sumIn,sumOut num=numpnts(s.qx) // end points of integration // limits are technically 0-inf, but wisely choose interesting region of q where R() is nonzero // +/- 3 sigq catches 99.73% of distrubution // change limits (and spacing of zi) at each evaluation based on R() //integration from va to vb Make/O/D/N=1 fcnRet,xptW,yPtw answer=0 //loop over q-values for(ii=0;ii