# Changeset 459 for sans/Dev/trunk/NCNR_User_Procedures/Reduction

Ignore:
Timestamp:
Dec 3, 2008 12:49:15 PM (14 years ago)
Message:

Fixes from Lionel's bug in the calculation of Qx and Qy. Qx and Qy were not being properly calculated as components of Q and phi (azimuthal angle). Only an effect at the largest q-values (> 0.3) and even then, only in the 3rd decimal place.This incorrect calculation was only visible on the 2D data display, and in the QxQy? ASCII export. Not a terrible bug, not worth immediate release of a patch.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
3 edited

Unmodified
Added
Removed
• ## sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf

 r457 End //phi is defined from +x axis, proceeding CCW around [0,2Pi] Threadsafe Function FindPhi(vx,vy) variable vx,vy variable phi phi = atan(vy/vx)               //returns a value from -pi/2 to pi/2 // special cases if(vx==0 && vy > 0) return(pi/2) endif if(vx==0 && vy < 0) return(3*pi/2) endif if(vx >= 0 && vy == 0) return(0) endif if(vx < 0 && vy == 0) return(pi) endif if(vx > 0 && vy > 0) return(phi) endif if(vx < 0 && vy > 0) return(abs(phi) + pi/2) endif if(vx < 0 && vy < 0) return(phi + pi) endif if( vx > 0 && vy < 0) return(abs(phi) + 3*pi/2) endif return(phi) end
• ## sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/RawWindowHook.ipf

 r418 Variable xctr=reals[16],yctr=reals[17],sdd=reals[18],lam=reals[26],pixSize=reals[13]/10 Variable/G root:myGlobals:gQQ = CalcQval(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) Variable/G root:myGlobals:gQX = CalcQX(xaxval+1,xctr,sdd,lam,pixSize) Variable/G root:myGlobals:gQY = CalcQY(yaxval+1,yctr,sdd,lam,pixSize) Variable/G root:myGlobals:gQX = CalcQX(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) Variable/G root:myGlobals:gQY = CalcQY(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) else Variable/G root:myGlobals:gQQ = 0 //sdd is in meters //wavelength is in Angstroms //returned q-value is in 1/Angstroms // // generalized to read the detector pixel dimension from the file header... // //returned magnitude of Q is in 1/Angstroms // // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) // Function CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize Variable dx,dy,thetax,thetay,qval,qx,qy //      Wave realW=\$"root:Packages:NIST:raw:realsRead" //      Variable pixSizeX = realW[10]/10                //header is in mm, want cm //      Variable pixSizeY = realW[13]/10                //header is in mm, want cm Variable dx,dy,qval,theta,dist Variable pixSizeX=pixSize Variable pixSizeY=pixSize dx = (xaxval - xctr)*pixSizeX           //delta x in cm dy = (yaxval - yctr)*pixSizeY           //delta y in cm thetax = atan(dx/sdd) thetay = atan(dy/sdd) qx = 4*Pi/lam*sin(thetax/2) qy = 4*Pi/lam*sin(thetay/2) qval = sqrt(qx^2 + qy^2) dist = sqrt(dx^2 + dy^2) theta = atan(dist/sdd) qval = 4*Pi/lam*sin(theta/2) return qval //ALL inputs are in detector coordinates // // generalized to read the detector pixel dimension from the file header... // Function CalcQX(xaxval,xctr,sdd,lam,pixSize) Variable xaxval,xctr,sdd,lam,pixSize //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector //sdd is in meters //wavelength is in Angstroms //      Wave realW=\$"root:Packages:NIST:raw:realsRead" //      Variable pixSize = realW[10]/10         //header is in mm, want cm Variable dx,thetax,qx //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector //sdd is in meters //wavelength is in Angstroms // // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) // Function CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize Variable qx,qval,phi,dx,dy qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) sdd *=100               //convert to cm dx = (xaxval - xctr)*pixSize    //delta x in cm thetax = atan(dx/sdd) qx = 4*Pi/lam*sin(thetax/2) dx = (xaxval - xctr)*pixSize            //delta x in cm dy = (yaxval - yctr)*pixSize            //delta y in cm phi = FindPhi(dx,dy) qx = qval*cos(phi) return qx //input/output is the same as CalcQval() //ALL inputs are in detector coordinates // // generalized to read the detector pixel dimension from the file header... // Function CalcQY(yaxval,yctr,sdd,lam,pixSize) Variable yaxval,yctr,sdd,lam,pixSize //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector //sdd is in meters //wavelength is in Angstroms //      Wave realW=\$"root:Packages:NIST:raw:realsRead" //      Variable pixSize = realW[13]/10         //header is in mm, want cm Variable dy,thetay,qy //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector //sdd is in meters //wavelength is in Angstroms // // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) // Function CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize Variable dy,qval,dx,phi,qy qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) sdd *=100               //convert to cm dx = (xaxval - xctr)*pixSize            //delta x in cm dy = (yaxval - yctr)*pixSize            //delta y in cm thetay = atan(dy/sdd) qy = 4*Pi/lam*sin(thetay/2) phi = FindPhi(dx,dy) qy = qval*sin(phi) return qy End //phi is defined from +x axis, proceeding CCW around [0,2Pi] Threadsafe Function FindPhi(vx,vy) variable vx,vy variable phi phi = atan(vy/vx)               //returns a value from -pi/2 to pi/2 // special cases if(vx==0 && vy > 0) return(pi/2) endif if(vx==0 && vy < 0) return(3*pi/2) endif if(vx >= 0 && vy == 0) return(0) endif if(vx < 0 && vy == 0) return(pi) endif if(vx > 0 && vy > 0) return(phi) endif if(vx < 0 && vy > 0) return(phi + pi) endif if(vx < 0 && vy < 0) return(phi + pi) endif if( vx > 0 && vy < 0) return(phi + 2*pi) endif return(phi) end //function to set the q-axis scaling after the data has been read in Variable maxX,minX,maxY,minY minX = CalcQX(1,xctr,sdd,lam,pixSize) maxX = CalcQX(pixelsX,xctr,sdd,lam,pixSize) minX = CalcQX(1,yctr,xctr,yctr,sdd,lam,pixSize) maxX = CalcQX(pixelsX,yctr,xctr,yctr,sdd,lam,pixSize) SetScale/I x minX,maxX,"",qx minY = CalcQY(1,yctr,sdd,lam,pixSize) maxY = CalcQY(pixelsY,yctr,sdd,lam,pixSize) minY = CalcQY(xctr,1,xctr,yctr,sdd,lam,pixSize) maxY = CalcQY(xctr,pixelsY,xctr,yctr,sdd,lam,pixSize) qy[0] = minY qy[1] = maxY value = !(value) End
• ## sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteQIS.ipf

 r418 Duplicate/O data,qx_val,qy_val,z_val //      Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val //      MyMat2XYZ(data,qx_val,qy_val,z_val)             //x and y are [p][q] indexes, not q-vals yet qx_val = CalcQx(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10)          //+1 converts to detector coordinate system qy_val = CalcQy(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val MyMat2XYZ(data,qx_val,qy_val,z_val)             //x and y are [p][q] indexes, not q-vals yet qx_val = CalcQx(qx_val+1,rw[16],rw[18],rw[26],rw[13]/10)                //+1 converts to detector coordinate system qy_val = CalcQy(qy_val+1,rw[17],rw[18],rw[26],rw[13]/10) //not demo-compatible, but approx 8x faster!! Function MyMat2XYZ(mat,xw,yw,zw) WAVE mat,xw,yw,zw NVAR pixelsX = root:myGlobals:gNPixelsX NVAR pixelsY = root:myGlobals:gNPixelsY xw= mod(p,pixelsX)              // X varies quickly yw= floor(p/pixelsY)    // Y varies slowly zw= mat(xw[p])(yw[p]) End //Function MyMat2XYZ(mat,xw,yw,zw) //      WAVE mat,xw,yw,zw // //      NVAR pixelsX = root:myGlobals:gNPixelsX //      NVAR pixelsY = root:myGlobals:gNPixelsY // //      xw= mod(p,pixelsX)              // X varies quickly //      yw= floor(p/pixelsY)    // Y varies slowly //      zw= mat(xw[p])(yw[p]) // //End //converts xyz triple to a matrix return outputPath End
Note: See TracChangeset for help on using the changeset viewer.