- Timestamp:
- Apr 16, 2018 10:50:33 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WhiteBeamSmear.ipf
r1091 r1095 33 33 // -- a significant problem with using the coef waves that are used in the wrapper are that 34 34 // they are set up with a dependency, so doing the WB calculation also does the "regular" 35 // calculation, doubling the time required... 36 37 35 // smeared calculation, doubling the time required... 36 37 38 // 39 // needs V_DummyFunctions for the FUNCREF to work - since it fails if I simply call the XOP 40 // 38 41 // 39 42 // SANSModel_proto(w,x) is in GaussUtils_v40.ipf … … 48 51 // 49 52 // 50 Macro V_Calc_WB_Smearing ()53 Macro V_Calc_WB_Smearing_top() 51 54 52 55 String folderStr,funcStr,coefStr … … 61 64 coefStr=S_Value 62 65 63 V_DoWavelengthIntegral(folderStr,funcStr,coefStr) 64 65 SetDataFolder root: 66 End 66 V_DoWavelengthIntegral_top(folderStr,funcStr,coefStr) 67 68 SetDataFolder root: 69 End 70 71 72 Macro V_Calc_WB_Smearing_mid() 73 74 String folderStr,funcStr,coefStr 75 76 ControlInfo/W=WrapperPanel popup_0 77 folderStr=S_Value 78 79 ControlInfo/W=WrapperPanel popup_1 80 funcStr=S_Value 81 82 ControlInfo/W=WrapperPanel popup_2 83 coefStr=S_Value 84 85 V_DoWavelengthIntegral_mid(folderStr,funcStr,coefStr) 86 87 SetDataFolder root: 88 End 89 90 Macro V_Calc_WB_Smearing_interp() 91 92 String folderStr,funcStr,coefStr 93 94 ControlInfo/W=WrapperPanel popup_0 95 folderStr=S_Value 96 97 ControlInfo/W=WrapperPanel popup_1 98 funcStr=S_Value 99 100 ControlInfo/W=WrapperPanel popup_2 101 coefStr=S_Value 102 103 V_DoWavelengthIntegral_interp(folderStr,funcStr,coefStr) 104 105 SetDataFolder root: 106 End 107 108 Macro V_Calc_WB_Smearing_triang() 109 110 String folderStr,funcStr,coefStr 111 112 ControlInfo/W=WrapperPanel popup_0 113 folderStr=S_Value 114 115 ControlInfo/W=WrapperPanel popup_1 116 funcStr=S_Value 117 118 ControlInfo/W=WrapperPanel popup_2 119 coefStr=S_Value 120 121 V_DoWavelengthIntegral_triang(folderStr,funcStr,coefStr) 122 123 SetDataFolder root: 124 End 125 67 126 68 127 69 128 // uses built-in Integrate1d() 70 129 // 71 Function V_DoWavelengthIntegral (folderStr,funcStr,coefStr)130 Function V_DoWavelengthIntegral_top(folderStr,funcStr,coefStr) 72 131 String folderStr,funcStr,coefStr 73 132 … … 83 142 84 143 // make a wave for the answer 85 Duplicate/O qvals answer_Rom_WB 144 Duplicate/O qvals answer_Rom_WB_top 86 145 87 146 // do the integration … … 97 156 // upLim = 8.37/5.3 98 157 // 99 // // using the interpolated distribution ( change the function call)158 // // using the interpolated distribution (must change the function call) 100 159 // lolim = 3/5.3 101 160 // uplim = 9/5.3 102 161 103 // using the "tr angular" distribution (cange the function call)104 loLim = 4/5.3105 upLim = 8/5.3106 107 answer_Rom_WB = Integrate_BuiltIn(cw,loLim,upLim,qVals)162 // using the "triangular" distribution (must change the function call) 163 // loLim = 4/5.3 164 // upLim = 8/5.3 165 166 answer_Rom_WB_top = V_Integrate_BuiltIn_top(cw,loLim,upLim,qVals) 108 167 109 168 // why do I need this? Is this because this is defined as the mean of the distribution 110 169 // and is needed to normalize the integral? verify this on paper. 111 answer_Rom_WB *= 5.3170 answer_Rom_WB_top *= 5.3 112 171 113 172 // normalize the integral 114 answer_Rom_WB /= 20926 // "top" of peaks173 answer_Rom_WB_top /= 20926 // "top" of peaks 115 174 // answer_Rom_WB /= 19933 // "middle" of peaks 116 175 // answer_Rom_WB /= 20051 // interpolated distribution 117 176 // answer_Rom_WB /= 1 // triangular distribution (it's already normalized) 177 178 // additional normalization??? 179 answer_Rom_WB_top /= 1.05 // 118 180 119 181 SetDataFolder root: … … 121 183 return 0 122 184 End 185 186 187 // uses built-in Integrate1d() 188 // 189 Function V_DoWavelengthIntegral_mid(folderStr,funcStr,coefStr) 190 String folderStr,funcStr,coefStr 191 192 SetDataFolder $("root:"+folderStr) 193 194 // gather the input waves 195 WAVE qVals = $(folderStr+"_q") 196 // WAVE cw = smear_coef_BroadPeak 197 WAVE cw = $coefStr 198 199 funcStr = V_getXFuncStrFromCoef(cw)+"_" //get the modelX name, tag on "_" 200 String/G root:gFunctionString = funcStr // need a global reference to pass to Integrate1D 201 202 // make a wave for the answer 203 Duplicate/O qvals answer_Rom_WB_mid 204 205 // do the integration 206 Variable loLim,upLim 207 208 // define limits based on lo/mean, hi/mean of the wavelength distribution 209 // using the empirical definition, "top" of the peaks 210 // loLim = 3.37/5.3 211 // upLim = 8.25/5.3 212 213 // // using the "middle" 214 loLim = 3.37/5.3 215 upLim = 8.37/5.3 216 // 217 // // using the interpolated distribution (must change the function call) 218 // lolim = 3/5.3 219 // uplim = 9/5.3 220 221 // using the "triangular" distribution (must change the function call) 222 // loLim = 4/5.3 223 // upLim = 8/5.3 224 225 answer_Rom_WB_mid = V_Integrate_BuiltIn_mid(cw,loLim,upLim,qVals) 226 227 // why do I need this? Is this because this is defined as the mean of the distribution 228 // and is needed to normalize the integral? verify this on paper. 229 answer_Rom_WB_mid *= 5.3 230 231 // normalize the integral 232 // answer_Rom_WB /= 20926 // "top" of peaks 233 answer_Rom_WB_mid /= 19933 // "middle" of peaks 234 // answer_Rom_WB /= 20051 // interpolated distribution 235 // answer_Rom_WB /= 1 // triangular distribution (it's already normalized) 236 237 // additional normalization??? 238 answer_Rom_WB_mid /= 1.05 // "middle" of peaks 239 240 SetDataFolder root: 241 242 return 0 243 End 244 245 // uses built-in Integrate1d() 246 // 247 Function V_DoWavelengthIntegral_interp(folderStr,funcStr,coefStr) 248 String folderStr,funcStr,coefStr 249 250 SetDataFolder $("root:"+folderStr) 251 252 // gather the input waves 253 WAVE qVals = $(folderStr+"_q") 254 // WAVE cw = smear_coef_BroadPeak 255 WAVE cw = $coefStr 256 257 funcStr = V_getXFuncStrFromCoef(cw)+"_" //get the modelX name, tag on "_" 258 String/G root:gFunctionString = funcStr // need a global reference to pass to Integrate1D 259 260 // make a wave for the answer 261 Duplicate/O qvals answer_Rom_WB_interp 262 263 // do the integration 264 Variable loLim,upLim 265 266 // define limits based on lo/mean, hi/mean of the wavelength distribution 267 // using the empirical definition, "top" of the peaks 268 // loLim = 3.37/5.3 269 // upLim = 8.25/5.3 270 271 // // using the "middle" 272 // loLim = 3.37/5.3 273 // upLim = 8.37/5.3 274 // 275 // // using the interpolated distribution (must change the function call) 276 lolim = 3/5.3 277 uplim = 9/5.3 278 279 // using the "triangular" distribution (must change the function call) 280 // loLim = 4/5.3 281 // upLim = 8/5.3 282 283 answer_Rom_WB_interp = V_Integrate_BuiltIn_interp(cw,loLim,upLim,qVals) 284 285 // why do I need this? Is this because this is defined as the mean of the distribution 286 // and is needed to normalize the integral? verify this on paper. 287 answer_Rom_WB_interp *= 5.3 288 289 // normalize the integral 290 // answer_Rom_WB /= 20926 // "top" of peaks 291 // answer_Rom_WB /= 19933 // "middle" of peaks 292 answer_Rom_WB_interp /= 20051 // interpolated distribution 293 // answer_Rom_WB /= 1 // triangular distribution (it's already normalized) 294 295 // additional normalization??? 296 answer_Rom_WB_interp /= 1.05 // "middle" of peaks 297 298 SetDataFolder root: 299 300 return 0 301 End 302 303 // uses built-in Integrate1d() 304 // 305 Function V_DoWavelengthIntegral_triang(folderStr,funcStr,coefStr) 306 String folderStr,funcStr,coefStr 307 308 SetDataFolder $("root:"+folderStr) 309 310 // gather the input waves 311 WAVE qVals = $(folderStr+"_q") 312 // WAVE cw = smear_coef_BroadPeak 313 WAVE cw = $coefStr 314 315 funcStr = V_getXFuncStrFromCoef(cw)+"_" //get the modelX name, tag on "_" 316 String/G root:gFunctionString = funcStr // need a global reference to pass to Integrate1D 317 318 // make a wave for the answer 319 Duplicate/O qvals answer_Rom_WB_triang 320 321 // do the integration 322 Variable loLim,upLim 323 324 // define limits based on lo/mean, hi/mean of the wavelength distribution 325 // using the empirical definition, "top" of the peaks 326 // loLim = 3.37/5.3 327 // upLim = 8.25/5.3 328 329 // // using the "middle" 330 // loLim = 3.37/5.3 331 // upLim = 8.37/5.3 332 // 333 // // using the interpolated distribution (must change the function call) 334 // lolim = 3/5.3 335 // uplim = 9/5.3 336 337 // using the "triangular" distribution (must change the function call) 338 loLim = 4/5.3 339 upLim = 8/5.3 340 341 answer_Rom_WB_triang = V_Integrate_BuiltIn_triangle(cw,loLim,upLim,qVals) 342 343 // why do I need this? Is this because this is defined as the mean of the distribution 344 // and is needed to normalize the integral? verify this on paper. 345 answer_Rom_WB_triang *= 5.3 346 347 // normalize the integral 348 // answer_Rom_WB /= 20926 // "top" of peaks 349 // answer_Rom_WB /= 19933 // "middle" of peaks 350 // answer_Rom_WB /= 20051 // interpolated distribution 351 answer_Rom_WB_triang /= 1 // triangular distribution (it's already normalized) 352 353 // additional normalization??? 354 answer_Rom_WB_triang /= 1.1 // 355 356 SetDataFolder root: 357 358 return 0 359 End 360 123 361 124 362 // … … 184 422 185 423 // val = V_WhiteBeamDist(dum*5.3)*BroadPeakX(cw,x/dum) 186 val = V_WhiteBeamDist(dum*5.3)*func(cw,x/dum)424 // val = V_WhiteBeamDist(dum*5.3)*func(cw,x/dum) 187 425 188 426 return (val) … … 200 438 // the trick here is that declaring the last qVal wave as a variable 201 439 // since this is implicitly called N times in the wave assignment of the answer wave 202 Function Integrate_BuiltIn(cw,loLim,upLim,qVal)440 Function V_Integrate_BuiltIn_top(cw,loLim,upLim,qVal) 203 441 Wave cw 204 442 Variable loLim,upLim … … 208 446 Variable ans 209 447 210 // ans = Integrate1D( intgrnd,lolim,uplim,2,0,cw) //adaptive quadrature211 ans = Integrate1D( intgrnd,lolim,uplim,1,0,cw) // Romberg integration448 // ans = Integrate1D(V_intgrnd_top,lolim,uplim,2,0,cw) //adaptive quadrature 449 ans = Integrate1D(V_intgrnd_top,lolim,uplim,1,0,cw) // Romberg integration 212 450 213 451 return ans 214 452 end 215 453 216 217 // 218 // See V_DunnyFunctions.ipf for the full list 454 // the trick here is that declaring the last qVal wave as a variable 455 // since this is implicitly called N times in the wave assignment of the answer wave 456 Function V_Integrate_BuiltIn_mid(cw,loLim,upLim,qVal) 457 Wave cw 458 Variable loLim,upLim 459 Variable qVal 460 461 Variable/G root:qq = qval 462 Variable ans 463 464 // ans = Integrate1D(V_intgrnd_mid,lolim,uplim,2,0,cw) //adaptive quadrature 465 ans = Integrate1D(V_intgrnd_mid,lolim,uplim,1,0,cw) // Romberg integration 466 467 return ans 468 end 469 470 // the trick here is that declaring the last qVal wave as a variable 471 // since this is implicitly called N times in the wave assignment of the answer wave 472 Function V_Integrate_BuiltIn_triangle(cw,loLim,upLim,qVal) 473 Wave cw 474 Variable loLim,upLim 475 Variable qVal 476 477 Variable/G root:qq = qval 478 Variable ans 479 480 // ans = Integrate1D(V_intgrnd_triangle,lolim,uplim,2,0,cw) //adaptive quadrature 481 ans = Integrate1D(V_intgrnd_triangle,lolim,uplim,1,0,cw) // Romberg integration 482 483 return ans 484 end 485 486 // the trick here is that declaring the last qVal wave as a variable 487 // since this is implicitly called N times in the wave assignment of the answer wave 488 Function V_Integrate_BuiltIn_interp(cw,loLim,upLim,qVal) 489 Wave cw 490 Variable loLim,upLim 491 Variable qVal 492 493 Variable/G root:qq = qval 494 Variable ans 495 496 // ans = Integrate1D(V_intgrnd_interp,lolim,uplim,2,0,cw) //adaptive quadrature 497 ans = Integrate1D(V_intgrnd_interp,lolim,uplim,1,0,cw) // Romberg integration 498 499 return ans 500 end 501 502 // 503 // See V_DummyFunctions.ipf for the full list 219 504 // 220 505 //Function BroadPeakX_(cw,x) … … 225 510 //end 226 511 227 Function intgrnd(cw,dum)512 Function V_intgrnd_top(cw,dum) 228 513 Wave cw 229 514 Variable dum // the dummy of the integration … … 238 523 239 524 // val = V_WhiteBeamDist(dum*5.3)*BroadPeakX(cw,qq/dum) 240 val = V_WhiteBeamDist (dum*5.3)*func(cw,qq/dum)525 val = V_WhiteBeamDist_top(dum*5.3)*func(cw,qq/dum) 241 526 242 527 // val = V_WhiteBeamInterp(dum*5.3)*func(cw,qq/dum) 528 529 return (val) 530 End 531 532 Function V_intgrnd_mid(cw,dum) 533 Wave cw 534 Variable dum // the dummy of the integration 535 536 Variable val 537 NVAR qq = root:qq //the q-value of the integration, not part of cw, so pass global 538 SVAR funcStr = root:gFunctionString 539 FUNCREF SANSModel_proto func = $funcStr 540 541 // val = (1-dum*5.3/8)*BroadPeakX(cw,qq/dum) 542 // val = (1-dum*5.3/8)*func(cw,qq/dum) 543 544 // val = V_WhiteBeamDist(dum*5.3)*BroadPeakX(cw,qq/dum) 545 val = V_WhiteBeamDist_mid(dum*5.3)*func(cw,qq/dum) 546 547 // val = V_WhiteBeamInterp(dum*5.3)*func(cw,qq/dum) 548 549 return (val) 550 End 551 552 Function V_intgrnd_triangle(cw,dum) 553 Wave cw 554 Variable dum // the dummy of the integration 555 556 Variable val 557 NVAR qq = root:qq //the q-value of the integration, not part of cw, so pass global 558 SVAR funcStr = root:gFunctionString 559 FUNCREF SANSModel_proto func = $funcStr 560 561 // val = (1-dum*5.3/8)*BroadPeakX(cw,qq/dum) 562 val = (1-dum*5.3/8)*func(cw,qq/dum) 563 564 // val = V_WhiteBeamDist(dum*5.3)*BroadPeakX(cw,qq/dum) 565 // val = V_WhiteBeamDist(dum*5.3)*func(cw,qq/dum) 566 567 // val = V_WhiteBeamInterp(dum*5.3)*func(cw,qq/dum) 568 569 return (val) 570 End 571 572 Function V_intgrnd_interp(cw,dum) 573 Wave cw 574 Variable dum // the dummy of the integration 575 576 Variable val 577 NVAR qq = root:qq //the q-value of the integration, not part of cw, so pass global 578 SVAR funcStr = root:gFunctionString 579 FUNCREF SANSModel_proto func = $funcStr 580 581 // val = (1-dum*5.3/8)*BroadPeakX(cw,qq/dum) 582 // val = (1-dum*5.3/8)*func(cw,qq/dum) 583 584 // val = V_WhiteBeamDist(dum*5.3)*BroadPeakX(cw,qq/dum) 585 // val = V_WhiteBeamDist(dum*5.3)*func(cw,qq/dum) 586 587 val = V_WhiteBeamInterp(dum*5.3)*func(cw,qq/dum) 243 588 244 589 return (val)
Note: See TracChangeset
for help on using the changeset viewer.