Changeset 1243 for sans/Dev/trunk
- Timestamp:
- Mar 12, 2020 6:23:22 PM (3 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_BeamCenter.ipf
r1242 r1243 1071 1071 return(0) 1072 1072 End 1073 1074 1075 1076 ////////////////////// 1077 // different way to get the corrected beam centers 1078 // 1079 // find the centroid for each file with the marquee as usual 1080 // then run the macro (to pick each open beam file name) 1081 // - values for centroid are read from the file 1082 // 1083 // - patch xy panel is filled in 1084 // 1085 // 1086 Function V_AutoBeamCenter() 1087 1088 String emptyFileName_F="",emptyFileName_M="",emptyFileName_B="" 1089 1090 1091 NVAR gIgnoreBack = root:Packages:NIST:VSANS:Globals:gIgnoreDetB 1092 1093 1094 // TODO -- can I auto-identify which is the F, M, B? 1095 // -- can I determine whether the reference beam center has been found already? 1096 // -- since the centroid was already picked, can the file be flagged at this time? 1097 // -- is it easier to have a single panel with three popups? or just two?? 1098 // 1099 1100 // 1101 // - to figure out which is F, M, B 1102 // try WaveMax(root:Packages:NIST:VSANS:RAW:entry:instrument:detector_MR:data) 1103 // and pick the panel with the largest value 1104 // 1105 // or display the file label along with the file name 1106 // 1107 // 1108 1109 // get the file names 1110 Prompt emptyFileName_F,"Empty Beam File, Front Carriage",popup,V_PickEMPBeamButton("") 1111 DoPrompt "Select File",emptyFileName_F 1112 if (V_Flag) 1113 return 0 // user canceled 1114 endif 1115 1116 Prompt emptyFileName_M,"Empty Beam File, Middle Carriage",popup,V_PickEMPBeamButton("") 1117 DoPrompt "Select File",emptyFileName_M 1118 if (V_Flag) 1119 return 0 // user canceled 1120 endif 1121 1122 if(!gIgnoreBack) 1123 Prompt emptyFileName_B,"Empty Beam File, Back Carriage",popup,V_PickEMPBeamButton("") 1124 DoPrompt "Select File",emptyFileName_B 1125 if (V_Flag) 1126 return 0 // user canceled 1127 endif 1128 endif 1129 1130 // read the values from the Reduction/comment block 1131 // "XREF=%g;YREF=%g;" 1132 String refStr="" 1133 Variable xRef_F,xRef_M,xRef_B 1134 Variable yRef_F,yRef_M,yRef_B 1135 1136 1137 //force a cleanup of these three data sets so they are read from disk 1138 KillDataFolder/Z $("root:Packages:NIST:VSANS:RawVSANS:"+ParseFilePath(0, emptyFileName_F, ".", 0, 0)) 1139 KillDataFolder/Z $("root:Packages:NIST:VSANS:RawVSANS:"+ParseFilePath(0, emptyFileName_M, ".", 0, 0)) 1140 KillDataFolder/Z $("root:Packages:NIST:VSANS:RawVSANS:"+ParseFilePath(0, emptyFileName_B, ".", 0, 0)) 1141 1142 // 1143 // TODO -- need to verify that the values are actually good 1144 // -- if they aren't, I need to do something about this... 1145 // 1146 1147 refStr = V_getReductionComments(emptyFileName_F) 1148 xRef_F = NumberByKey("XREF", refStr ,"=",";") 1149 yRef_F = NumberByKey("YREF", refStr ,"=",";") 1150 1151 if(numtype(xRef_F)!=0 || numtype(yRef_F)!=0) //not a normal number 1152 Abort "Centroid has not been set for the Front carriage. Open the file and use the Marquee to find the centroid." 1153 endif 1154 1155 refStr = V_getReductionComments(emptyFileName_M) 1156 xRef_M = NumberByKey("XREF", refStr ,"=",";") 1157 yRef_M = NumberByKey("YREF", refStr ,"=",";") 1158 1159 if(numtype(xRef_M)!=0 || numtype(yRef_M)!=0) //not a normal number 1160 Abort "Centroid has not been set for the Middle carriage. Open the file and use the Marquee to find the centroid." 1161 endif 1162 // 1163 // either read the values or set default values 1164 if(!gIgnoreBack) 1165 refStr = V_getReductionComments(emptyFileName_B) 1166 xRef_B = NumberByKey("XREF", refStr ,"=",";") 1167 yRef_B = NumberByKey("YREF", refStr ,"=",";") 1168 if(numtype(xRef_B)!=0 || numtype(yRef_B)!=0) //not a normal number 1169 Abort "Centroid has not been set for the Back carriage. Open the file and use the Marquee to find the centroid." 1170 endif 1171 else 1172 //default values 1173 xref_B = 340 1174 yRef_B = 828 1175 endif 1176 1177 Print xRef_F,xRef_M,xRef_B 1178 Print yRef_F,yRef_M,yRef_B 1179 1180 // pass these values to the procedure 1181 // but what if some of the values are bad? 1182 // these are both procedures, not functions... 1183 // V_DeriveBeamCenters() 1184 // Make/O/T newPanelWave = {"FL","FR","FT","FB","ML","MR","MT","MB","B"} 1185 Make/O/D/N=9 newXCtr_cm,newYCtr_cm 1186 1187 // Wave/T newPanelWave 1188 Wave newXCtr_cm,newYCtr_cm 1189 1190 // Edit newXCtr_cm,newYCtr_cm 1191 1192 // V_fDeriveBeamCenters(x_FrontReference,y_FrontReference,x_MiddleReference,y_MiddleReference) 1193 // start with the front 1194 // FR 1195 newXCtr_cm[1] = xRef_F 1196 newYCtr_cm[1] = yRef_F 1197 // FL 1198 newXCtr_cm[0] = xRef_F + kBCtrOffset_FL_x //NEW Dec 2018 1199 newYCtr_cm[0] = yRef_F + kBCtrOffset_FL_y 1200 // FB 1201 newXCtr_cm[3] = xRef_F + kBCtrOffset_FB_x // NEW Dec 2018 1202 newYCtr_cm[3] = yRef_F + kBCtrOffset_FB_y 1203 // FT 1204 newXCtr_cm[2] = xRef_F + kBCtrOffset_FT_x // NEW Dec 2018 (not a duplicate of FB anymore) 1205 newYCtr_cm[2] = yRef_F + kBCtrOffset_FT_y 1206 1207 // MR 1208 newXCtr_cm[5] = xRef_M 1209 newYCtr_cm[5] = yRef_M 1210 // ML 1211 newXCtr_cm[4] = xRef_M + kBCtrOffset_ML_x 1212 newYCtr_cm[4] = yRef_M + kBCtrOffset_ML_y 1213 // MB 1214 newXCtr_cm[7] = xRef_M + kBCtrOffset_MB_x 1215 newYCtr_cm[7] = yRef_M + kBCtrOffset_MB_y 1216 // MT 1217 newXCtr_cm[6] = xRef_M + kBCtrOffset_MT_x 1218 newYCtr_cm[6] = yRef_M + kBCtrOffset_MT_y 1219 1220 // default value for B (approx center) in pixels 1221 newXCtr_cm[8] = xref_B 1222 newYCtr_cm[8] = yref_B 1223 1224 1225 // XY patch panel values are located at: 1226 // SetVariable setvar0,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Lo 1227 // SetVariable setvar1,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Hi 1228 1229 // SetDataFolder root:Packages:NIST:VSANS:Globals:Patch 1230 // display the wave 1231 // Edit/W=(180,40,500,370)/HOST=# panelW,xCtr_cm,yCtr_cm 1232 1233 // and the panel Proc V_Patch_xyCtr_Panel() : Panel 1234 1235 Variable lo,hi 1236 V_Find_LoHi_RunNum(lo,hi) 1237 NVAR gFileNum_Lo=root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Lo 1238 NVAR gFileNum_Hi=root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Hi 1239 1240 gFileNum_Lo = lo 1241 gFileNum_Hi = hi 1242 1243 // wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW 1244 wave xCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:xCtr_cm 1245 wave yCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:yCtr_cm 1246 1247 // panelW = newPanelW 1248 xCtr_cm = newXCtr_cm 1249 yCtr_cm = newYCtr_cm 1250 1251 // open the panel 1252 Execute "V_PatchDet_xyCenters_Panel()" 1253 1254 DoAlert 0,"These are the new beam centers. Nothing has been written to files. You need to check the file numbers and click Write." 1255 1256 return(0) 1257 End 1258 1259 1260 1261 1262 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Marquee_Operations.ipf
r1242 r1243 275 275 End 276 276 277 Function V_FindCentroid() : GraphMarquee 277 278 279 Function V_Find_BeamCentroid() : GraphMarquee 278 280 279 281 // //get the current displayed data (so the correct folder is used) … … 284 286 Variable left,right,bottom,top,ii,jj,counts 285 287 Variable x_mm_sum,y_mm_sum,x_mm,y_mm 288 Variable xRef,yRef 286 289 287 290 … … 383 386 Print "FRONT Reference X-center (cm) = ",x_mm/10 384 387 Print "FRONT Reference Y-center (cm) = ",y_mm/10 + yCorrection*yPixSize 388 xRef = x_mm/10 389 yRef = y_mm/10 + yCorrection*yPixSize 385 390 endif 386 391 … … 393 398 Print "MIDDLE Reference X-center (cm) = ",x_mm/10 394 399 Print "MIDDLE Reference Y-center (cm) = ",y_mm/10 + yCorrection*yPixSize 400 xRef = x_mm/10 401 yRef = y_mm/10 + yCorrection*yPixSize 395 402 endif 396 403 … … 400 407 Print "FRONT Reference X-center (cm) = ",x_mm/10 - kBCtrOffset_FL_x // NEW Dec 2018 values 401 408 Print "FRONT Reference Y-center (cm) = ",y_mm/10 - kBCtrOffset_FL_y 409 xRef = x_mm/10 - kBCtrOffset_FL_x 410 yRef = y_mm/10 - kBCtrOffset_FL_y 402 411 endif 403 412 … … 405 414 Print "MIDDLE Reference X-center (cm) = ",x_mm/10 - kBCtrOffset_ML_x 406 415 Print "MIDDLE Reference Y-center (cm) = ",y_mm/10 - kBCtrOffset_ML_y 407 endif 408 endif 416 xRef = x_mm/10 - kBCtrOffset_ML_x 417 yRef = y_mm/10 - kBCtrOffset_ML_y 418 endif 419 endif 420 421 // TODO 422 // ?? store the xy reference values somewhere so that the conversion to proper 423 // beam center values can be done automatically, rather than copying numbers into a procedure 424 // 425 // - either I need 6 globals for the three panels, or I need to store the values in the 426 // reduction block of the file (comment?) - but I don't have the fileName here - could I find it 427 // somewhere? gFileList in the current data folder? 428 // 429 String ctrStr="" 430 if(cmpstr(detStr,"B") == 0) 431 xRef = xCtr 432 yRef = yCtr //these are in pixels 433 endif 434 sprintf ctrStr,"XREF=%g;YREF=%g;",xRef,yRef 435 SVAR gFileList = $("root:Packages:NIST:VSANS:"+gCurDispType+":gFileList") 436 437 V_writeReductionComments(gFileList,ctrStr) 438 439 409 440 410 441 //back to root folder (redundant) -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf
r1242 r1243 429 429 SetDrawLayer/W=MaskEditPanel ProgFront 430 430 SetDrawEnv/W=MaskEditPanel xcoord= bottom,ycoord= left,save //be sure to use axis coordinate mode 431 SetDrawEnv/W=MaskEditPanel fillPat=1 431 SetDrawEnv/W=MaskEditPanel fillPat=1 ,fillfgc= (65535,65535,65535,39000) //set the draw fill to translucent white 432 SetDrawEnv/W=MaskEditPanel save 432 433 433 434 break -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf
r1242 r1243 32 32 "-" 33 33 "Derive Beam Centers From Reference",V_DeriveBeamCenters() 34 "Derive Beam Centers From Open Beam Files",V_AutoBeamCenter() 34 35 "-" 35 36 "Back Detector Saturation",Vm_NumberSaturated() -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf
r1242 r1243 2357 2357 Make/O/D/N=9 xCtr_cm,yCtr_cm 2358 2358 Make/O/T/N=9 panelW 2359 2360 PanelW = {"FL","FR","FT","FB","ML","MR","MT","MB","B"} 2359 2361 2360 2362 Variable/G gFileNum_Lo,gFileNum_Hi -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Utilities_General.ipf
r1242 r1243 1570 1570 End 1571 1571 1572 1573 1574 1572 /// 1575 1573 1574 1575 Function V_PrintLoHiNum() 1576 1577 Variable lo,hi 1578 V_Find_LoHi_RunNum(lo,hi) 1579 Print "lo = ",lo 1580 Print "hi = ",hi 1581 1582 End 1583 1584 // 1585 // returns the lo, hi run numbers in the current directory 1586 // (passed by reference) 1587 // 1588 // 1589 // note that 1111 (is a special number for the ReadNoise file, ignore this run) 1590 // 1591 Function V_Find_LoHi_RunNum(lo,hi) 1592 Variable &lo,&hi 1593 1594 String fileList="",fname="" 1595 Variable ii,num,runNum 1596 1597 // set to values that will change 1598 lo = 1e8 1599 hi = 0 1600 1601 // get a file listing of all raw data files 1602 fileList = V_GetRawDataFileList() 1603 num = itemsInList(fileList) 1604 1605 for(ii=0;ii<num;ii+=1) 1606 fname = stringFromList(ii,fileList) 1607 runNum = V_GetRunNumFromFile(fname) 1608 1609 if(runNum != 1111) //ignore this run 1610 lo = runNum < lo ? runNum : lo // if runNum < lo, update 1611 hi = runNum > hi ? runNum : hi // if runNum > hi, update 1612 endif 1613 endfor 1614 1615 return(0) 1616 End 1617 1618
Note: See TracChangeset
for help on using the changeset viewer.