Changeset 890
- Timestamp:
- Jan 28, 2013 4:43:50 PM (10 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Includes_v520.ipf
r871 r890 87 87 #include "EventModeProcessing" 88 88 89 // SRK JAN 2013 - to make simulation easier 90 #include "MC_SimulationScripting" 89 91 90 92 // a simple list of items to add to the Beta menu -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r888 r890 1356 1356 1357 1357 /// called in SASCALC:ReCalculateInten() 1358 Function Simulate_2D_MC(funcStr,aveint,qval,sigave,sigmaq,qbar,fsubs )1358 Function Simulate_2D_MC(funcStr,aveint,qval,sigave,sigmaq,qbar,fsubs,estimateOnly) 1359 1359 String funcStr 1360 1360 WAVE aveint,qval,sigave,sigmaq,qbar,fsubs 1361 1361 Variable estimateOnly 1362 1362 1363 NVAR doMonteCarlo = root:Packages:NIST:SAS:gDoMonteCarlo // == 1 if 2D MonteCarlo set by hidden flag 1363 1364 WAVE rw=root:Packages:NIST:SAS:realsRead … … 1469 1470 t0 *= 2 //empirical correction, since processor count returns 8 for (4 real + 4 virtual) 1470 1471 Print "Estimated Simulation time (s) = ",t0 1472 1473 1474 if(estimateOnly) 1475 return(t0) 1476 endif 1477 1471 1478 1472 1479 // to correct for detector efficiency, send only the fraction of neutrons that are actually counted … … 1609 1616 1610 1617 // simulate the empty cell scattering, only in 1D 1611 Simulate_1D_EmptyCell("TwoLevel_EC",aveint,qval,sigave,sigmaq,qbar,fsubs) 1618 // Simulate_1D_EmptyCell("TwoLevel_EC",aveint,qval,sigave,sigmaq,qbar,fsubs) 1619 Simulate_1D_EmptyCell("EC_Empirical",aveint,qval,sigave,sigmaq,qbar,fsubs) 1620 1612 1621 Print "Sample Simulation (2D) CR = ",results[9]/ctTime 1622 1613 1623 // check, so that RT simulation won't display SAS data type 1614 1624 NVAR/Z gFakeUpdate = root:myGlobals:gFakeUpdate … … 2000 2010 2001 2011 2002 Simulate_1D_EmptyCell("TwoLevel_EC",aveint,qval,sigave,sigmaq,qbar,fsubs) 2012 // Simulate_1D_EmptyCell("TwoLevel_EC",aveint,qval,sigave,sigmaq,qbar,fsubs) 2013 Simulate_1D_EmptyCell("EC_Empirical",aveint,qval,sigave,sigmaq,qbar,fsubs) 2014 2015 2003 2016 Print "Sample Simulation (1D) CR = ",estDetCR 2004 2017 … … 2044 2057 // - there is little difference vs. the empty cell alone. 2045 2058 // 2046 // - data was fit to the TwoLevel model, which fits rather nicely 2059 // - data was fit to the TwoLevel model, which fits rather nicely, or an empirical function EC_Empirical 2047 2060 // 2048 2061 Function Simulate_1D_EmptyCell(funcStr,aveint,qval,sigave,sigmaq,qbar,fsubs) … … 2050 2063 WAVE aveint,qval,sigave,sigmaq,qbar,fsubs 2051 2064 2052 Variable r1,xCtr,yCtr,sdd,pixSize,wavelength 2065 Variable r1,xCtr,yCtr,sdd,pixSize,wavelength,thick 2053 2066 String coefStr,abortStr,str 2054 2067 … … 2056 2069 FUNCREF SANSModelAAO_MCproto funcUnsmeared=$(funcStr) //unsmeared 2057 2070 2058 Make/O/D root:Packages:NIST:SAS:coef_Empty = {1,1.84594,714.625,5e-08,2.63775,0.0223493,3.94009,0.0153754,1.72127,0} 2059 WAVE coefW = root:Packages:NIST:SAS:coef_Empty 2060 2071 2061 2072 Wave samInten=$"root:Simulation:Simulation_i" // this will exist and send the smeared calculation to the corect DF 2062 2073 Duplicate/O samInten, root:Simulation:Simulation_EC_i 2063 2074 Wave inten_EC=$"root:Simulation:Simulation_EC_i" 2064 2075 2076 if(cmpstr(funcStr,"EC_Empirical") == 0) 2077 make/O/D root:Packages:NIST:SAS:coef_ECEmp = {2.2e-8,3.346,0.0065,9.0,0.016} 2078 WAVE coefW = root:Packages:NIST:SAS:coef_ECEmp 2079 thick = 0.1 //this works for the empirical model 2080 else 2081 //use the "TwoLevel" model 2082 Make/O/D root:Packages:NIST:SAS:coef_Empty = {1,1.84594,714.625,5e-08,2.63775,0.0223493,3.94009,0.0153754,1.72127,0} 2083 WAVE coefW = root:Packages:NIST:SAS:coef_Empty 2084 // for two 1/16" quartz windows, thick = 0.32 cm 2085 thick = 0.32 2086 endif 2087 2065 2088 // the resolution-smeared intensity of the empty cell 2066 2089 func(coefW,inten_EC,qval) 2090 2067 2091 2068 2092 NVAR imon = root:Packages:NIST:SAS:gImon … … 2079 2103 // use local variables here for the Empty cell - maybe use globals later, if I really want to save them 2080 2104 // - here, just print them out for now 2081 Variable SimDetCts,estDetCR,fracScat,estTrans,mScat,thick 2082 2083 // for two 1/16" quartz windows, thick = 0.32 cm 2084 thick = 0.32 2105 Variable SimDetCts,estDetCR,fracScat,estTrans,mScat 2106 2107 2085 2108 2086 2109 WAVE rw=root:Packages:NIST:SAS:realsRead … … 2113 2136 mscat *= (estTrans)/(1-estTrans) 2114 2137 2115 2116 2138 Duplicate/O qval prob_i_EC,countsInAnnulus_EC 2117 2139 … … 2382 2404 2383 2405 2384 //// this is a very simple example of how to script the MC simulation to run unattended2385 // 2386 // you need to supply for each "run": the run index (you increment manually)2387 // the sample label (as a string)2388 // 2389 // changing the various configuration paramters will have to be done on a case-by-case basis2390 // looking into SASCALC to see what is really changed,2391 // or the configuration parameters of the MC_SASCALC panel2392 // 2393 // 2394 Function Script_2DMC()2395 2396 2397 NVAR SimTimeWarn = root:Packages:NIST:SAS:g_SimTimeWarn2398 SimTimeWarn = 36000 //sets the threshold for the warning dialog to 10 hours2399 STRUCT WMButtonAction ba2400 ba.eventCode = 2 //fake mouse click on button2401 2402 NVAR detDist = root:Packages:NIST:SAS:gDetDist2403 2404 detDist = 200 //set directly in cm2405 MC_DoItButtonProc(ba)2406 SaveAsVAXButtonProc("",runIndex=105,simLabel="this is run 105, SDD = 200")2407 2408 detDist = 300 //set directly in cm2409 MC_DoItButtonProc(ba)2410 SaveAsVAXButtonProc("",runIndex=106,simLabel="this is run 106, SDD = 300")2411 2412 detDist = 400 //set directly in cm2413 MC_DoItButtonProc(ba)2414 SaveAsVAXButtonProc("",runIndex=107,simLabel="this is run 107, SDD = 400")2415 2416 2417 SimTimeWarn = 10 //back to 10 seconds for manual operation2418 return(0)2419 end2406 ////// this is a very simple example of how to script the MC simulation to run unattended 2407 //// 2408 //// you need to supply for each "run": the run index (you increment manually) 2409 //// the sample label (as a string) 2410 //// 2411 //// changing the various configuration paramters will have to be done on a case-by-case basis 2412 //// looking into SASCALC to see what is really changed, 2413 //// or the configuration parameters of the MC_SASCALC panel 2414 //// 2415 //// 2416 //Function Script_2DMC() 2417 // 2418 // 2419 // NVAR SimTimeWarn = root:Packages:NIST:SAS:g_SimTimeWarn 2420 // SimTimeWarn = 36000 //sets the threshold for the warning dialog to 10 hours 2421 // STRUCT WMButtonAction ba 2422 // ba.eventCode = 2 //fake mouse click on button 2423 // 2424 // NVAR detDist = root:Packages:NIST:SAS:gDetDist 2425 // 2426 // detDist = 200 //set directly in cm 2427 // MC_DoItButtonProc(ba) 2428 // SaveAsVAXButtonProc("",runIndex=105,simLabel="this is run 105, SDD = 200") 2429 // 2430 // detDist = 300 //set directly in cm 2431 // MC_DoItButtonProc(ba) 2432 // SaveAsVAXButtonProc("",runIndex=106,simLabel="this is run 106, SDD = 300") 2433 // 2434 // detDist = 400 //set directly in cm 2435 // MC_DoItButtonProc(ba) 2436 // SaveAsVAXButtonProc("",runIndex=107,simLabel="this is run 107, SDD = 400") 2437 // 2438 // 2439 // SimTimeWarn = 10 //back to 10 seconds for manual operation 2440 // return(0) 2441 //end -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_Utils.ipf
r889 r890 1814 1814 break 1815 1815 case "NGA": 1816 Print "Using the NG7 table for NGA *** this needs to be updated ***"1816 // Print "Using the NG7 table for NGA *** this needs to be updated ***" 1817 1817 attenFactor = LookupAttenNGA(lam,attenNo,atten_err) 1818 1818 break -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ProtocolAsPanel.ipf
r857 r890 2073 2073 String tempName = S_Path + FindValidFilename(filename) 2074 2074 err = GetXYBoxFromFile(tempName,x1,x2,y1,y2) //xy's are passed/returned by reference 2075 Print x1,x2,y1,y22075 // Print x1,x2,y1,y2 2076 2076 2077 2077 if( ((x1-x2)==0) || ((y1-y2)==0) ) //need to re-select the box -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r889 r890 162 162 Variable/G root:Packages:NIST:SAS:g_actSimTime = 0 //for the save 163 163 Variable/G root:Packages:NIST:SAS:g_SimTimeWarn = 10 //manually set to a very large value for scripted operation 164 164 Variable/G root:Packages:NIST:SAS:g_estimateOnly = 0 // == 1 for just a time estimate, == 0 (default) to do the simulation 165 Variable/G root:Packages:NIST:SAS:g_estimatedMCTime // estimated MC sim time 166 167 PlotEC_Empirical(100,0.001,0.7) // plot an empirical empty cell, only used for the simulation, not needed for SASCALC 168 KillTopGraphAndTable(1) // then kill the graph and table that the macro generates 165 169 166 170 //tick labels for SDD slider … … 1214 1218 NVAR doMonteCarlo = root:Packages:NIST:SAS:gDoMonteCarlo // == 1 if 2D MonteCarlo set by hidden flag 1215 1219 NVAR doSimulation = root:Packages:NIST:SAS:doSimulation // == 1 if 1D simulated data, 0 if other from the checkbox 1220 NVAR g_estimateOnly = root:Packages:NIST:SAS:g_estimateOnly // == 1 for just a time estimate, == 0 (default) to do the simulation 1221 NVAR g_estimatedMCTime = root:Packages:NIST:SAS:g_estimatedMCTime // estimated MC sim time 1216 1222 SVAR funcStr = root:Packages:NIST:SAS:gFuncStr //set by the popup 1217 1223 … … 1220 1226 //2D simulation (in MultiScatter_MonteCarlo_2D.ipf) 1221 1227 1222 Simulate_2D_MC(funcStr,aveint,qval,sigave,sigmaq,qbar,fsubs)1228 g_estimatedMCTime = Simulate_2D_MC(funcStr,aveint,qval,sigave,sigmaq,qbar,fsubs,g_estimateOnly) 1223 1229 1224 1230 //end 2D simulation -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WorkFileUtils.ipf
r836 r890 535 535 ratio = domega^3 536 536 xy = xx[ii]*yy[jj] 537 537 538 data[ii][jj] *= xy*ratio 539 538 540 solidAngle[ii][jj] = xy*ratio //testing only 539 541 data_err[ii][jj] *= xy*ratio //error propagation assumes that SA and Jacobian are exact, so simply scale error … … 583 585 data_err[ii][jj] = tmp_err 584 586 585 solidAngle[ii][jj] = lat_err587 // solidAngle[ii][jj] = lat_err 586 588 587 589
Note: See TracChangeset
for help on using the changeset viewer.