- Timestamp:
- Dec 3, 2008 12:49:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 q-value 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 q-axis 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
Note: See TracChangeset
for help on using the changeset viewer.