Changeset 800 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- May 4, 2011 9:47:33 AM (12 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_DataReadWrite.ipf
r795 r800 1021 1021 1022 1022 // your writer here 1023 Wave wTransmission1023 // Wave wTransmission 1024 1024 //nha ??? Should make this wave in our own DataFolder to avoid clashing names. 1025 Make /N=(1,1) wTransmission 1025 // Make /N=(1,1) wTransmission 1026 Make/O/D/N=1 wTransmission 1026 1027 String groupName = "/reduce" 1027 1028 String varName = "Transmission" -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Buttons.ipf
r764 r800 70 70 End 71 71 72 /////not used////73 // function control a background task of "live" image updating74 //75 Function UpdateImage(ctrlName) : ButtonControl76 String ctrlName77 78 if (cmpstr(ctrlName,"bStart") == 0)79 Button $ctrlName,title="Stop",rename=bStop80 // Start the updating - FakeUpdate() has been designated as the background task81 CtrlBackground period=60,start82 else83 Button $ctrlName,title="Start",rename=bStart84 // Stop the updating85 CtrlBackground stop86 endif87 End88 89 //not used, but useful for real-time display of the detector90 //old, and likely not up-to-date with the present data folder structure91 Function FakeUpdate()92 93 //get the current displayed data (so the correct folder is used)94 SVAR cur_folder=root:myGlobals:gDataDisplayType95 SetDataFolder "root:Packages:NIST:"+cur_folder //use the full path, so it will always work96 WAVE data = $"data"97 // WAVE vlegend = $"vlegend"98 99 //alter the raw data100 data = abs(enoise(10))101 102 // adjust the color bar103 WaveStats/Q data104 // SetScale/I y,V_min,V_max,"" vlegend105 // vlegend=y106 107 // assume all is OK, return 0108 // button1 controls the start/stop of the background task109 110 //back to root folder111 SetDataFolder root:112 113 return 0114 End115 72 116 73 //Updates the color map used for the SANS data based on the values of the slider bars -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf
r757 r800 1250 1250 NVAR doMonteCarlo = root:Packages:NIST:SAS:gDoMonteCarlo // == 1 if 2D MonteCarlo set by hidden flag 1251 1251 WAVE rw=root:Packages:NIST:SAS:realsRead 1252 WAVE iw=root:Packages:NIST:SAS:integersRead 1252 1253 1253 1254 // Try to nicely exit from a threading error, if possible … … 1423 1424 1424 1425 NVAR rawCts = root:Packages:NIST:SAS:gRawCounts 1426 NVAR ctTime = root:Packages:NIST:SAS:gCntTime 1427 1425 1428 if(!rawCts) //go ahead and do the abs scaling to the linear_data 1426 1429 linear_data = linear_data / kappa … … 1449 1452 1450 1453 data = linear_data 1454 1455 // fill in bits of the header 1456 rw[0] = imon //the simulated monitor counts 1457 iw[2] = ctTime //simulated counting time in seconds 1451 1458 // re-average the 2D data 1452 1459 S_CircularAverageTo1D("SAS") … … 1457 1464 // simulate the empty cell scattering, only in 1D 1458 1465 Simulate_1D_EmptyCell("TwoLevel_EC",aveint,qval,sigave,sigmaq,qbar,fsubs) 1459 NVAR ctTime = root:Packages:NIST:SAS:gCntTime1460 1466 Print "Sample Simulation (2D) CR = ",results[9]/ctTime 1461 if(WinType("SANS_Data") ==1) 1462 Execute "ChangeDisplay(\"SAS\")" //equivalent to pressing "Show 2D" 1463 endif 1467 // check, so that RT simulation won't display SAS data type 1468 NVAR/Z gFakeUpdate = root:myGlobals:gFakeUpdate 1469 if(NVAR_Exists(gFakeUpdate) && gFakeUpdate == 1) 1470 // do nothing 1471 else 1472 if(WinType("SANS_Data") ==1) 1473 Execute "ChangeDisplay(\"SAS\")" //equivalent to pressing "Show 2D" 1474 endif 1475 endif 1476 1464 1477 1465 1478 return(0) … … 2221 2234 // 2222 2235 // 2223 //Function Script_2DMC()2224 // 2225 // 2226 //NVAR SimTimeWarn = root:Packages:NIST:SAS:g_SimTimeWarn2227 //SimTimeWarn = 36000 //sets the threshold for the warning dialog to 10 hours2228 //STRUCT WMButtonAction ba2229 //ba.eventCode = 2 //fake mouse click on button2230 //2231 //NVAR detDist = root:Packages:NIST:SAS:gDetDist2232 // 2233 //detDist = 200 //set directly in cm2234 //MC_DoItButtonProc(ba)2235 //SaveAsVAXButtonProc("",runIndex=105,simLabel="this is run 105, SDD = 200")2236 //2237 //detDist = 300 //set directly in cm2238 //MC_DoItButtonProc(ba)2239 //SaveAsVAXButtonProc("",runIndex=106,simLabel="this is run 106, SDD = 300")2240 // 2241 //detDist = 400 //set directly in cm2242 //MC_DoItButtonProc(ba)2243 //SaveAsVAXButtonProc("",runIndex=107,simLabel="this is run 107, SDD = 400")2244 //2245 // 2246 //SimTimeWarn = 10 //back to 10 seconds for manual operation2247 //return(0)2248 //end2236 Function Script_2DMC() 2237 2238 2239 NVAR SimTimeWarn = root:Packages:NIST:SAS:g_SimTimeWarn 2240 SimTimeWarn = 36000 //sets the threshold for the warning dialog to 10 hours 2241 STRUCT WMButtonAction ba 2242 ba.eventCode = 2 //fake mouse click on button 2243 2244 NVAR detDist = root:Packages:NIST:SAS:gDetDist 2245 2246 detDist = 200 //set directly in cm 2247 MC_DoItButtonProc(ba) 2248 SaveAsVAXButtonProc("",runIndex=105,simLabel="this is run 105, SDD = 200") 2249 2250 detDist = 300 //set directly in cm 2251 MC_DoItButtonProc(ba) 2252 SaveAsVAXButtonProc("",runIndex=106,simLabel="this is run 106, SDD = 300") 2253 2254 detDist = 400 //set directly in cm 2255 MC_DoItButtonProc(ba) 2256 SaveAsVAXButtonProc("",runIndex=107,simLabel="this is run 107, SDD = 400") 2257 2258 2259 SimTimeWarn = 10 //back to 10 seconds for manual operation 2260 return(0) 2261 end -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_Utils.ipf
r794 r800 307 307 308 308 // this is really sigma_Q_parallel 309 SigmaQX = kap*kap/12 * (3*(S1/L1)^2 + 3*(S2/LP)^2 + (proj_DDet/L2)^2 + (sin(phi))^2*8*(a_val_L2)^2*lambda^4*lambdaWidth^2)309 SigmaQX = kap*kap/12 * (3*(S1/L1)^2 + 3*(S2/LP)^2 + (proj_DDet/L2)^2 + (sin(phi))^2*8*(a_val_L2)^2*lambda^4*lambdaWidth^2) 310 310 SigmaQX += inQ*inQ*v_lambda 311 311 … … 313 313 proj_DDet = DDet*sin(phi) + DDet*cos(phi) //not necessary, since DDet is the same in both X and Y directions 314 314 315 SigmaQY = 3*(S1/L1)^2 + 3*(S2/LP)^2 + (proj_DDet/L2)^2 + (cos(phi))^2*8*(a_val_L2)^2*lambda^4*lambdaWidth^2 316 SigmaQY *= kap*kap/12 315 SigmaQY = kap*kap/12 * (3*(S1/L1)^2 + 3*(S2/LP)^2 + (proj_DDet/L2)^2 + (cos(phi))^2*8*(a_val_L2)^2*lambda^4*lambdaWidth^2) 317 316 318 317 SigmaQX = sqrt(SigmaQX) 319 318 SigmaQy = sqrt(SigmaQY) 320 319 320 321 ///////////////////////////////////////////////// 322 /// 323 ////// this is all experimental, inclusion of gravity effect into the parallel component 324 // 325 Variable yg_d,acc,sdd,ssd,lambda0,DL_L,sig_l 326 Variable var_qlx,var_qly,var_ql,qx,qy,sig_perp,sig_para 327 // G = 981. //! ACCELERATION OF GRAVITY, CM/SEC^2 328 acc = vz_1 // 3.956E5 //! CONVERT WAVELENGTH TO VELOCITY CM/SEC 329 SDD = L2 //1317 330 SSD = L1 //1627 //cm 331 lambda0 = lambda // 15 332 DL_L = lambdaWidth //0.236 333 SIG_L = DL_L/sqrt(6) 334 YG_d = -0.5*G*SDD*(SSD+SDD)*(LAMBDA0/acc)^2 335 // Print "DISTANCE BEAM FALLS DUE TO GRAVITY (CM) = ",YG 336 337 sig_perp = kap*kap/12 * (3*(S1/L1)^2 + 3*(S2/LP)^2 + (proj_DDet/L2)^2) 338 sig_perp = sqrt(sig_perp) 339 340 341 FindQxQy(inQ,phi,qx,qy) 342 343 VAR_QLY = SIG_L^2 * (QY+4*PI*YG_d/(SDD*LAMBDA0))^2 344 VAR_QLX = (SIG_L*QX)^2 345 VAR_QL = VAR_QLY + VAR_QLX //! WAVELENGTH CONTRIBUTION TO VARIANCE 346 sig_para = (sig_perp^2 + VAR_QL)^0.5 347 348 //return values PBR 349 SigmaQX = sig_para 350 SigmaQy = sig_perp 351 352 // 321 353 322 354 results = "success" -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/RealTimeUpdate_RT.ipf
r570 r800 16 16 // 17 17 // as of 110101, the help file has not been written 18 // 19 // 20 // 21 // for Summer School 2011 --- a fake update 22 // 1) set the flag 23 // Variable/G root:myGlobals:gFakeUpdate=1 24 // 2) load any data file as the RT data 25 // 3) get SASCALC set up to the correct configuration 26 // 4) run ClearRTFolder() to empty out the SAS folder, and update the display 27 // 5) start the updating 28 // 29 // -- generate a script that will (from scratch) open everything needed, open/hide windows 30 // as needed, and be sure that all of the files, varaibles, etc. that are needed are actually there. 31 // 32 // --needs SASCALC + an analysis model for it to work, and still some details to work out for 33 // smooth initialization of the process, but it should work. 34 // 35 // 36 // 37 Proc Init_FakeRT() 38 pInit_FakeRT() 39 End 40 41 Proc Clear_RT_Folder() 42 ClearRTFolder() 43 End 44 45 // 18 46 // 19 47 //***************************** … … 343 371 NVAR monitorCounts = root:myGlobals:RT:monitorCounts 344 372 NVAR monitorCountRate = root:myGlobals:RT:monitorCountRate 345 SVAR title = root:myGlobals:gCurDispFile373 SVAR/Z title = root:myGlobals:gCurDispFile 346 374 347 375 title="Real-Time : "+filename … … 553 581 NVAR monitorCounts = root:myGlobals:RT:monitorCounts 554 582 NVAR monitorCountRate = root:myGlobals:RT:monitorCountRate 555 SVAR title=root:myGlobals:gCurDispFile583 SVAR/Z title=root:myGlobals:gCurDispFile 556 584 SVAR sampledesc=root:myGlobals:gCurTitle 557 585 … … 581 609 //err = ReadOrdelaHST(RT_fileStr) 582 610 //err = ReadHeaderAndData(RT_fileStr) 583 err = ReadRTAndData(RT_fileStr) 611 NVAR/Z gFakeUpdate = root:myGlobals:gFakeUpdate 612 if(NVAR_Exists(gFakeUpdate) && gFakeUpdate == 1) 613 err = FakeUpdate() 614 else 615 err = ReadRTAndData(RT_fileStr) 616 endif 617 584 618 if(err==1) 585 619 Button $"bkgStop",win=RT_Panel,title="Start Updating",rename=bkgStart … … 632 666 // update the 1d plot 633 667 if(WinType("Plot_1d")==1) //if the 1D graph exists 634 Panel_DoAverageButtonProc("") 668 Panel_DoAverageButtonProc("") 669 DoWindow/F SANS_Data 635 670 endif 636 671 /////// … … 969 1004 970 1005 End 1006 1007 /////not used//// 1008 // function control a background task of "live" image updating 1009 // 1010 Function UpdateImage(ctrlName) : ButtonControl 1011 String ctrlName 1012 1013 if (cmpstr(ctrlName,"bStart") == 0) 1014 Button $ctrlName,title="Stop",rename=bStop 1015 // Start the updating - FakeUpdate() has been designated as the background task 1016 CtrlBackground period=60,start 1017 else 1018 Button $ctrlName,title="Start",rename=bStart 1019 // Stop the updating 1020 CtrlBackground stop 1021 endif 1022 End 1023 1024 1025 // puts a "clean" instance of SAS into RealTime 1026 Function ClearRTFolder() 1027 1028 String RTPath = "root:Packages:NIST:RealTime" 1029 String SimPath = "root:Packages:NIST:SAS" 1030 1031 1032 Duplicate/O $(SimPath + ":data"),$(RTPath+":data") 1033 Duplicate/O $(SimPath + ":linear_data"),$(RTPath+":linear_data") 1034 Duplicate/O $(SimPath + ":textread"),$(RTPath+":textread") 1035 Duplicate/O $(SimPath + ":integersread"),$(RTPath+":integersread") 1036 Duplicate/O $(SimPath + ":realsread"),$(RTPath+":realsread") 1037 1038 WAVE RT_rw = $(RTPath+":RealsRead") 1039 WAVE RT_iw = $(RTPath+":IntegersRead") 1040 1041 RT_iw[2] = 0 1042 RT_rw[0] = 0 1043 1044 Wave RTData = $(RTPath+":data") 1045 Wave RTLinData = $(RTPath+":linear_data") 1046 RTLinData = 0 1047 RTData = 0 1048 1049 // get the right Q axes on the display 1050 //add the qx and qy axes 1051 Wave q_x_axis=$"root:myGlobals:q_x_axis" 1052 Wave q_y_axis=$"root:myGlobals:q_y_axis" 1053 Set_Q_Axes(q_x_axis,q_y_axis,RTPath) 1054 1055 return(0) 1056 End 1057 1058 //not used, but useful for real-time display of the detector 1059 //old, and likely not up-to-date with the present data folder structure 1060 Function FakeUpdate() 1061 1062 //get the current displayed data (so the correct folder is used) 1063 SVAR cur_folder=root:myGlobals:gDataDisplayType 1064 1065 STRUCT WMButtonAction ba 1066 ba.eventCode = 2 //fake mouse click on button 1067 MC_DoItButtonProc(ba) 1068 1069 // would copy the work contents, but I want to add the MC results + times, etc. 1070 // Execute "CopyWorkFolder(\"Simulation\",\"RealTime\")" 1071 1072 //check for existence of data in oldtype 1073 // if the desired workfile doesn't exist, let the user know, and abort 1074 String RTPath,SimPath 1075 if(WaveExists($("root:Packages:NIST:RealTime:data")) == 0) 1076 ClearRTFolder() 1077 // Print "There is no work file in "+"SAS"+"--Aborting" 1078 // Return(1) //error condition 1079 Endif 1080 1081 //check for log-scaling of the "type" data and adjust if necessary 1082 // ConvertFolderToLinearScale("SAS") 1083 // ConvertFolderToLinearScale("RealTime") 1084 // Fix_LogLinButtonState(0) //make sure the button reflects the new linear scaling 1085 //then continue 1086 1087 //copy from current dir (type)=destPath to newtype, overwriting newtype contents 1088 SimPath = "root:Packages:NIST:SAS" 1089 RTPath = "root:Packages:NIST:RealTime" 1090 // Duplicate/O $(SimPath + ":textread"),$(RTPath+":textread") 1091 // Duplicate/O $(SimPath + ":integersread"),$(RTPath+":integersread") 1092 // Duplicate/O $(SimPath + ":realsread"),$(RTPath+":realsread") 1093 // Duplicate/O $(SimPath + ":linear_data_error"),$(RTPath+":linear_data_error") 1094 1095 WAVE RT_rw = $(RTPath+":RealsRead") 1096 WAVE Sim_rw = $(SimPath+":RealsRead") 1097 WAVE RT_iw = $(RTPath+":IntegersRead") 1098 WAVE Sim_iw = $(SimPath+":IntegersRead") 1099 1100 // accumulate the count time and monitor counts 1101 RT_iw[2] += Sim_iw[2] 1102 RT_rw[0] += Sim_rw[0] 1103 1104 // accumulate the data 1105 Wave RTData = $(RTPath+":data") 1106 Wave RTLinData = $(RTPath+":linear_data") 1107 Wave SimLinData = $(SimPath+":linear_data") 1108 RTLinData += SimLinData 1109 1110 NVAR gIsLogScale = $(RTPath + ":gIsLogScale") 1111 if(gIsLogScale) 1112 RTData = log(RTLinData) 1113 else 1114 RTData = RTLinData 1115 endif 1116 1117 // Execute "ChangeDisplay(\"RealTime\")" 1118 //just need to update the color bar 1119 // MapSliderProc("both",0,0) 1120 1121 //alter the raw data 1122 // linear_data += abs(enoise(1)) + abs(cos(p*q)) 1123 // data = linear_data 1124 1125 1126 //back to root folder 1127 SetDataFolder root: 1128 1129 return 0 1130 End 1131 1132 // 1133 // 1134 // 1135 // to use, first load in the analysis and reduction packages 1136 // -- then, load in the sphere model 1137 // 1138 // load sphere model 1139 // Execute/P "INSERTINCLUDE \"Sphere_v40\"" 1140 // Execute/P "COMPILEPROCEDURES " 1141 // 1142 // 1143 Function pInit_FakeRT() 1144 1145 1146 1147 // plot sphere model 1148 String cmdStr,funcStr 1149 funcStr = "SphereForm" 1150 sprintf cmdStr, "Plot%s()",funcStr 1151 Execute cmdStr 1152 1153 // close graph (top) and table 1154 String topGraph= WinName(0,1) //this is the topmost graph 1155 String topTable= WinName(0,2) //this is the topmost table 1156 KillWindow $topGraph 1157 KillWindow $topTable 1158 1159 // change coef_sf[0] = 0.01 1160 Wave coef_sf = root:coef_sf 1161 coef_sf[0] = 0.01 1162 1163 1164 1165 // open SASCALC 1166 Execute "SASCALC()" 1167 1168 // open MC simulation window 1169 DoWindow/F MC_SASCALC 1170 if(V_flag==0) 1171 Execute "MC_SASCALC()" //sets the variable 1172 AutoPositionWindow/M=1/R=SASCALC MC_SASCALC 1173 endif 1174 NVAR doSim = root:Packages:NIST:SAS:doSimulation 1175 doSim=1 1176 1177 // set model 1178 SVAR gStr = root:Packages:NIST:SAS:gFuncStr 1179 gStr = "SphereForm" 1180 String listStr = MC_FunctionPopupList() 1181 Variable item = WhichListItem("SphereForm", listStr ) 1182 PopupMenu MC_popup0,win=MC_SASCALC,mode=(item+1) 1183 1184 // set ct time to 5 s 1185 STRUCT WMSetVariableAction sva 1186 NVAR ctTime = root:Packages:NIST:SAS:gCntTime 1187 ctTime = 5 1188 sva.eventCode = 3 //update 1189 sva.dval = ctTime //5 seconds 1190 CountTimeSetVarProc(sva) 1191 1192 // be sure check boxes are raw_cts / BS in / XOP 1193 NVAR cts = root:Packages:NIST:SAS:gRawCounts 1194 NVAR BSin = root:Packages:NIST:SAS:gBeamStopIn 1195 NVAR xop = root:Packages:NIST:SAS:gUse_MC_XOP 1196 cts = 1 1197 BSin = 1 1198 xop = 1 1199 1200 // run 1 simulation to "set" things 1201 DoWindow/F MC_SASCALC 1202 STRUCT WMButtonAction ba 1203 ba.eventCode = 2 //fake mouse click on button 1204 MC_DoItButtonProc(ba) 1205 1206 1207 // set RT fake flag 1208 Variable/G root:myGlobals:gFakeUpdate=1 1209 1210 // open RT window 1211 1212 // load (any) data file 1213 1214 // ClearFolder 1215 1216 1217 1218 1219 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf
r764 r800 1797 1797 rw[19] = val // already in cm 1798 1798 //move the beamcenter, make it an integer value for the MC simulation 1799 rw[16] = 64 + round(2*rw[19])//approximate beam X is 64 w/no offset, 114 w/25 cm offset1800 rw[17] = 64 1799 rw[16] = 64 + round(2*rw[19]) + 0.5 //approximate beam X is 64 w/no offset, 114 w/25 cm offset 1800 rw[17] = 64 + 0.5 //typical value 1801 1801 1802 1802 return(val) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteQIS.ipf
r797 r800 852 852 853 853 // Save/G/M="\r\n" labelWave,qx_val,qy_val,z_val as fullpath // without resolution 854 Save/ G/M="\r\n" labelWave,qx_val_s,qy_val_s,z_val_s,sw_s,qz_val_s,SigmaQx_s,SigmaQy_s,fSubS_s as fullpath // write out the resolution information854 Save/O/G/M="\r\n" labelWave,qx_val_s,qy_val_s,z_val_s,sw_s,qz_val_s,SigmaQx_s,SigmaQy_s,fSubS_s as fullpath // write out the resolution information 855 855 #else 856 856 Open refNum as fullpath
Note: See TracChangeset
for help on using the changeset viewer.