- Timestamp:
- May 18, 2018 10:32:22 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_EventModeProcessing.ipf
r1091 r1100 2 2 #pragma IgorVersion=6.22 3 3 4 5 4 6 // 5 7 // Event mode prcessing for VSANS … … 7 9 // First pass, getting the basics to work 8 10 // 9 // -- need TOF processing for wavelength calibration10 // -- document this so it can be done quickly and easily.11 // x- need TOF processing for wavelength calibration 12 // x- document this so it can be done quickly and easily. 11 13 // 12 14 … … 50 52 51 53 // 52 // x- these dimensions are hard-wired (OK for now, will need to be additional definitions for Back detector)54 // x- these dimensions are hard-wired 53 55 // 54 56 // XBINS is for an individual panel … … 98 100 String/G root:Packages:NIST:VSANS:Event:gVsansStr="" 99 101 Variable/G root:Packages:NIST:VSANS:Event:gRevision = 0 100 Variable/G root:Packages:NIST:VSANS:Event:gOffset=0 // = 2 2bytes if no disabled tubes102 Variable/G root:Packages:NIST:VSANS:Event:gOffset=0 // = 25 bytes if no disabled tubes 101 103 Variable/G root:Packages:NIST:VSANS:Event:gTime1=0 102 104 Variable/G root:Packages:NIST:VSANS:Event:gTime2=0 … … 117 119 Variable/G root:Packages:NIST:VSANS:Event:gEvent_logint = 1 118 120 119 Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 3// ==0 for "stream", ==1 for Oscillatory121 Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 0 // ==0 for "stream", ==1 for Oscillatory 120 122 Variable/G root:Packages:NIST:VSANS:Event:gRemoveBadEvents = 1 // ==1 to remove "bad" events, ==0 to read "as-is" 121 123 Variable/G root:Packages:NIST:VSANS:Event:gSortStreamEvents = 0 // ==1 to sort the event stream, a last resort for a stream of data … … 131 133 132 134 133 // for decimation (not used for VSANS - may be added back in the future 135 // for decimation (not used for VSANS - may be added back in the future) 134 136 Variable/G root:Packages:NIST:VSANS:Event:gEventFileTooLarge = 1500 // 1500 MB considered too large 135 137 Variable/G root:Packages:NIST:VSANS:Event:gDecimation = 100 … … 157 159 ModifyPanel fixedSize=1,noEdit =1 158 160 159 SetDrawLayer UserBack160 DrawText 479,345,"Stream Data"161 DrawLine 563,338,775,338162 DrawText 479,419,"Oscillatory or Stream Data"163 DrawLine 647,411,775,411161 // SetDrawLayer UserBack 162 // DrawText 479,345,"Stream Data" 163 // DrawLine 563,338,775,338 164 // DrawText 479,419,"Oscillatory or Stream Data" 165 // DrawLine 647,411,775,411 164 166 165 167 // ShowTools/A 166 Button button0,pos={14, 87},size={150,20},proc=V_LoadEventLog_Button,title="Load Event Log File"168 Button button0,pos={14,70},size={150,20},proc=V_LoadEventLog_Button,title="Load Event Log File" 167 169 Button button0,fSize=12 170 Button button23,pos={14,100},size={150,20},proc=V_LoadEventLog_Button,title="Load From RAW" 171 Button button23,fSize=12 168 172 TitleBox tb1,pos={475,500},size={266,86},fSize=10 169 173 TitleBox tb1,variable= root:Packages:NIST:VSANS:Event:gEventDisplayString … … 171 175 CheckBox chkbox2,pos={376,151},size={81,15},proc=V_LogIntEvent_Proc,title="Log Intensity" 172 176 CheckBox chkbox2,fSize=10,variable= root:Packages:NIST:VSANS:Event:gEvent_logint 173 CheckBox chkbox3,pos={14,1 25},size={119,15},title="Remove Bad Events?",fSize=10177 CheckBox chkbox3,pos={14,150},size={119,15},title="Remove Bad Events?",fSize=10 174 178 CheckBox chkbox3,variable= root:Packages:NIST:VSANS:Event:gRemoveBadEvents 175 179 176 180 Button doneButton,pos={738,36},size={50,20},proc=V_EventDone_Proc,title="Done" 177 181 Button doneButton,fSize=12 178 Button button2,pos={486,200},size={140,20},proc=V_ShowEventDataButtonProc,title="Show Event Data"179 Button button3,pos={486,228},size={140,20},proc=V_ShowBinDetailsButtonProc,title="Show Bin Details"180 Button button5,pos={633,228},size={140,20},proc=V_ExportSlicesButtonProc,title="Export Slices as VAX",disable=2181 182 Button button6,pos={748,9},size={40,20},proc=V_EventModeHelpButtonProc,title="?" 182 183 184 // Button button5,pos={633,228},size={140,20},proc=V_ExportSlicesButtonProc,title="Export Slices as VAX",disable=2 185 186 Button button8,pos={570,35},size={120,20},proc=V_CustomBinButtonProc,title="Custom Bins" 187 Button button2,pos={570,65},size={140,20},proc=V_ShowEventDataButtonProc,title="Show Event Data" 188 Button button3,pos={570,95},size={140,20},proc=V_ShowBinDetailsButtonProc,title="Show Bin Details" 189 190 183 191 Button button7,pos={211,33},size={120,20},proc=V_AdjustEventDataButtonProc,title="Adjust Events" 184 Button button8,pos={653,201},size={120,20},proc=V_CustomBinButtonProc,title="Custom Bins"185 192 Button button4,pos={211,63},size={120,20},proc=V_UndoTimeSortButtonProc,title="Undo Time Sort" 186 193 Button button18,pos={211,90},size={120,20},proc=V_EC_ImportWavesButtonProc,title="Import Edited" … … 200 207 201 208 // NEW FOR VSANS 202 Button button21,pos={580,70},size={120,20},proc=V_SplitToPanels_Button,title="Split to Panels" 203 Button button22,pos={580,90},size={120,20},proc=V_GraphPanels_Button,title="Show Panels" 204 205 Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 206 Button button14,pos={488,350},size={120,20},proc=V_Stream_LoadDecim,title="Load Split List",disable=2 207 Button button19,pos={649,350},size={120,20},proc=V_Stream_LoadAdjustedList,title="Load Edited List",disable=2 208 Button button20,pos={680,376},size={90,20},proc=V_ShowList_ToLoad,title="Show List",disable=2 209 SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor",disable=2 210 SetVariable setvar3,fSize=10 211 SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:VSANS:Event:gDecimation 212 213 Button button15_0,pos={488,425},size={110,20},proc=V_AccumulateSlicesButton,title="Add First Slice",disable=2 214 Button button16_1,pos={488,450},size={110,20},proc=V_AccumulateSlicesButton,title="Add Next Slice",disable=2 215 Button button17_2,pos={620,425},size={110,20},proc=V_AccumulateSlicesButton,title="Display Total",disable=2 216 217 CheckBox chkbox1_0,pos={25,34},size={69,14},title="Oscillatory",fSize=10 209 Button button21,pos={488,205},size={120,20},proc=V_SplitToPanels_Button,title="Split to Panels" 210 Button button22,pos={488,240},size={120,20},proc=V_GraphPanels_Button,title="Show Panels" 211 212 Button button24,pos={488,270},size={180,20},proc=V_DuplRAWForExport_Button,title="Duplicate RAW for Export" 213 Button button25,pos={488,300},size={180,20},proc=V_CopySlicesForExport_Button,title="Copy Slices for Export" 214 Button button26,pos={488,330},size={180,20},proc=V_SaveExportedNexus_Button,title="Save Exported to Nexus" 215 216 // Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 217 // Button button14,pos={488,350},size={120,20},proc=V_Stream_LoadDecim,title="Load Split List",disable=2 218 // Button button19,pos={649,350},size={120,20},proc=V_Stream_LoadAdjustedList,title="Load Edited List",disable=2 219 // Button button20,pos={680,376},size={90,20},proc=V_ShowList_ToLoad,title="Show List",disable=2 220 // SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor",disable=2 221 // SetVariable setvar3,fSize=10 222 // SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:VSANS:Event:gDecimation 223 // 224 // Button button15_0,pos={488,425},size={110,20},proc=V_AccumulateSlicesButton,title="Add First Slice",disable=2 225 // Button button16_1,pos={488,450},size={110,20},proc=V_AccumulateSlicesButton,title="Add Next Slice",disable=2 226 // Button button17_2,pos={620,425},size={110,20},proc=V_AccumulateSlicesButton,title="Display Total",disable=2 227 228 CheckBox chkbox1_0,pos={25,30},size={69,14},title="Oscillatory",fSize=10 218 229 CheckBox chkbox1_0,mode=1,proc=V_EventModeRadioProc,value=0 219 CheckBox chkbox1_1,pos={25,59},size={53,14},title="Stream",fSize=10 220 CheckBox chkbox1_1,proc=V_EventModeRadioProc,value=0,mode=1 221 CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 222 CheckBox chkbox1_2,proc=V_EventModeRadioProc,value=0,mode=1 223 CheckBox chkbox1_3,pos={104,34},size={37,14},title="TOF",fSize=10 224 CheckBox chkbox1_3,proc=V_EventModeRadioProc,value=1,mode=1 225 226 GroupBox group0_0,pos={5,5},size={174,112},title="(1) Loading Mode",fSize=12,fStyle=1 227 GroupBox group0_1,pos={372,5},size={192,127},title="(3) Bin Events",fSize=12,fStyle=1 228 GroupBox group0_2,pos={477,169},size={310,92},title="(4) View / Export",fSize=12,fStyle=1 229 GroupBox group0_3,pos={191,5},size={165,117},title="(2) Edit Events",fSize=12,fStyle=1 230 GroupBox group0_4,pos={474,278},size={312,200},title="Split / Accumulate Files",fSize=12 231 GroupBox group0_4,fStyle=1 230 CheckBox chkbox1_1,pos={25,50},size={53,14},title="Stream",fSize=10 231 CheckBox chkbox1_1,proc=V_EventModeRadioProc,value=1,mode=1 232 // CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 233 // CheckBox chkbox1_2,proc=V_EventModeRadioProc,value=0,mode=1 234 CheckBox chkbox1_3,pos={104,30},size={37,14},title="TOF",fSize=10 235 CheckBox chkbox1_3,proc=V_EventModeRadioProc,value=0,mode=1 236 237 CheckBox chkbox1_4,pos={30,125},size={37,14},title="F",fSize=10 238 CheckBox chkbox1_4,proc=V_EventCarrRadioProc,value=1,mode=1 239 CheckBox chkbox1_5,pos={90,125},size={37,14},title="M",fSize=10 240 CheckBox chkbox1_5,proc=V_EventCarrRadioProc,value=0,mode=1 241 242 GroupBox group0_0,pos={5,5},size={174,140},title="(1) Loading Mode",fSize=12,fStyle=1 243 GroupBox group0_3,pos={191,5},size={165,130},title="(2) Edit Events",fSize=12,fStyle=1 244 GroupBox group0_1,pos={372,5},size={350,130},title="(3) Bin Events",fSize=12,fStyle=1 245 GroupBox group0_2,pos={477,169},size={310,300},title="(4) View / Export",fSize=12,fStyle=1 246 247 // GroupBox group0_4,pos={474,278},size={312,200},title="Split / Accumulate Files",fSize=12 248 // GroupBox group0_4,fStyle=1 232 249 233 250 Display/W=(10,170,460,610)/HOST=# … … 248 265 EndMacro 249 266 250 // 251 // takes the data that is loaded and binned as a fake 267 268 // 269 // 270 Function V_DuplRAWForExport_Button(ba) : ButtonControl 271 STRUCT WMButtonAction &ba 272 273 switch( ba.eventCode ) 274 case 2: // mouse up 275 // click code here 276 V_DuplicateRAWForExport() 277 // 278 break 279 case -1: // control being killed 280 break 281 endswitch 282 283 return 0 284 End 285 286 287 // 288 // 289 Function V_CopySlicesForExport_Button(ba) : ButtonControl 290 STRUCT WMButtonAction &ba 291 292 switch( ba.eventCode ) 293 case 2: // mouse up 294 // click code here 295 String detStr="" 296 ControlInfo chkbox1_4 297 if(V_value == 1) 298 detStr = "F" 299 else 300 detStr = "M" 301 endif 302 // 303 V_CopySlicesForExport(detStr) 304 // 305 break 306 case -1: // control being killed 307 break 308 endswitch 309 310 return 0 311 End 312 313 314 // 315 // 316 Function V_SaveExportedNexus_Button(ba) : ButtonControl 317 STRUCT WMButtonAction &ba 318 319 switch( ba.eventCode ) 320 case 2: // mouse up 321 // click code here 322 String detStr="" 323 324 // 325 Execute "V_SaveExportedEvents()" 326 // 327 break 328 case -1: // control being killed 329 break 330 endswitch 331 332 return 0 333 End 334 335 336 337 338 339 // 340 // takes the event data that is loaded and binned as a combined 252 341 // (192 x 128) panel to the four LRTB panels, each with 48 tubes 253 342 // … … 311 400 gEventModeRadioVal= MODE_STREAM 312 401 break 313 case "chkbox1_2":314 gEventModeRadioVal= MODE_TISANE315 break402 // case "chkbox1_2": 403 // gEventModeRadioVal= MODE_TISANE 404 // break 316 405 case "chkbox1_3": 317 406 gEventModeRadioVal= MODE_TOF … … 320 409 CheckBox chkbox1_0,value= gEventModeRadioVal==MODE_OSCILL 321 410 CheckBox chkbox1_1,value= gEventModeRadioVal==MODE_STREAM 322 CheckBox chkbox1_2,value= gEventModeRadioVal==MODE_TISANE411 // CheckBox chkbox1_2,value= gEventModeRadioVal==MODE_TISANE 323 412 CheckBox chkbox1_3,value= gEventModeRadioVal==MODE_TOF 324 413 325 414 return(0) 326 415 End 416 417 Function V_EventCarrRadioProc(name,value) 418 String name 419 Variable value 420 421 strswitch (name) 422 case "chkbox1_4": 423 CheckBox chkbox1_4,value= 1 424 CheckBox chkbox1_5,value= 0 425 break 426 case "chkbox1_5": 427 CheckBox chkbox1_4,value= 0 428 CheckBox chkbox1_5,value= 1 429 break 430 endswitch 431 432 return(0) 433 End 434 327 435 328 436 Function V_AdjustEventDataButtonProc(ba) : ButtonControl … … 940 1048 endif 941 1049 942 Open/R/D/P=catPathName/F=fileFilters fileref 943 filename = S_filename 944 if(strlen(S_filename) == 0) 945 // user cancelled 946 DoAlert 0,"No file selected, no file loaded." 947 return(1) 1050 // load from raw? 1051 // if so, which carriage? 1052 String loadFromRAW 1053 String detStr 1054 if(cmpstr(ctrlName,"button23")==0) 1055 loadFromRAW = "Yes" 1056 ControlInfo chkbox1_4 1057 if(V_value == 1) 1058 detStr = "F" 1059 else 1060 detStr = "M" 1061 endif 948 1062 endif 949 1063 1064 // Prompt loadFromRAW,"Load from RAW?",popup,"Yes;No;" 1065 // Prompt detStr,"Carriage",popup,"M;F;" 1066 // DoPrompt "Load data from...",loadFromRAW,detStr 1067 1068 // if(V_flag) //user cancel 1069 // return(0) 1070 // endif 1071 1072 if(cmpstr(loadFromRAW,"Yes")==0) 1073 PathInfo catPathName 1074 filename = S_Path + V_getDetEventFileName("RAW",detStr+"L") 1075 1076 // check here to see if the file can be found. if not report the error and exit 1077 Open/R/Z=1 fileref as fileName 1078 if(V_flag == 0) 1079 Close fileref 1080 else 1081 DoAlert 0,"The event file associated with RAW cannot be found. "+filename 1082 return(0) 1083 endif 1084 else 1085 Open/R/D/P=catPathName/F=fileFilters fileref 1086 filename = S_filename 1087 if(strlen(S_filename) == 0) 1088 // user cancelled 1089 DoAlert 0,"No file selected, no file loaded." 1090 return(1) 1091 endif 1092 endif 950 1093 // keep this , but set to 1.5 GB 951 1094 // since I'm now in 64-bit space … … 1021 1164 NVAR gResol = root:Packages:NIST:VSANS:Event:gResol //timeStep in clock frequency (Hz) 1022 1165 Printf "Time Step = 1/Frequency (ns) = %g\r",(1/gResol)*1e9 1166 variable timeStep_s = (1/gResol) 1167 1168 // DONE: 1169 // x- the time scaling is done. 1170 // TODO: VERIFY 1171 // ??? timeStep from the clock frequency is not right--- the step appears to be 100 ns??? 1172 // 1173 timeStep_s = 100e-9 1023 1174 1024 1175 ///// … … 1026 1177 // 1027 1178 1028 // TODO: 1029 // -- the time scaling is NOT done. it is still in raw ticks. 1030 // 1179 1031 1180 1032 1181 if(mode == MODE_STREAM) // continuous "Stream" mode - start from zero … … 1037 1186 v_tic() 1038 1187 printf "rescale time = " 1039 rescaledTime = 1*(timePt-timePt[0]) //convert to nanoseconds and start from zero 1188 // rescaledTime = 1*(timePt-timePt[0]) //convert to nanoseconds and start from zero 1189 rescaledTime = timeStep_s*(timePt-timePt[0]) //convert to seconds and start from zero 1040 1190 v_toc() 1041 1191 v_tic() … … 1048 1198 if(mode == MODE_OSCILL) // oscillatory mode - don't adjust the times, we get periodic t0 to reset t=0 1049 1199 Duplicate/O timePt rescaledTime 1050 rescaledTime *= 1 //convert to nanoseconds and that's all1200 rescaledTime *= timeStep_s //convert to seconds and that's all 1051 1201 t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 1052 1202 … … 1060 1210 if(mode == MODE_TOF) // TOF mode - don't adjust the times, we get periodic t0 to reset t=0 1061 1211 Duplicate/O timePt rescaledTime 1062 rescaledTime *= 1 //convert to nanoseconds and that's all1212 rescaledTime *= timeStep_s //convert to seconds and that's all 1063 1213 t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 1064 1214
Note: See TracChangeset
for help on using the changeset viewer.