Changeset 551
- Timestamp:
- Sep 10, 2009 3:45:30 PM (13 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r544 r551 62 62 // 63 63 // 64 65 // setting the flag to 1 == 2D simulation 66 // any other value for flag == 1D simulation 67 // 68 // must remember to close/reopen the simulation control panel to get the correct panel 69 // 70 Function Set_2DMonteCarlo_Flag(value) 71 Variable value 72 73 NVAR flag=root:Packages:NIST:SAS:gDoMonteCarlo 74 flag=value 75 return(0) 76 end 64 77 65 78 // threaded call to the main function, adds up the individual runs, and returns what is to be displayed … … 175 188 results[3] = retWave[2] - linear_data[xc][yc] //# reaching detector minus Q(0) 176 189 results[4] = retWave[3]/retWave[1] //avg# times scattered 177 results[5] = retWave[4]/retWave[ 1] //single coherent fraction178 results[6] = retWave[5]/retWave[ 1] //double coherent fraction190 results[5] = retWave[4]/retWave[7] //single coherent fraction 191 results[6] = retWave[5]/retWave[7] //multiple coherent fraction 179 192 results[7] = retWave[6]/retWave[1] //multiple scatter fraction 180 193 results[8] = (retWave[0]-retWave[1])/retWave[0] //transmitted fraction … … 239 252 results[3] = retWave[2] - linear_data[xc][yc] //# reaching detector minus Q(0) 240 253 results[4] = retWave[3]/retWave[1] //avg# times scattered 241 results[5] = retWave[4]/retWave[ 1] //single coherent fraction242 results[6] = retWave[5]/retWave[ 1] //double coherent fraction254 results[5] = retWave[4]/retWave[7] //single coherent fraction 255 results[6] = retWave[5]/retWave[7] //double coherent fraction 243 256 results[7] = retWave[6]/retWave[1] //multiple scatter fraction 244 257 results[8] = (retWave[0]-retWave[1])/retWave[0] //transmitted fraction … … 288 301 Variable NSingleIncoherent,NSingleCoherent,NScatterEvents,incoherentEvent,coherentEvent 289 302 Variable NDoubleCoherent,NMultipleScatter,countIt,detEfficiency 303 Variable NMultipleCoherent,NCoherentEvents 290 304 291 305 detEfficiency = 1.0 //70% counting efficiency = 0.7 … … 351 365 NMultipleScatter = 0 352 366 NScatterEvents = 0 367 NMultipleCoherent = 0 368 NCoherentEvents = 0 353 369 354 370 //C INITIALIZE ARRAYS. … … 415 431 // IF(ran > (ratio1+ratio2) ) //C NEUTRON SCATTERED coherently 416 432 IF(ran > ratio) //C NEUTRON SCATTERED coherently 417 coherentEvent = 1433 coherentEvent += 1 418 434 FIND_THETA = 0 //false 419 435 DO … … 441 457 // phi and theta are random over the entire sphere of scattering 442 458 // !can't just choose random theta and phi, won't be random over sphere solid angle 443 incoherentEvent = 1459 incoherentEvent += 1 444 460 445 461 ran = abs(enoise(1)) //[0,1] … … 514 530 NMultipleScatter += 1 515 531 endif 532 if(coherentEvent >= 1 && incoherentEvent == 0) 533 NCoherentEvents += 1 534 endif 535 if(coherentEvent > 1 && incoherentEvent == 0) 536 NMultipleCoherent += 1 537 endif 538 539 516 540 //Print "n1,index (x,y) = ",n1,index, xpixel,ypixel 517 541 … … 534 558 results[1] = n2 535 559 results[2] = isOn 536 results[3] = NScatterEvents //sum of # of times that neutrons scattered 560 results[3] = NScatterEvents //sum of # of times that neutrons scattered (coh+incoh) 537 561 results[4] = NSingleCoherent //# of events that are single, coherent 538 results[5] = NDoubleCoherent 539 results[6] = NMultipleScatter //# of multiple scattering events 562 results[5] = NMultipleCoherent //# of scattered neutrons that are coherently scattered more than once 563 results[6] = NMultipleScatter //# of scattered neutrons that are scattered more than once (coh and/or incoh) 564 results[7] = NCoherentEvents //# of scattered neutrons that are scattered coherently one or more times 540 565 541 566 // Print "# absorbed = ",n3 … … 843 868 // RenameWindow #,T_results 844 869 // SetActiveSubwindow ## 845 EndMacro870 //EndMacro 846 871 847 872 // as a stand-alone panel, extra control bar (right) and subwindow implementations don't work right 848 873 // for various reasons... 849 874 Window MC_SASCALC() : Panel 875 876 // when opening the panel, set the raw counts check to 1 877 root:Packages:NIST:SAS:gRawCounts = 1 878 850 879 PauseUpdate; Silent 1 // building window... 851 880 NewPanel /W=(92,556,713,818)/K=1 as "SANS Simulator" … … 866 895 SetVariable setvar0_3,pos={105,484},size={50,20},disable=1 867 896 GroupBox group0,pos={15,42},size={267,130},title="Monte Carlo" 868 SetVariable cntVar,pos={1 90,73},size={80,15},proc=CountTimeSetVarProc,title="time(s)"897 SetVariable cntVar,pos={185,73},size={90,15},proc=CountTimeSetVarProc,title="time(s)" 869 898 SetVariable cntVar,format="%d" 870 899 SetVariable cntVar,limits={1,600,1},value= root:Packages:NIST:SAS:gCntTime … … 1264 1293 Button MC_button0,pos={17,181},size={130,20},proc=Sim_1D_DoItButtonProc,title="Do 1D Simulation" 1265 1294 Button MC_button0,fColor=(3,52428,1) 1295 Button MC_button1,pos={17,211},size={150,20},proc=Save_1DSimData,title="Save Simulated Data" 1266 1296 GroupBox group0,pos={15,42},size={280,130},title="Sample Setup" 1267 1297 CheckBox check0_1,pos={216,179},size={60,14},title="Yes Offset",variable= root:Packages:NIST:SAS:gDoTraceOffset … … 1369 1399 return 0 1370 1400 End 1401 1402 1403 // 1404 // 1405 // 1406 Function Save_1DSimData(ctrlName) : ButtonControl 1407 String ctrlName 1408 1409 String type="SAS",fullpath="" 1410 Variable dialog=1 //=1 will present dialog for name 1411 1412 String destStr="" 1413 destStr = "root:Packages:NIST:"+type 1414 1415 Variable refNum 1416 String formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n" 1417 String fname,ave="C",hdrStr1="",hdrStr2="" 1418 Variable step=1 1419 1420 If(1) 1421 //setup a "fake protocol" wave, sice I have no idea of the current state of the data 1422 Make/O/T/N=8 root:myGlobals:Protocols:SIMProtocol 1423 Wave/T SIMProtocol = $"root:myGlobals:Protocols:SIMProtocol" 1424 String junk="****SIMULATED DATA****" 1425 //stick in the fake protocol... 1426 NVAR ctTime = root:Packages:NIST:SAS:gCntTime 1427 NVAR totalCts = root:Packages:NIST:SAS:g_1DTotCts //summed counts (simulated) 1428 NVAR detCR = root:Packages:NIST:SAS:g_1DEstDetCR // estimated detector count rate 1429 NVAR fractScat = root:Packages:NIST:SAS:g_1DFracScatt 1430 1431 SIMProtocol[0] = junk 1432 SIMProtocol[1] = "\tCounting time (s) = "+num2str(ctTime) 1433 SIMProtocol[2] = "\tTotal detector counts = "+num2str(totalCts) 1434 SIMProtocol[3] = "\tDetector countrate (1/s) = "+num2str(detCR) 1435 SIMProtocol[4] = "\tFraction of beam scattered coherently = "+num2str(fractScat) 1436 SIMProtocol[5] = junk 1437 SIMProtocol[6] = "" 1438 SIMProtocol[7] = "" 1439 //set the global 1440 String/G root:myGlobals:Protocols:gProtoStr = "SIMProtocol" 1441 Endif 1442 1443 1444 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 1445 WAVE intw=$(destStr + ":integersRead") 1446 WAVE rw=$(destStr + ":realsRead") 1447 WAVE/T textw=$(destStr + ":textRead") 1448 WAVE qvals =$(destStr + ":qval") 1449 WAVE inten=$(destStr + ":aveint") 1450 WAVE sig=$(destStr + ":sigave") 1451 WAVE qbar = $(destStr + ":QBar") 1452 WAVE sigmaq = $(destStr + ":SigmaQ") 1453 WAVE fsubs = $(destStr + ":fSubS") 1454 1455 SVAR gProtoStr = root:myGlobals:Protocols:gProtoStr 1456 Wave/T proto=$("root:myGlobals:Protocols:"+gProtoStr) 1457 1458 //check each wave 1459 If(!(WaveExists(intw))) 1460 Abort "intw DNExist Save_1DSimData()" 1461 Endif 1462 If(!(WaveExists(rw))) 1463 Abort "rw DNExist Save_1DSimData()" 1464 Endif 1465 If(!(WaveExists(textw))) 1466 Abort "textw DNExist Save_1DSimData()" 1467 Endif 1468 If(!(WaveExists(qvals))) 1469 Abort "qvals DNExist Save_1DSimData()" 1470 Endif 1471 If(!(WaveExists(inten))) 1472 Abort "inten DNExist Save_1DSimData()" 1473 Endif 1474 If(!(WaveExists(sig))) 1475 Abort "sig DNExist Save_1DSimData()" 1476 Endif 1477 If(!(WaveExists(qbar))) 1478 Abort "qbar DNExist Save_1DSimData()" 1479 Endif 1480 If(!(WaveExists(sigmaq))) 1481 Abort "sigmaq DNExist Save_1DSimData()" 1482 Endif 1483 If(!(WaveExists(fsubs))) 1484 Abort "fsubs DNExist Save_1DSimData()" 1485 Endif 1486 If(!(WaveExists(proto))) 1487 Abort "current protocol wave DNExist Save_1DSimData()" 1488 Endif 1489 1490 //strings can be too long to print-- must trim to 255 chars 1491 Variable ii,num=8 1492 Make/O/T/N=(num) tempShortProto 1493 for(ii=0;ii<num;ii+=1) 1494 tempShortProto[ii] = (proto[ii])[0,240] 1495 endfor 1496 1497 if(dialog) 1498 PathInfo/S catPathName 1499 fullPath = DoSaveFileDialog("Save data as") 1500 If(cmpstr(fullPath,"")==0) 1501 //user cancel, don't write out a file 1502 Close/A 1503 Abort "no data file was written" 1504 Endif 1505 //Print "dialog fullpath = ",fullpath 1506 Endif 1507 1508 NVAR monCt = root:Packages:NIST:SAS:gImon 1509 NVAR thick = root:Packages:NIST:SAS:gThick 1510 NVAR trans = root:Packages:NIST:SAS:gSamTrans //for 1D, default value 1511 1512 1513 1514 hdrStr1 = num2str(monCt)+" "+num2str(rw[26])+" "+num2str(rw[19])+" "+num2str(rw[18]) 1515 hdrStr1 += " "+num2str(trans)+" "+num2str(thick) + ave +" "+num2str(step) + "\r\n" 1516 1517 hdrStr2 = num2str(rw[16])+" "+num2str(rw[17])+" "+num2str(rw[23])+" "+num2str(rw[24])+" " 1518 hdrStr2 += num2str(rw[25])+" "+num2str(rw[27])+" "+num2str(rw[21])+" "+"ORNL " + "\r\n" 1519 1520 //actually open the file here 1521 Open refNum as fullpath 1522 1523 //write out the standard header information 1524 fprintf refnum,"FILE: %s\t\t CREATED: %s\r\n","SIMULATED DATA",(date() +" "+ time()) 1525 fprintf refnum,"LABEL: %s\r\n","SIMULATED DATA" 1526 fprintf refnum,"MON CNT LAMBDA DET ANG DET DIST TRANS THICK AVE STEP\r\n" 1527 fprintf refnum,hdrStr1 1528 fprintf refnum,"BCENT(X,Y) A1(mm) A2(mm) A1A2DIST(m) DL/L BSTOP(mm) DET_TYP \r\n" 1529 fprintf refnum,hdrStr2 1530 // fprintf refnum,headerFormat,rw[0],rw[26],rw[19],rw[18],rw[4],rw[5],ave,step 1531 1532 //insert protocol information here 1533 //-1 list of sample files 1534 //0 - bkg 1535 //1 - emp 1536 //2 - div 1537 //3 - mask 1538 //4 - abs params c2-c5 1539 //5 - average params 1540 fprintf refnum, "SAM: %s\r\n",tempShortProto[0] 1541 fprintf refnum, "BGD: %s\r\n",tempShortProto[1] 1542 fprintf refnum, "EMP: %s\r\n",tempShortProto[2] 1543 fprintf refnum, "DIV: %s\r\n",tempShortProto[3] 1544 fprintf refnum, "MASK: %s\r\n",tempShortProto[4] 1545 fprintf refnum, "ABS: %s\r\n",tempShortProto[5] 1546 fprintf refnum, "Average Choices: %s\r\n",tempShortProto[6] 1547 1548 //write out the data columns 1549 fprintf refnum,"The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n" 1550 wfprintf refnum, formatStr, qvals,inten,sig,sigmaq,qbar,fsubs 1551 1552 Close refnum 1553 1554 SetDataFolder root: //(redundant) 1555 1556 //write confirmation of write operation to history area 1557 Print "Averaged File written: ", GetFileNameFromPathNoSemi(fullPath) 1558 KillWaves/Z tempShortProto 1559 1560 //clear the stuff that was created for case of saving files 1561 If(1) 1562 Killwaves/Z root:myGlobals:Protocols:SIMProtocol 1563 String/G root:myGlobals:Protocols:gProtoStr = "" 1564 Endif 1565 1566 1567 return(0) 1568 1569 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r545 r551 125 125 String/G root:Packages:NIST:SAS:gSavePrefix = "SIMUL" 126 126 Make/O/D/N=10 root:Packages:NIST:SAS:results = 0 127 Make/O/T/N=10 root:Packages:NIST:SAS:results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction double coherent","fraction multiple scattered","fraction transmitted","detector counts w/obeamstop"}127 Make/O/T/N=10 root:Packages:NIST:SAS:results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction multiple coherent","fraction multiple scattered","fraction transmitted","detector counts w/beamstop"} 128 128 129 129 Variable/G root:Packages:NIST:SAS:g_1DTotCts = 0 //summed counts (simulated) … … 148 148 //for plotting 149 149 Variable/G root:Packages:NIST:SAS:gFreezeCount=1 //start the count at 1 to keep Jeff happy 150 Variable/G root:Packages:NIST:SAS:gDoTraceOffset= 1// (1==Yes, offset 2^n), 0==turn off the offset150 Variable/G root:Packages:NIST:SAS:gDoTraceOffset=0 // (1==Yes, offset 2^n), 0==turn off the offset 151 151 152 152 End … … 719 719 endif 720 720 endif 721 NVAR doSim = root:Packages:NIST:SAS:doSimulation 722 doSim=1 721 723 else 722 724 //get rid of the controls (just try both) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/USANS_EmptyWaves.ipf
r547 r551 9 9 num=numpnts(w) 10 10 11 printf "Make/O/ N=%d %s\r\r",num,name11 printf "Make/O/D/N=%d %s\r\r",num,name 12 12 13 13 for(ii=0;ii<num;ii+=1) … … 23 23 24 24 //Write2Save(CR_EC_0p25Gd,"CR_0p25") 25 Make/O/ N=44 CR_0p2525 Make/O/D/N=44 CR_0p25 26 26 27 27 CR_0p25[0] = 3873.7 … … 72 72 // 73 73 ///Write2Save(Q_EC_0p25Gd,"Q_0p25") 74 Make/O/ N=44 Q_0p2574 Make/O/D/N=44 Q_0p25 75 75 76 76 Q_0p25[0] = 5.52469e-06 … … 120 120 121 121 //¥Write2Save(CR_EC_0p50Gd,"CR_0p50") 122 Make/O/ N=38 CR_0p50122 Make/O/D/N=38 CR_0p50 123 123 124 124 CR_0p50[0] = 15828.3 … … 162 162 163 163 //¥Write2Save(Q_EC_0p50Gd,"Q_0p50") 164 Make/O/ N=38 Q_0p50164 Make/O/D/N=38 Q_0p50 165 165 166 166 Q_0p50[0] = 3.68132e-06 … … 204 204 205 205 // ¥Write2Save(CR_EC_0p625Gd,"CR_0p625") 206 Make/O/ N=111 CR_0p625206 Make/O/D/N=111 CR_0p625 207 207 208 208 CR_0p625[0] = 21097 … … 319 319 320 320 //¥Write2Save(Q_EC_0p625Gd,"Q_0p625") 321 Make/O/ N=111 Q_0p625321 Make/O/D/N=111 Q_0p625 322 322 323 323 Q_0p625[0] = 4.51567e-06 … … 435 435 436 436 //¥Write2Save(CR_EB_1p75Cd,"CR_1p75") 437 Make/O/ N=62 CR_1p75437 Make/O/D/N=62 CR_1p75 438 438 439 439 CR_1p75[0] = 56049.9 … … 501 501 502 502 //¥Write2Save(Q_EB_1p75Cd,"Q_1p75") 503 Make/O/ N=62 Q_1p75503 Make/O/D/N=62 Q_1p75 504 504 505 505 Q_1p75[0] = 2.39312e-06 … … 567 567 568 568 //¥Write2Save(CR_EB_2p0Cd,"CR_2p0") 569 Make/O/ N=98 CR_2p0569 Make/O/D/N=98 CR_2p0 570 570 571 571 CR_2p0[0] = 56491 … … 669 669 670 670 //¥Write2Save(Q_EB_2p0Cd,"Q_2p0") 671 Make/O/ N=98 Q_2p0671 Make/O/D/N=98 Q_2p0 672 672 673 673 Q_2p0[0] = 1.4972e-06 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/U_CALC.ipf
r550 r551 15 15 // 16 16 // - more presets 17 // - fast ways to increase/decrease number of points 18 // - fast ways to increase/decrease counting time 19 // 20 // - plot as countrate, not absolute scale 21 // - 3e-5 cutoff 22 // - ? don't plot lowest angle range (but needs to be in the count time) 17 18 // 19 // X plot as countrate, not absolute scale 20 // X 3e-5 cutoff 21 // X ? don't plot lowest angle range (but needs to be in the count time) 23 22 // - need empty beam and empty cell count rate vs. aperture (Cd vs. Gd?) 24 23 // … … 28 27 // or at least compare to what the empty cell would give in the same count time 29 28 // 30 // model the direct beam?? currently the "red" region from -1 to 0.6 is almost entirely29 // -? model the direct beam?? currently the "red" region from -1 to 0.6 is almost entirely 31 30 // the primary beam, so it's a bit artificial (qmin is really ~ 3e-5) 32 31 // 33 32 34 33 // 35 // Need T_wide, T_rock, I peak for proper absolute scaling 34 // Need T_wide, T_rock, I peak for proper absolute scaling, but I don't know if it's really important 35 // to be able to simlulate to this extent 36 36 // 37 37 … … 103 103 Variable/G gCtTime6 = 2000 104 104 Variable/G gIncr6 = 2 105 106 Variable/G gAngLow7 = 50 107 Variable/G gAngHigh7 = 95 108 Variable/G gNumPts7 = 10 109 Variable/G gCtTime7 = 0 110 Variable/G gIncr7 = 5 105 111 106 112 // results, setup values … … 287 293 Variable pos=strsearch(platform,"WINDOWS",0) 288 294 if(pos >= 0) //windows 289 Display /W=(55,44, 955,544) /K=1295 Display /W=(55,44,855,450) /K=1 290 296 else //mac 291 297 Display /W=(55,44,1055,544) /K=1 … … 297 303 ControlBar/L 500 298 304 299 GroupBox group0,pos={5,1},size={493,1 59},title="Instrument Setup"300 GroupBox group1,pos={5,1 65},size={240,147},title="Sample Setup"301 GroupBox group2,pos={5,3 25},size={259,147},title="Results"305 GroupBox group0,pos={5,1},size={493,177},title="Instrument Setup" 306 GroupBox group1,pos={5,183},size={240,147},title="Sample Setup" 307 GroupBox group2,pos={5,343},size={259,147},title="Results" 302 308 303 309 PopupMenu popup0,pos={17,19},size={165,20},title="Sample Aperture Diam (in)" … … 316 322 SetVariable setvar1d,pos={left+299,top},size={100,15},title="# points",value= gNumPts1 317 323 SetVariable setvar1e,pos={left+399,top},size={93,15},title="count (s)",value= gCtTime1 318 SetVariable setvar1a,labelBack=(65535,32768,32768) 324 // SetVariable setvar1a,labelBack=(65535,32768,32768) //old rainbow 325 SetVariable setvar1a,labelBack=(49858,65535,65535) 319 326 320 327 pt += inc … … 324 331 SetVariable setvar2d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts2 325 332 SetVariable setvar2e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime2 326 SetVariable setvar2a labelBack=(65535,65533,32768) 333 // SetVariable setvar2a labelBack=(65535,65533,32768) //old rainbow 334 SetVariable setvar2a labelBack=(21074,8995,21074) 327 335 328 336 pt += inc … … 332 340 SetVariable setvar3d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts3 333 341 SetVariable setvar3e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime3 334 SetVariable setvar3a labelBack=(32769,65535,32768) 342 // SetVariable setvar3a labelBack=(32769,65535,32768) //old rainbow 343 SetVariable setvar3a labelBack=(0,60652,60652) 335 344 336 345 pt += inc … … 340 349 SetVariable setvar4d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts4 341 350 SetVariable setvar4e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime4 342 SetVariable setvar4a labelBack=(32768,65535,65535) 351 // SetVariable setvar4a labelBack=(32768,65535,65535) //old rainbow 352 SetVariable setvar4a labelBack=(0,51400,0) 343 353 344 354 pt += inc … … 348 358 SetVariable setvar5d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts5 349 359 SetVariable setvar5e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime5 350 SetVariable setvar5a labelBack=(32768,54615,65535) 360 // SetVariable setvar5a labelBack=(32768,54615,65535) //old rainbow 361 SetVariable setvar5a labelBack=(59367,49344,0) 351 362 352 363 pt += inc … … 356 367 SetVariable setvar6d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts6 357 368 SetVariable setvar6e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime6 358 SetVariable setvar6a labelBack=(44253,29492,58982) 369 // SetVariable setvar6a labelBack=(44253,29492,58982) //old rainbow 370 SetVariable setvar6a labelBack=(54998,0,0) 371 372 pt += inc 373 SetVariable setvar7a,pos={left+17,top+pt},size={90,15},title="theta min",value= gAngLow7 374 SetVariable setvar7b,pos={left+113,top+pt},size={89,15},title="theta max",value= gAngHigh7 375 SetVariable setvar7c,pos={left+209,top+pt},size={89,15},title="increm",value= gIncr7 376 SetVariable setvar7d,pos={left+299,top+pt},size={100,15},title="# points",value= gNumPts7 377 SetVariable setvar7e,pos={left+399,top+pt},size={93,15},title="count (s)",value= gCtTime7 378 // SetVariable setvar7a labelBack=(44253,29492,58982) //old rainbow 379 SetVariable setvar7a labelBack=(39321,21845,51657) 359 380 360 381 // the action procedures and limits/increments … … 365 386 SetVariable setvar5a proc=ThetaMinSetVarProc 366 387 SetVariable setvar6a proc=ThetaMinSetVarProc 388 SetVariable setvar7a proc=ThetaMinSetVarProc 367 389 368 390 // … … 373 395 SetVariable setvar5b proc=ThetaMaxSetVarProc 374 396 SetVariable setvar6b proc=ThetaMaxSetVarProc 397 SetVariable setvar7b proc=ThetaMaxSetVarProc 375 398 // 376 399 SetVariable setvar1c proc=IncrSetVarProc,limits={0.01,0.1,0.01} … … 380 403 SetVariable setvar5c proc=IncrSetVarProc,limits={0.5,5,1} 381 404 SetVariable setvar6c proc=IncrSetVarProc,limits={1,10,2} 405 SetVariable setvar7c proc=IncrSetVarProc,limits={1,20,2} 382 406 // 383 407 SetVariable setvar1d proc=NumPtsSetVarProc,limits={2,50,1} … … 387 411 SetVariable setvar5d proc=NumPtsSetVarProc,limits={2,50,1} 388 412 SetVariable setvar6d proc=NumPtsSetVarProc,limits={2,50,1} 413 SetVariable setvar7d proc=NumPtsSetVarProc,limits={2,50,1} 389 414 // 390 415 SetVariable setvar1e proc=CtTimeSetVarProc,limits={-1,50000,1} … … 394 419 SetVariable setvar5e proc=CtTimeSetVarProc,limits={-1,50000,100} 395 420 SetVariable setvar6e proc=CtTimeSetVarProc,limits={-1,50000,100} 396 397 Button button0,pos={left+280,180},size={60,20},fColor=(65535,65535,0),proc=U_SimPlotButtonProc,title="Plot" 398 CheckBox check0_2,pos={left+280,230},size={60,14},title="CountRate?",variable= root:Packages:NIST:USANS:Globals:U_Sim:g_1D_PlotCR 399 CheckBox check0_3,pos={left+280,250},size={60,14},title="Noise?",variable= root:Packages:NIST:USANS:Globals:U_Sim:g_1D_AddNoise 400 CheckBox check0_4 title="Show EMP?",pos={left+280,270},proc=ShowEMPCheckProc,value=0 421 SetVariable setvar7e proc=CtTimeSetVarProc,limits={-1,50000,100} 422 423 Button button0,pos={left+280,200},size={130,20},fColor=(65535,65535,0),proc=U_SimPlotButtonProc,title="Simulate USANS" 424 CheckBox check0_2,pos={left+280,250},size={60,14},title="CountRate?",variable= root:Packages:NIST:USANS:Globals:U_Sim:g_1D_PlotCR 425 CheckBox check0_3,pos={left+280,270},size={60,14},title="Noise?",variable= root:Packages:NIST:USANS:Globals:U_Sim:g_1D_AddNoise 426 CheckBox check0_4 title="Show EMP?",pos={left+280,290},proc=ShowEMPCheckProc,value=0 401 427 402 428 … … 405 431 ThetaEditMode(2) //checked on startup 406 432 407 // instrumentsetup408 SetVariable U_setvar0_1,pos={left+20,2 11},size={160,15},title="Thickness (cm)"433 // sample setup 434 SetVariable U_setvar0_1,pos={left+20,231},size={160,15},title="Thickness (cm)" 409 435 SetVariable U_setvar0_1,limits={0,inf,0.1},value= root:Packages:NIST:USANS:Globals:U_Sim:gThick 410 SetVariable U_setvar0_3,pos={left+20,2 35},size={160,15},title="Sample Transmission"436 SetVariable U_setvar0_3,pos={left+20,255},size={160,15},title="Sample Transmission" 411 437 SetVariable U_setvar0_3,limits={0,1,0.01},value= root:Packages:NIST:USANS:Globals:U_Sim:gSamTrans 412 PopupMenu U_popup0,pos={left+20, 185},size={165,20},proc=Sim_USANS_ModelPopMenuProc,title="Model"438 PopupMenu U_popup0,pos={left+20,205},size={165,20},proc=Sim_USANS_ModelPopMenuProc,title="Model" 413 439 PopupMenu U_popup0,mode=1,value= #"U_FunctionPopupList()" 414 SetVariable setvar0,pos={left+20,2 59},size={120,15},title="Empty Level",disable=2440 SetVariable setvar0,pos={left+20,279},size={120,15},title="Empty Level",disable=2 415 441 SetVariable setvar0,limits={0,10,0.01},value= root:Packages:NIST:USANS:Globals:U_Sim:g_EmptyLevel 416 SetVariable setvar0_1,pos={left+20, 284},size={120,15},title="Bkg Level",disable=2442 SetVariable setvar0_1,pos={left+20,304},size={120,15},title="Bkg Level",disable=2 417 443 SetVariable setvar0_1,limits={0,10,0.01},value= root:Packages:NIST:USANS:Globals:U_Sim:g_BkgLevel 418 444 … … 420 446 421 447 // a box for the results 422 SetVariable totalTime,pos={left+20,350},size={150,15},title="Count time (h:m)",value= gTotTimeStr 423 // ValDisplay valdisp0,pos={338,210},size={220,13},title="Total detector counts" 424 // ValDisplay valdisp0,limits={0,0,0},barmisc={0,1000},value= root:Packages:NIST:USANS:Globals:U_Sim:g_1DTotCts 425 ValDisplay valdisp0_2,pos={left+20,380},size={220,13},title="Fraction of beam scattered" 448 SetVariable totalTime,pos={left+20,370},size={150,15},title="Count time (h:m)",value= gTotTimeStr 449 ValDisplay valdisp0_2,pos={left+20,395},size={220,13},title="Fraction of beam scattered" 426 450 ValDisplay valdisp0_2,limits={0,0,0},barmisc={0,1000},value= root:Packages:NIST:USANS:Globals:U_Sim:g_1DFracScatt 427 ValDisplay valdisp0_3,pos={left+20,410},size={220,13},title="Estimated transmission" 451 ValDisplay valdisp0_2,disable=1 452 ValDisplay valdisp0_3,pos={left+20,420},size={220,13},title="Estimated transmission" 428 453 ValDisplay valdisp0_3,limits={0,0,0},barmisc={0,1000},value=root:Packages:NIST:USANS:Globals:U_Sim:g_1DEstTrans 429 Button button1,pos={left+20,440},size={50,20},proc=U_SaveButtonProc,title="Save" 454 ValDisplay valdisp0_3,disable=1 455 Button button1,pos={left+20,440},size={150,20},proc=U_SaveButtonProc,title="Save Simulated Data" 430 456 431 457 … … 550 576 End 551 577 552 // hard-wired for 6controls578 // hard-wired for 7 controls 553 579 // return value is in seconds 554 580 // global display string is set with hrs:min … … 557 583 Variable ii,num,totTime=0 558 584 String pathStr="root:Packages:NIST:USANS:Globals:U_Sim:" 559 num= 6585 num=7 560 586 561 587 for(ii=1;ii<=num;ii+=1) … … 585 611 End 586 612 587 // changes edit mode of the theta min/max boxes for simplified setup613 // changes edit mode of the theta min/max boxes and increment for simplified setup 588 614 // val = 2 = disable 589 615 // val = 0 = edit enabled … … 593 619 SetVariable setvar1a,win=UCALC,disable=val 594 620 SetVariable setvar1b,win=UCALC,disable=val 621 SetVariable setvar1c,win=UCALC,disable=val 595 622 596 623 SetVariable setvar2a,win=UCALC,disable=val 597 624 SetVariable setvar2b,win=UCALC,disable=val 625 SetVariable setvar2c,win=UCALC,disable=val 598 626 599 627 SetVariable setvar3a,win=UCALC,disable=val 600 628 SetVariable setvar3b,win=UCALC,disable=val 629 SetVariable setvar3c,win=UCALC,disable=val 601 630 602 631 SetVariable setvar4a,win=UCALC,disable=val 603 632 SetVariable setvar4b,win=UCALC,disable=val 633 SetVariable setvar4c,win=UCALC,disable=val 604 634 605 635 SetVariable setvar5a,win=UCALC,disable=val 606 636 SetVariable setvar5b,win=UCALC,disable=val 637 SetVariable setvar5c,win=UCALC,disable=val 607 638 608 639 SetVariable setvar6a,win=UCALC,disable=val 609 640 SetVariable setvar6b,win=UCALC,disable=val 610 641 SetVariable setvar6c,win=UCALC,disable=val 642 643 SetVariable setvar7a,win=UCALC,disable=val 644 SetVariable setvar7b,win=UCALC,disable=val 645 SetVariable setvar7c,win=UCALC,disable=val 611 646 return(0) 612 647 End … … 735 770 SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 736 771 737 num = 6//# of angular ranges772 num = 7 //# of angular ranges 738 773 739 774 // only try to plot ranges with non-zero count times … … 832 867 Imon = GetUSANSBeamIntensity() //based on the aperture size, select the beam intensity 833 868 Print "imon=",imon 869 834 870 // calculate the scattering cross section simply to be able to estimate the transmission 835 871 // unfortunately, this calculation is useless in the USANS range. So although it's calculated, the 872 // results are never reported. 873 // -- the main issue is that the integration range is optimized for SANS, and is not useful for USANS 874 // -there are only a few points in the USANS range, and extending it lower caused issues before. 836 875 CalculateRandomDeviate(funcUnsmeared,$coefStr,wavelength,"root:Packages:NIST:SAS:ran_dev",sig_sas) 837 876 … … 1069 1108 // add SIM data to the graph if it exists and is not already on the graph 1070 1109 // 1110 // 1111 // ** currently, I have changed the graph to not display the angle at the top. I have not yet 1112 // found a way to keep the scaling of the two axes in-sync when the empty cell data is added to the 1113 // graph (versus Q) 1114 // 1071 1115 Function GraphSIM() 1072 1116 … … 1090 1134 1091 1135 // lines for the no-noise result vs angle 1092 AppendToGraph/T Smeared_inten vs angle 1136 // AppendToGraph/T Smeared_inten vs angle 1137 AppendToGraph Smeared_inten vs Sim_USANS_q 1093 1138 ModifyGraph rgb(Smeared_inten)=(1,12815,52428) 1094 1139 ModifyGraph mode(Smeared_inten)=4,marker(Smeared_inten)=19,msize(Smeared_inten)=2 … … 1098 1143 AppendToGraph Sim_USANS_i vs Sim_USANS_q 1099 1144 ModifyGraph mode(Sim_USANS_i)=3,marker(Sim_USANS_i)=19,msize(Sim_USANS_i)=4 1100 ModifyGraph zColor(Sim_USANS_i)={setNumber,1,6,Rainbow,0} //force the colors from 1->6 1145 //don't reverse the dbZ21 or the highest angle will have "invisible" light blue error bars 1146 ModifyGraph zColor(Sim_USANS_i)={setNumber,1,7,dBZ21,0} //better for 7 colors 1147 // ModifyGraph zColor(Sim_USANS_i)={setNumber,1,7,Rainbow,0} //force the colors from 1->7 1101 1148 ModifyGraph useMrkStrokeRGB(Sim_USANS_i)=1 1102 1149 ErrorBars/T=0 Sim_USANS_i Y,wave=(Sim_USANS_s,Sim_USANS_s) … … 1104 1151 ModifyGraph log=1 1105 1152 ModifyGraph mirror(left)=1 1153 // if no top axis, then 1154 // ModifyGraph mirror(bottom)=1 1106 1155 ModifyGraph grid=2 1107 1156 ModifyGraph standoff=0 1108 1157 1109 1158 // to make sure that the scales are the same (but fails on zoom) 1110 // SetAxis bottom 2e-06,0.003 1111 // SetAxis top 2e-06/5.55e-5,0.003/5.55e-5 1159 NewFreeAxis/O/T top_angle 1160 ModifyFreeAxis/Z top_angle,master= bottom,hook= TransformAngleAxisHook 1161 ModifyGraph lblPos(top_angle)=50,freePos(top_angle)=0 1162 ModifyGraph log(top_angle)=1 1112 1163 1113 1164 SetDrawEnv linefgc= (39321,1,1),dash= 3,linethick= 3 1114 1165 SetDrawEnv xcoord= bottom 1115 1166 DrawLine 3e-05,0.01,3e-05,0.99 1116 1117 Label top "Angle"1167 1168 Label top_angle "Angle" 1118 1169 Label bottom "Q (1/A)" 1119 1170 Label left "Counts or Count Rate" … … 1125 1176 End 1126 1177 1178 Function TransformAngleAxisHook(s) 1179 STRUCT WMAxisHookStruct &s 1180 1181 s.max= s.max/5.55e-5 1182 s.min= s.min/5.55e-5 1183 1184 return 0 1185 End 1127 1186 1128 1187 //fakes a folder with loaded 1-d usans data, no calculation of the matrix … … 1283 1342 NVAR gIncr6 = gIncr6 1284 1343 1285 1344 NVAR gAngLow7 = gAngLow7 1345 NVAR gAngHigh7 = gAngHigh7 1346 NVAR gNumPts7 = gNumPts7 1347 NVAR gCtTime7 = gCtTime7 1348 NVAR gIncr7 = gIncr7 1286 1349 1287 1350 strswitch(popStr) // string switch … … 1324 1387 gIncr6 = 2 1325 1388 1389 gAngLow7 = 50 1390 gAngHigh7 = 95 1391 gNumPts7 = 10 1392 gCtTime7 = 0 1393 gIncr7 = 5 1394 1326 1395 break 1327 1396 case "Medium Count": … … 1362 1431 gCtTime6 = 1200 1363 1432 gIncr6 = 2 1364 1433 1434 gAngLow7 = 50 1435 gAngHigh7 = 95 1436 gNumPts7 = 10 1437 gCtTime7 = 0 1438 gIncr7 = 5 1439 1365 1440 break 1366 1441 case "Long Count": … … 1402 1477 gIncr6 = 2 1403 1478 1479 gAngLow7 = 50 1480 gAngHigh7 = 95 1481 gNumPts7 = 10 1482 gCtTime7 = 3000 1483 gIncr7 = 5 1484 1404 1485 break 1405 1486 default: … … 1453 1534 String baseName="SIMUL" 1454 1535 1455 num = 6//# of angular ranges1536 num = 7 //# of angular ranges 1456 1537 1457 1538 // only try to plot ranges with non-zero count times
Note: See TracChangeset
for help on using the changeset viewer.