- Timestamp:
- Nov 25, 2014 3:10:21 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MC_SimulationScripting.ipf
r942 r950 96 96 // x- fill in the "RunSample" functions 97 97 // 98 // -- I need a little panel to control all of this, and get the information, just98 // x- I need a little panel to control all of this, and get the information, just 99 99 // like setting up a real experiment. Or maybe not. Maybe better to keep some of this 100 100 // hidden. … … 102 102 // For some experiments it's quite useful to see the level of this contribution, rather than 103 103 // the completely clean simulation. 104 // -- in this file, clearly separate the examples from the utility functions104 // x- in this file, clearly separate the examples from the utility functions 105 105 // -- get a function list of everything, and document what each does (if not obvious) 106 106 // -- step by step comments of one of the examples (1D and 2D) are probably the most useful 107 // -- "dry run" function to estimate the total simulation time for 2D. (? set all monitor counts to 1000107 // x- "dry run" function to estimate the total simulation time for 2D. (? set all monitor counts to 1000 108 108 // or whatever I use to get other estimates, and then run through everything to get estimated times) 109 109 // … … 113 113 // 114 114 // 115 // ----- transmission really doesn't workin the simulation...116 // -- add function to simulate transmission in 2D by saving a "Trans" configuration115 // ----- transmission really in the simulation... 116 // x- add function to simulate transmission in 2D by saving a "Trans" configuration 117 117 // and automatically using that. Currently the trans is already written to the file 118 // x- would also need a function to simulate an empty beam measurement to rescale the118 // x- would also need a function to simulate an empty beam measurement to rescale the 119 119 // transmissions. (use the model given, set scale (w[0] to something really small) 120 // -- or better, use the empty cell function that is guaranteed to have coefficients that are120 // x- or better, use the empty cell function that is guaranteed to have coefficients that are 121 121 // well behaved - and I can set/reset them to get a proper "empty beam" 122 122 // … … 128 128 129 129 /// un-comment this by removing the "x" from the word xMenu. Then compile. 130 // - note that no menu items will appear unless BOTH the Reduction and Analysis are loaded 130 131 Menu "Macros" 131 132 Submenu "Simulation Scripting - Beta" 132 ScriptItem(0),Sim_saveConfProc() 133 ScriptItem(1),Sim_moveConfProc() 134 ScriptItem(2),ListSASCALCConfigs() 133 ScriptItem(0),ShowRunListPanel() 134 // ScriptItem(0),Sim_StoreConfProc() 135 // ScriptItem(1),Sim_moveConfProc() 136 ScriptItem(1) 137 // ScriptItem(2),ListSASCALCConfigs() 135 138 ScriptItem(3),DryRunProc_1D() 136 ScriptItem(4),DryRunProc_2D()139 // ScriptItem(4),DryRunProc_2D() 137 140 ScriptItem(5),OptimalCountProc() 138 141 ScriptItem(6),MakeCombineTable_byName() … … 141 144 ScriptItem(9) 142 145 ScriptItem(10),Setup_Sim_Example() 143 ScriptItem(11),Example_1DSim()144 ScriptItem(12),Example_2DSim()146 // ScriptItem(11),Example_1DSim() 147 // ScriptItem(12),Example_2DSim() 145 148 ScriptItem(13) 146 149 ScriptItem(14),DisplayProcedure "Example_1DSim" … … 156 159 switch(num) 157 160 case 0: 158 str = "Save Configuration" 161 str = "Run List Panel" 162 //str = "Save Configuration" 159 163 break 160 164 case 1: 161 str = "Move to Configuration" 165 //str = "Move to Configuration" 166 str = "-" 162 167 break 163 168 case 2: … … 236 241 Function Example_1DSim() 237 242 238 String confList,ctTimeList,saveNameList,funcStr,titleStr 243 String confList,ctTimeList,saveNameList,funcStr,titleStrList 239 244 240 245 … … 264 269 ctTimeList = "100;300;900;" 265 270 saveNameList = "sim_1m.abs;sim_4m.abs;sim_13m.abs;" 266 titleStr = "MySample 1"271 titleStrList = "MySample 1 at 1m;MySample 1 at 4m;MySample 1 at 13m;" 267 272 268 273 // then this runs the samples as listed 269 Sim_RunSample_1D(confList,ctTimeList,titleStr ,saveNameList)274 Sim_RunSample_1D(confList,ctTimeList,titleStrList,saveNameList) 270 275 271 276 // no transmissions or empty beam measurements to make for 1D simulation … … 277 282 Function Example_2DSim() 278 283 279 String confList,ctTimeList,titleStr ,transConfList,transCtTimeList284 String confList,ctTimeList,titleStrList,transConfList,transCtTimeList 280 285 Variable runIndex,val,totalTime 281 286 String funcStr … … 319 324 transConfList = "Config_13m;" // trans only @ 13m 320 325 transCtTimeList = "1;" // trans count time = 1s 321 titleStr = "MySample 1"326 titleStrList = "MySample 1 at 1m;MySample 1 at 4m;MySample 1 at 13m;" 322 327 323 328 // runIndex is PBR and updates as the number of files are written 324 329 325 330 // this runs the sample 326 totalTime += Sim_RunSample_2D(confList,ctTimeList,titleStr ,runIndex)331 totalTime += Sim_RunSample_2D(confList,ctTimeList,titleStrList,runIndex) 327 332 // this runs the transmissions 328 totalTime += Sim_RunTrans_2D(transConfList,transCtTimeList,titleStr ,runIndex)333 totalTime += Sim_RunTrans_2D(transConfList,transCtTimeList,titleStrList,runIndex) 329 334 330 335 // run the empty beam at all configurations … … 332 337 transConfList = "Config_1m;Config_4m;Config_13m;" 333 338 transCtTimeList = "1;1;1;" 334 titleStr = "Empty Beam"335 totalTime += Sim_RunEmptyBeamTrans_2D(transConfList,transCtTimeList,titleStr ,runIndex)339 titleStrList = "Empty Beam at 1m;Empty Beam at 4m;Empty Beam at 13m;" 340 totalTime += Sim_RunEmptyBeamTrans_2D(transConfList,transCtTimeList,titleStrList,runIndex) 336 341 337 342 Print "runIndex = ",runIndex … … 348 353 Function Example_Loop_1DSim() 349 354 350 String confList,ctTimeList,saveNameList,funcStr,titleStr 355 String confList,ctTimeList,saveNameList,funcStr,titleStrList 351 356 352 357 … … 376 381 ctTimeList = "" //filled in the loop 377 382 saveNameList = "" 378 titleStr = "DAB versus count time t = "383 titleStrList = "DAB versus count time t = " //overwritten in loop 379 384 380 385 Make/O/D ctTime = {5,11,16,21,27,32,37,43,48,53,107,160,214,267,321,374,428,481,535,1604,5348,21390,53476} … … 384 389 for(jj=0;jj<numpnts(ctTime);jj+=1) 385 390 for(ii=0;ii<nTrials;ii+=1) 386 titleStr = "DAB versus count time t = "+num2str(ctTime[jj])391 titleStrList = "DAB versus count time t = "+num2str(ctTime[jj]) 387 392 saveNameList = "DAB_4m_t"+num2str(ctTime[jj])+"_"+num2str(ii)+".abs;" 388 393 ctTimeList = num2str(ctTime[jj])+";" 389 394 // then this runs the samples as listed 390 Sim_RunSample_1D(confList,ctTimeList,titleStr ,saveNameList)395 Sim_RunSample_1D(confList,ctTimeList,titleStrList,saveNameList) 391 396 endfor 392 397 endfor … … 411 416 Function Example_Loop_2DSim() 412 417 413 String confList,ctTimeList,titleStr ,transConfList,transCtTimeList418 String confList,ctTimeList,titleStrList,transConfList,transCtTimeList 414 419 Variable runIndex,val,totalTime 415 420 String funcStr … … 454 459 transConfList = "Config_1m;Config_4m;Config_13m;" 455 460 transCtTimeList = "1;1;1;" 456 titleStr = "Empty Beam"457 totalTime += Sim_RunEmptyBeamTrans_2D(transConfList,transCtTimeList,titleStr ,runIndex)461 titleStrList = "Empty Beam at 1m;Empty Beam at 4m;Empty Beam at 13m;" 462 totalTime += Sim_RunEmptyBeamTrans_2D(transConfList,transCtTimeList,titleStrList,runIndex) 458 463 459 464 … … 464 469 transConfList = "Config_13m" // trans only @ 13m 465 470 transCtTimeList = "1;" // trans count time = 1s 466 titleStr = "MySample 1"471 titleStrList = "MySample 1" 467 472 468 473 // runIndex is PBR and updates as the number of files are written … … 483 488 484 489 confList = conf[ii] +";" 485 titleStr = "DAB simulation, thick = "+num2str(thick[ii])490 titleStrList = "DAB simulation, thick = "+num2str(thick[ii]) 486 491 ctTimeList = num2str(ctTime[ii])+";" 487 492 488 493 // this runs the transmissions (only at 13m) 489 494 if(cmpstr(conf[ii],"Config_13m")==0) 490 totalTime += Sim_RunTrans_2D(transConfList,transCtTimeList,titleStr ,runIndex)495 totalTime += Sim_RunTrans_2D(transConfList,transCtTimeList,titleStrList,runIndex) 491 496 endif 492 497 493 498 // this runs the sample 494 totalTime += Sim_RunSample_2D(confList,ctTimeList,titleStr ,runIndex)499 totalTime += Sim_RunSample_2D(confList,ctTimeList,titleStrList,runIndex) 495 500 496 501 endfor … … 516 521 517 522 // pass in a semicolon delimited list of configurations + corresponding count times + saved names 518 Function Sim_RunSample_1D(confList,ctTimeList,titleStr ,saveNameList)519 String confList,ctTimeList,titleStr ,saveNameList523 Function Sim_RunSample_1D(confList,ctTimeList,titleStrList,saveNameList) 524 String confList,ctTimeList,titleStrList,saveNameList 520 525 521 526 Variable ii,num,ct,cr,numPt 522 String twStr,fname,type 527 String twStr,fname,type,titleStr 523 528 NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just count rate, == 0 (default) to do the simulation and save 524 529 WAVE/Z crWave = root:CR_1D … … 533 538 ct = str2num(StringFromList(ii, ctTimeList,";")) 534 539 fname = StringFromList(ii, saveNameList,";") 540 titleStr = StringFromList(ii, titleStrList,";") 535 541 536 542 Sim_MoveToConfiguration(tw) … … 584 590 // of the model to something tiny so that there is no coherent scattering 585 591 // 586 Function Sim_RunTrans_2D(confList,ctTimeList,titleStr ,runIndex)587 String confList,ctTimeList,titleStr 592 Function Sim_RunTrans_2D(confList,ctTimeList,titleStrList,runIndex) 593 String confList,ctTimeList,titleStrList 588 594 Variable &runIndex 589 595 590 596 Variable ii,num,ct,index,totalTime 591 String twStr,type 597 String twStr,type,titleStr 592 598 593 599 NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just a time estimate, == 0 (default) to do the simulation … … 600 606 for(ii=0;ii<num;ii+=1) 601 607 twStr = StringFromList(ii, confList,";") 608 titleStr = StringFromList(ii, titleStrList,";") 602 609 Wave/T tw=$("root:Packages:NIST:SAS:"+twStr) 603 610 ct = str2num(StringFromList(ii, ctTimeList,";")) … … 628 635 // Print "Sample Simulation (2D) CR = ",results[9]/ctTime 629 636 // -- for estimates, iMon is set to 1000, so time=1000/(root:Packages:NIST:SAS:gImon) 630 Function Sim_RunSample_2D(confList,ctTimeList,titleStr ,runIndex)631 String confList,ctTimeList,titleStr 637 Function Sim_RunSample_2D(confList,ctTimeList,titleStrList,runIndex) 638 String confList,ctTimeList,titleStrList 632 639 Variable &runIndex 633 640 634 641 Variable ii,num,ct,index,totalTime 635 String twStr,type 642 String twStr,type,titleStr 636 643 637 644 NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just a time estimate, == 0 (default) to do the simulation … … 645 652 for(ii=0;ii<num;ii+=1) 646 653 twStr = StringFromList(ii, confList,";") 654 titleStr = StringFromList(ii, titleStrList,";") 647 655 Wave/T tw=$("root:Packages:NIST:SAS:"+twStr) 648 656 ct = str2num(StringFromList(ii, ctTimeList,";")) … … 1132 1140 End 1133 1141 1134 Proc Sim_ saveConfProc(waveStr)1142 Proc Sim_StoreConfProc(waveStr) 1135 1143 String waveStr 1136 1144 1137 Sim_S aveConfiguration(waveStr)1145 Sim_StoreConfiguration(waveStr) 1138 1146 End 1139 1147 // … … 1155 1163 // 9 = offset 1156 1164 // 1157 Function Sim_S aveConfiguration(waveStr)1165 Function Sim_StoreConfiguration(waveStr) 1158 1166 String waveStr 1159 1167 … … 1162 1170 SetDataFolder root:Packages:NIST:SAS 1163 1171 1164 Make/O/T/N=20 $("Config_"+waveStr) 1165 Wave/T tw=$("Config_"+waveStr) 1172 waveStr = CleanupName("Config_"+waveStr,0) 1173 1174 Make/O/T/N=20 $(waveStr) 1175 Wave/T tw=$(waveStr) 1166 1176 tw = "" 1167 1177 … … 1271 1281 1272 1282 1273 ///////////// a panel to (maybe) write to speed the setup of the runs1274 //1275 Function/S ListSASCALCConfigs()1276 String str1277 SetDataFolder root:Packages:NIST:SAS1278 str = WaveList("Conf*",";","")1279 SetDataFolder root:1280 print str1281 return(str)1282 End1283 1284 //Proc Sim_SetupRunPanel() : Panel1285 // PauseUpdate; Silent 1 // building window...1286 // NewPanel /W=(399,44,764,386)1287 // ModifyPanel cbRGB=(56639,28443,117)1288 // ShowTools/A1289 //EndMacro
Note: See TracChangeset
for help on using the changeset viewer.