- Timestamp:
- Jan 7, 2009 1:17:09 PM (14 years ago)
- Location:
- sans/Dev/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/RawWindowHook.ipf
r459 r467 271 271 //returned magnitude of Q is in 1/Angstroms 272 272 // 273 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...)274 //275 273 Function CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 276 274 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 277 275 278 Variable dx,dy,qval,t heta,dist276 Variable dx,dy,qval,two_theta,dist 279 277 280 278 Variable pixSizeX=pixSize … … 286 284 dist = sqrt(dx^2 + dy^2) 287 285 288 t heta = atan(dist/sdd)289 290 qval = 4*Pi/lam*sin(t heta/2)286 two_theta = atan(dist/sdd) 287 288 qval = 4*Pi/lam*sin(two_theta/2) 291 289 292 290 return qval … … 301 299 //wavelength is in Angstroms 302 300 // 303 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) 301 // repaired incorrect qx and qy calculation 3 dec 08 SRK (Lionel and C. Dewhurst) 302 // now properly accounts for qz 304 303 // 305 304 Function CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 306 305 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 307 306 308 Variable qx,qval,phi,dx,dy 307 Variable qx,qval,phi,dx,dy,dist,two_theta 309 308 310 309 qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) … … 315 314 phi = FindPhi(dx,dy) 316 315 317 qx = qval*cos(phi) 316 //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 317 dist = sqrt(dx^2 + dy^2) 318 two_theta = atan(dist/sdd) 319 320 qx = qval*cos(two_theta/2)*cos(phi) 318 321 319 322 return qx … … 327 330 //wavelength is in Angstroms 328 331 // 329 // repaired the dumb error of incorrect qx and qy calculation 3 dec 08 SRK (Lionel...) 332 // repaired incorrect qx and qy calculation 3 dec 08 SRK (Lionel and C. Dewhurst) 333 // now properly accounts for qz 330 334 // 331 335 Function CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 332 336 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 333 337 334 Variable dy,qval,dx,phi,qy 338 Variable dy,qval,dx,phi,qy,dist,two_theta 335 339 336 340 qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) … … 341 345 phi = FindPhi(dx,dy) 342 346 343 qy = qval*sin(phi) 347 //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 348 dist = sqrt(dx^2 + dy^2) 349 two_theta = atan(dist/sdd) 350 351 qy = qval*cos(two_theta/2)*sin(phi) 344 352 345 353 return qy 346 354 End 347 355 356 //calculates just the z-component of the q-vector, not measured on the detector 357 //input/output is the same as CalcQval() 358 //ALL inputs are in detector coordinates 359 //NOTE: detector locations passed in are pixel = 0.5cm real space on the Ordela detector 360 //sdd is in meters 361 //wavelength is in Angstroms 362 // 363 // not actually used, but here for completeness if anyone asks 364 // 365 Function CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 366 Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSize 367 368 Variable dy,qval,dx,phi,qz,dist,two_theta 369 370 qval = CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSize) 371 372 sdd *=100 //convert to cm 373 374 //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 375 dx = (xaxval - xctr)*pixSize //delta x in cm 376 dy = (yaxval - yctr)*pixSize //delta y in cm 377 dist = sqrt(dx^2 + dy^2) 378 two_theta = atan(dist/sdd) 379 380 qz = qval*sin(two_theta/2) 381 382 return qz 383 End 348 384 349 385 //phi is defined from +x axis, proceeding CCW around [0,2Pi] -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteQIS.ipf
r459 r467 736 736 // Endif 737 737 738 Duplicate/O data,qx_val,qy_val,z_val 738 Duplicate/O data,qx_val,qy_val,z_val,qval,qz_val 739 739 740 740 // Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val … … 743 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 744 qy_val = CalcQy(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 745 745 746 746 Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val 747 748 // un-comment these if you want to write out qz_val and qval too, then use the proper save command 749 // qval = CalcQval(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 750 // qz_val = CalcQz(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 751 // Redimension/N=(pixelsX*pixelsY) qz_val,qval 747 752 748 753 //not demo-compatible, but approx 8x faster!! 749 754 #if(cmpstr(stringbykey("IGORKIND",IgorInfo(0),":",";"),"pro") == 0) 750 Save/G/M="\r\n" labelWave,qx_val,qy_val,z_val as fullpath // /M=termStr specifies terminator 755 Save/G/M="\r\n" labelWave,qx_val,qy_val,z_val as fullpath // /M=termStr specifies terminator 756 // Save/G/M="\r\n" labelWave,qx_val,qy_val,qz_val,qval,z_val as fullpath // for debugging, write out everything 751 757 #else 752 758 Open refNum as fullpath … … 757 763 #endif 758 764 759 Killwaves/Z spWave,labelWave,qx_val,qy_val,z_val 765 Killwaves/Z spWave,labelWave,qx_val,qy_val,z_val,qval,qz_val 760 766 761 767 Print "QxQy_Export File written: ", GetFileNameFromPathNoSemi(fullPath)
Note: See TracChangeset
for help on using the changeset viewer.