Changeset 459 for sans/Dev/trunk/NCNR_User_Procedures
 Timestamp:
 Dec 3, 2008 12:49:15 PM (14 years ago)
 Location:
 sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r457 r459 601 601 End 602 602 603 //phi is defined from +x axis, proceeding CCW around [0,2Pi]604 Threadsafe Function FindPhi(vx,vy)605 variable vx,vy606 607 variable phi608 609 phi = atan(vy/vx) //returns a value from pi/2 to pi/2610 611 // special cases612 if(vx==0 && vy > 0)613 return(pi/2)614 endif615 if(vx==0 && vy < 0)616 return(3*pi/2)617 endif618 if(vx >= 0 && vy == 0)619 return(0)620 endif621 if(vx < 0 && vy == 0)622 return(pi)623 endif624 625 626 627 if(vx > 0 && vy > 0)628 return(phi)629 endif630 if(vx < 0 && vy > 0)631 return(abs(phi) + pi/2)632 endif633 if(vx < 0 && vy < 0)634 return(phi + pi)635 endif636 if( vx > 0 && vy < 0)637 return(abs(phi) + 3*pi/2)638 endif639 640 return(phi)641 end642 603 643 604 
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/RawWindowHook.ipf
r418 r459 242 242 Variable xctr=reals[16],yctr=reals[17],sdd=reals[18],lam=reals[26],pixSize=reals[13]/10 243 243 Variable/G root:myGlobals:gQQ = CalcQval(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) 244 Variable/G root:myGlobals:gQX = CalcQX(xaxval+1, xctr,sdd,lam,pixSize)245 Variable/G root:myGlobals:gQY = CalcQY( yaxval+1,yctr,sdd,lam,pixSize)244 Variable/G root:myGlobals:gQX = CalcQX(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) 245 Variable/G root:myGlobals:gQY = CalcQY(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSize) 246 246 else 247 247 Variable/G root:myGlobals:gQQ = 0 … … 268 268 //sdd is in meters 269 269 //wavelength is in Angstroms 270 //returned qvalue is in 1/Angstroms 271 // 272 // generalized to read the detector pixel dimension from the file header... 270 // 271 //returned magnitude of Q is in 1/Angstroms 272 // 273 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) 273 274 // 274 275 Function CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 275 276 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 276 277 277 Variable dx,dy,thetax,thetay,qval,qx,qy 278 279 // Wave realW=$"root:Packages:NIST:raw:realsRead" 280 // Variable pixSizeX = realW[10]/10 //header is in mm, want cm 281 // Variable pixSizeY = realW[13]/10 //header is in mm, want cm 278 Variable dx,dy,qval,theta,dist 279 282 280 Variable pixSizeX=pixSize 283 281 Variable pixSizeY=pixSize … … 286 284 dx = (xaxval  xctr)*pixSizeX //delta x in cm 287 285 dy = (yaxval  yctr)*pixSizeY //delta y in cm 288 thetax = atan(dx/sdd)289 thetay = atan(dy/sdd)290 qx = 4*Pi/lam*sin(thetax/2)291 qy = 4*Pi/lam*sin(thetay/2) 292 qval = sqrt(qx^2 + qy^2)286 dist = sqrt(dx^2 + dy^2) 287 288 theta = atan(dist/sdd) 289 290 qval = 4*Pi/lam*sin(theta/2) 293 291 294 292 return qval … … 299 297 //ALL inputs are in detector coordinates 300 298 // 301 // generalized to read the detector pixel dimension from the file header...302 // 303 Function CalcQX(xaxval,xctr,sdd,lam,pixSize) 304 Variable xaxval,xctr,sdd,lam,pixSize 305 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 306 //sdd is in meters 307 //wavelength is in Angstroms 308 309 // Wave realW=$"root:Packages:NIST:raw:realsRead" 310 // Variable pixSize = realW[10]/10 //header is in mm, want cm 311 312 Variable dx,thetax,qx299 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 300 //sdd is in meters 301 //wavelength is in Angstroms 302 // 303 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) 304 // 305 Function CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 306 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 307 308 Variable qx,qval,phi,dx,dy 309 310 qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 313 311 314 312 sdd *=100 //convert to cm 315 dx = (xaxval  xctr)*pixSize //delta x in cm 316 thetax = atan(dx/sdd) 317 qx = 4*Pi/lam*sin(thetax/2) 313 dx = (xaxval  xctr)*pixSize //delta x in cm 314 dy = (yaxval  yctr)*pixSize //delta y in cm 315 phi = FindPhi(dx,dy) 316 317 qx = qval*cos(phi) 318 318 319 319 return qx … … 323 323 //input/output is the same as CalcQval() 324 324 //ALL inputs are in detector coordinates 325 // 326 // generalized to read the detector pixel dimension from the file header... 327 // 328 Function CalcQY(yaxval,yctr,sdd,lam,pixSize) 329 Variable yaxval,yctr,sdd,lam,pixSize 330 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 331 //sdd is in meters 332 //wavelength is in Angstroms 333 334 // Wave realW=$"root:Packages:NIST:raw:realsRead" 335 // Variable pixSize = realW[13]/10 //header is in mm, want cm 336 337 Variable dy,thetay,qy 325 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 326 //sdd is in meters 327 //wavelength is in Angstroms 328 // 329 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) 330 // 331 Function CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 332 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 333 334 Variable dy,qval,dx,phi,qy 335 336 qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 338 337 339 338 sdd *=100 //convert to cm 339 dx = (xaxval  xctr)*pixSize //delta x in cm 340 340 dy = (yaxval  yctr)*pixSize //delta y in cm 341 thetay = atan(dy/sdd) 342 qy = 4*Pi/lam*sin(thetay/2) 341 phi = FindPhi(dx,dy) 342 343 qy = qval*sin(phi) 343 344 344 345 return qy 345 346 End 347 348 349 //phi is defined from +x axis, proceeding CCW around [0,2Pi] 350 Threadsafe Function FindPhi(vx,vy) 351 variable vx,vy 352 353 variable phi 354 355 phi = atan(vy/vx) //returns a value from pi/2 to pi/2 356 357 // special cases 358 if(vx==0 && vy > 0) 359 return(pi/2) 360 endif 361 if(vx==0 && vy < 0) 362 return(3*pi/2) 363 endif 364 if(vx >= 0 && vy == 0) 365 return(0) 366 endif 367 if(vx < 0 && vy == 0) 368 return(pi) 369 endif 370 371 372 if(vx > 0 && vy > 0) 373 return(phi) 374 endif 375 if(vx < 0 && vy > 0) 376 return(phi + pi) 377 endif 378 if(vx < 0 && vy < 0) 379 return(phi + pi) 380 endif 381 if( vx > 0 && vy < 0) 382 return(phi + 2*pi) 383 endif 384 385 return(phi) 386 end 387 346 388 347 389 //function to set the qaxis scaling after the data has been read in … … 367 409 Variable maxX,minX,maxY,minY 368 410 369 minX = CalcQX(1, xctr,sdd,lam,pixSize)370 maxX = CalcQX(pixelsX, xctr,sdd,lam,pixSize)411 minX = CalcQX(1,yctr,xctr,yctr,sdd,lam,pixSize) 412 maxX = CalcQX(pixelsX,yctr,xctr,yctr,sdd,lam,pixSize) 371 413 SetScale/I x minX,maxX,"",qx 372 414 373 minY = CalcQY( 1,yctr,sdd,lam,pixSize)374 maxY = CalcQY( pixelsY,yctr,sdd,lam,pixSize)415 minY = CalcQY(xctr,1,xctr,yctr,sdd,lam,pixSize) 416 maxY = CalcQY(xctr,pixelsY,xctr,yctr,sdd,lam,pixSize) 375 417 qy[0] = minY 376 418 qy[1] = maxY … … 383 425 value = !(value) 384 426 End 385 
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteQIS.ipf
r418 r459 737 737 738 738 Duplicate/O data,qx_val,qy_val,z_val 739 740 // Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val 741 // MyMat2XYZ(data,qx_val,qy_val,z_val) //x and y are [p][q] indexes, not qvals yet 742 743 qx_val = CalcQx(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) //+1 converts to detector coordinate system 744 qy_val = CalcQy(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 745 739 746 Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val 740 MyMat2XYZ(data,qx_val,qy_val,z_val) //x and y are [p][q] indexes, not qvals yet741 742 qx_val = CalcQx(qx_val+1,rw[16],rw[18],rw[26],rw[13]/10) //+1 converts to detector coordinate system743 qy_val = CalcQy(qy_val+1,rw[17],rw[18],rw[26],rw[13]/10)744 747 745 748 //not democompatible, but approx 8x faster!! … … 762 765 763 766 764 Function MyMat2XYZ(mat,xw,yw,zw)765 WAVE mat,xw,yw,zw766 767 NVAR pixelsX = root:myGlobals:gNPixelsX768 NVAR pixelsY = root:myGlobals:gNPixelsY769 770 xw= mod(p,pixelsX) // X varies quickly771 yw= floor(p/pixelsY) // Y varies slowly772 zw= mat(xw[p])(yw[p])773 774 End767 //Function MyMat2XYZ(mat,xw,yw,zw) 768 // WAVE mat,xw,yw,zw 769 // 770 // NVAR pixelsX = root:myGlobals:gNPixelsX 771 // NVAR pixelsY = root:myGlobals:gNPixelsY 772 // 773 // xw= mod(p,pixelsX) // X varies quickly 774 // yw= floor(p/pixelsY) // Y varies slowly 775 // zw= mat(xw[p])(yw[p]) 776 // 777 //End 775 778 776 779 //converts xyz triple to a matrix … … 843 846 return outputPath 844 847 End 845
Note: See TracChangeset
for help on using the changeset viewer.