Changeset 1046
- Timestamp:
- Jun 14, 2017 3:18:49 PM (6 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_EventModeProcessing.ipf
r1045 r1046 6 6 // TODO: 7 7 // 8 // -- Can any of this be multithreaded? 9 // -- the histogram operation, the Indexing for the histogram, all are candidates 10 // -- can the decoding be multithreaded as a wave assignment speedup? 11 // 12 // 8 13 // -- search for TODO for unresolved issues not on this list 9 14 // … … 13 18 // 14 19 // -- examples? 15 //16 // -- ?? need way to get correspondence between .hst files and VAX files? Names are all different. See17 // DateAndTime2HSTName() functions and similar @ bottom of this file18 //19 // x- add the XOP to the distribution package20 //21 // x- Need to make sure that the rescaledTime and the differentiated time graphs are22 // being properly updated when the data is processed, modified, etc.23 //24 // -- I need better nomenclature other than "stream" for the "continuous" data set.25 // It's all a stream, just sometimes it's not oscillatory26 20 // 27 21 // … … 31 25 // to prevent the "atuo-detection" of data as RGB 32 26 // 33 // -- Do something with the PP events. Currently, only the PP events that are XY (just the34 // type 0 events (since I still need to find out what they realy mean)35 //36 // -- Add a switch to allow Sorting of the Stream data to remove the "time-reversed" data37 // points. Maybe not kosher, but would clean things up.38 //39 ///////////////////////////////40 //41 // NOTE -- to be able to show the T0 and PP event locations/times, force the loader to use the Igor code rather than42 // the XOP. Then there will be waves generated with their locations: T0Time and T0EventNum, PPTime and PPEventNum. Edit these waves43 // and (1) delete the zero points at the end of the waves and (2) multiply the Time wave * 1e-7 to convert to seconds.44 // Then the waves can be plotted on top of the event data, so it can be seen where these events were identified.45 27 // 46 28 /////////////// SWITCHES ///////////////// … … 53 35 // 54 36 // 55 ///////// DONE ////////// 56 // 57 // X- memory issues: 58 // -- in LoadEvents -- should I change the MAKE to: 59 // /I/U is unsigned 32-bit integer (for the time) 60 // /B/U is unsigned 8-bit integer (max val=255) for the x and y values 61 // -- then how does this affect downstream processing - such as rescaledTime, differentiation, etc. 62 // x- and can I re-write the XOP to create these types of data waves, and properly fill them... 63 // 64 // **- any integer waves must be translated by Igor into FP to be able to be displayed or for any 65 // type of analysis. so it's largely a waste of time to use integers. so simply force the XOP to 66 // generate only SP waves. this will at least save some space. 67 // 68 // 69 // 70 // x- Is there any way to improve the speed of the loader? How could an XOP be structured 71 // for maximum flexibility? Leave the post processing to Igor, but how much for the XOP 72 // to do? And can it handle such large amounts of data to pass back and forth, or 73 // does it need to be written as an operation, rather than a function??? I'd really 74 // rather that Igor handles the memory management, not me, if I write the XOP. 75 // 76 // **- as of 11/27, the OSX version of the XOP event loader is about 35x faster for the load! 77 // and is taking approx 1.8s/28MB, or about 6.5s/100MB of file. quite reasonable now, and 78 // probably a bit faster yet on the PC. 79 // 80 // 81 // X- fix the log/lin display - it's not working correctly 82 // I could use ModifyImage and log = 0|1 keyword for the log Z display 83 // rather than creating a duplicate wave of log(data) 84 // -- it's in the Function sliceSelectEvent_Proc() 85 // 86 // X- add controls to show the bar graph 87 // x- add popup for selecting the binning type 88 // x- add ability to save the slices to RAW VAX files 89 // X- add control to show the bin counts and bin end times 90 // x- ADD buttons, switches, etc for the oscillatory mode - so that this can be accessed 91 // 92 // x- How are the headers filled for the VAX files from Teabag??? 93 // -- I currently read the events 2x. Once to count the events to make the waves the proper 94 // size, then a second time to actualy process the events. Would it be faster to insert points 95 // as needed, or to estimate the size, and make it too large, then trim at the end... 96 // ((( NO -- I have no good way of getting a proper estimate of how many XY events there are for a file)) 97 // 98 // 99 // 100 101 102 // 103 // These are also defined in the TISANE procedure file. In both files they are declared 104 // as Static, so they are local to each procedure 105 // 106 Static Constant ATXY = 0 107 Static Constant ATXYM = 2 108 Static Constant ATMIR = 1 109 Static Constant ATMAR = 3 110 111 Static Constant USECSPERTICK=0.1 // microseconds 112 Static Constant TICKSPERUSEC=10 113 Static Constant XBINS=128 37 // 38 // 39 40 41 // TODO -- these dimensions are hard-wired and will be wrong half of the time 42 // 43 Static Constant XBINS=48 114 44 Static Constant YBINS=128 115 //116 45 117 46 Static Constant MODE_STREAM = 0 … … 119 48 Static Constant MODE_TISANE = 2 120 49 Static Constant MODE_TOF = 3 121 122 50 123 51 … … 131 59 End 132 60 133 61 // TODO: 62 // -- need an index table with the tube <-> panel correspondence 63 // 134 64 Function V_Init_Event() 135 65 … … 138 68 String/G root:Packages:NIST:VSANS:Event:gEvent_logfile 139 69 String/G root:Packages:NIST:VSANS:Event:gEventDisplayString="Details of the file load" 140 141 // Variable/G root:Packages:NIST:VSANS:Event:AIMTYPE_XY=0 // XY Event 142 // Variable/G root:Packages:NIST:VSANS:Event:AIMTYPE_XYM=2 // XY Minor event 143 // Variable/G root:Packages:NIST:VSANS:Event:AIMTYPE_MIR=1 // Minor rollover event 144 // Variable/G root:Packages:NIST:VSANS:Event:AIMTYPE_MAR=3 // Major rollover event 145 146 Variable/G root:Packages:NIST:VSANS:Event:gEvent_time_msw = 0 147 Variable/G root:Packages:NIST:VSANS:Event:gEvent_time_lsw = 0 70 71 72 // globals that are the header of the VSANS event file 73 String/G root:Packages:NIST:VSANS:Event:gVsansStr="" 74 Variable/G root:Packages:NIST:VSANS:Event:gRevision = 0 75 Variable/G root:Packages:NIST:VSANS:Event:gOffset=0 // = 22 bytes if no disabled tubes 76 Variable/G root:Packages:NIST:VSANS:Event:gTime1=0 77 Variable/G root:Packages:NIST:VSANS:Event:gTime2=0 78 Variable/G root:Packages:NIST:VSANS:Event:gTime3=0 79 Variable/G root:Packages:NIST:VSANS:Event:gTime4=0 // these 4 time pieces are supposed to be 8 bytes total 80 Variable/G root:Packages:NIST:VSANS:Event:gTime5=0 // these 5 time pieces are supposed to be 10 bytes total 81 String/G root:Packages:NIST:VSANS:Event:gDetStr="" 82 Variable/G root:Packages:NIST:VSANS:Event:gVolt=0 83 Variable/G root:Packages:NIST:VSANS:Event:gResol=0 //time resolution in nanoseconds 84 // TODO -- need a wave? for the list of disabled tubes 85 // don't know how many there might be, or why I would need to know 86 148 87 Variable/G root:Packages:NIST:VSANS:Event:gEvent_t_longest = 0 149 88 … … 153 92 Variable/G root:Packages:NIST:VSANS:Event:gEvent_logint = 1 154 93 155 Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 0// ==0 for "stream", ==1 for Oscillatory94 Variable/G root:Packages:NIST:VSANS:Event:gEvent_Mode = 3 // ==0 for "stream", ==1 for Oscillatory 156 95 Variable/G root:Packages:NIST:VSANS:Event:gRemoveBadEvents = 1 // ==1 to remove "bad" events, ==0 to read "as-is" 157 96 Variable/G root:Packages:NIST:VSANS:Event:gSortStreamEvents = 0 // ==1 to sort the event stream, a last resort for a stream of data … … 181 120 End 182 121 183 // 184 // -- extra bits of buttons... not used 185 // 186 // Button button9 title="Decimation",size={100,20},pos={490,400},proc=E_ShowDecimateButton 187 // 188 // Button button11,pos={490,245},size={150,20},proc=LoadDecimateButtonProc,title="Load and Decimate" 189 // Button button12,pos={490,277},size={150,20},proc=ConcatenateButtonProc,title="Concatenate" 190 // Button button13,pos={490,305},size={150,20},proc=DisplayConcatenatedButtonProc,title="Display Concatenated" 191 // 192 // GroupBox group0 title="Manual Controls",size={185,112},pos={490,220} 193 // 194 // NewPanel /W=(82,44,854,664)/N=EventModePanel/K=2 195 // DoWindow/C EventModePanel 196 // ModifyPanel fixedSize=1,noEdit =1 122 123 197 124 Proc VSANS_EventModePanel() 198 125 PauseUpdate; Silent 1 // building window... … … 208 135 209 136 // ShowTools/A 210 Button button0,pos={14,87},size={150,20},proc= LoadEventLog_Button,title="Load Event Log File"137 Button button0,pos={14,87},size={150,20},proc=V_LoadEventLog_Button,title="Load Event Log File" 211 138 Button button0,fSize=12 212 139 TitleBox tb1,pos={475,500},size={266,86},fSize=10 213 140 TitleBox tb1,variable= root:Packages:NIST:VSANS:Event:gEventDisplayString 214 141 215 CheckBox chkbox2,pos={376,151},size={81,15},proc= LogIntEvent_Proc,title="Log Intensity"142 CheckBox chkbox2,pos={376,151},size={81,15},proc=V_LogIntEvent_Proc,title="Log Intensity" 216 143 CheckBox chkbox2,fSize=10,variable= root:Packages:NIST:VSANS:Event:gEvent_logint 217 144 CheckBox chkbox3,pos={14,125},size={119,15},title="Remove Bad Events?",fSize=10 218 145 CheckBox chkbox3,variable= root:Packages:NIST:VSANS:Event:gRemoveBadEvents 219 146 220 Button doneButton,pos={738,36},size={50,20},proc= EventDone_Proc,title="Done"147 Button doneButton,pos={738,36},size={50,20},proc=V_EventDone_Proc,title="Done" 221 148 Button doneButton,fSize=12 222 Button button2,pos={486,200},size={140,20},proc= ShowEventDataButtonProc,title="Show Event Data"223 Button button3,pos={486,228},size={140,20},proc= ShowBinDetailsButtonProc,title="Show Bin Details"224 Button button5,pos={633,228},size={140,20},proc= ExportSlicesButtonProc,title="Export Slices as VAX"225 Button button6,pos={748,9},size={40,20},proc= EventModeHelpButtonProc,title="?"149 Button button2,pos={486,200},size={140,20},proc=V_ShowEventDataButtonProc,title="Show Event Data" 150 Button button3,pos={486,228},size={140,20},proc=V_ShowBinDetailsButtonProc,title="Show Bin Details" 151 Button button5,pos={633,228},size={140,20},proc=V_ExportSlicesButtonProc,title="Export Slices as VAX",disable=2 152 Button button6,pos={748,9},size={40,20},proc=V_EventModeHelpButtonProc,title="?" 226 153 227 Button button7,pos={211,33},size={120,20},proc= AdjustEventDataButtonProc,title="Adjust Events"228 Button button8,pos={653,201},size={120,20},proc= CustomBinButtonProc,title="Custom Bins"229 Button button4,pos={211,63},size={120,20},proc= UndoTimeSortButtonProc,title="Undo Time Sort"230 Button button18,pos={211,90},size={120,20},proc= EC_ImportWavesButtonProc,title="Import Edited"231 232 SetVariable setvar0,pos={208,149},size={160,16},proc= sliceSelectEvent_Proc,title="Display Time Slice"154 Button button7,pos={211,33},size={120,20},proc=V_AdjustEventDataButtonProc,title="Adjust Events" 155 Button button8,pos={653,201},size={120,20},proc=V_CustomBinButtonProc,title="Custom Bins" 156 Button button4,pos={211,63},size={120,20},proc=V_UndoTimeSortButtonProc,title="Undo Time Sort" 157 Button button18,pos={211,90},size={120,20},proc=V_EC_ImportWavesButtonProc,title="Import Edited" 158 159 SetVariable setvar0,pos={208,149},size={160,16},proc=V_sliceSelectEvent_Proc,title="Display Time Slice" 233 160 SetVariable setvar0,fSize=10 234 161 SetVariable setvar0,limits={0,1000,1},value= root:Packages:NIST:VSANS:Event:gEvent_tsdisp … … 238 165 SetVariable setvar2,value= root:Packages:NIST:VSANS:Event:gEvent_t_longest 239 166 240 PopupMenu popup0,pos={389,77},size={119,20},proc= BinTypePopMenuProc,title="Bin Spacing"167 PopupMenu popup0,pos={389,77},size={119,20},proc=V_BinTypePopMenuProc,title="Bin Spacing" 241 168 PopupMenu popup0,fSize=10 242 169 PopupMenu popup0,mode=1,popvalue="Equal",value= #"\"Equal;Fibonacci;Custom;\"" 243 Button button1,pos={389,103},size={120,20},fSize=12,proc= ProcessEventLog_Button,title="Bin Event Data"244 245 Button button10,pos={488,305},size={100,20},proc= SplitFileButtonProc,title="Split Big File"246 Button button14,pos={488,350},size={120,20},proc= Stream_LoadDecim,title="Load Split List"247 Button button19,pos={649,350},size={120,20},proc= Stream_LoadAdjustedList,title="Load Edited List"248 Button button20,pos={680,376},size={90,20},proc= ShowList_ToLoad,title="Show List"249 SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor" 170 Button button1,pos={389,103},size={120,20},fSize=12,proc=V_ProcessEventLog_Button,title="Bin Event Data" 171 172 Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 173 Button button14,pos={488,350},size={120,20},proc=V_Stream_LoadDecim,title="Load Split List",disable=2 174 Button button19,pos={649,350},size={120,20},proc=V_Stream_LoadAdjustedList,title="Load Edited List",disable=2 175 Button button20,pos={680,376},size={90,20},proc=V_ShowList_ToLoad,title="Show List",disable=2 176 SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor",disable=2 250 177 SetVariable setvar3,fSize=10 251 178 SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:VSANS:Event:gDecimation 252 179 253 Button button15_0,pos={488,425},size={110,20},proc= AccumulateSlicesButton,title="Add First Slice"254 Button button16_1,pos={488,450},size={110,20},proc= AccumulateSlicesButton,title="Add Next Slice"255 Button button17_2,pos={620,425},size={110,20},proc= AccumulateSlicesButton,title="Display Total"180 Button button15_0,pos={488,425},size={110,20},proc=V_AccumulateSlicesButton,title="Add First Slice",disable=2 181 Button button16_1,pos={488,450},size={110,20},proc=V_AccumulateSlicesButton,title="Add Next Slice",disable=2 182 Button button17_2,pos={620,425},size={110,20},proc=V_AccumulateSlicesButton,title="Display Total",disable=2 256 183 257 184 CheckBox chkbox1_0,pos={25,34},size={69,14},title="Oscillatory",fSize=10 258 CheckBox chkbox1_0,mode=1,proc= EventModeRadioProc,value=1185 CheckBox chkbox1_0,mode=1,proc=V_EventModeRadioProc,value=0 259 186 CheckBox chkbox1_1,pos={25,59},size={53,14},title="Stream",fSize=10 260 CheckBox chkbox1_1,proc= EventModeRadioProc,value=0,mode=1187 CheckBox chkbox1_1,proc=V_EventModeRadioProc,value=0,mode=1 261 188 CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 262 CheckBox chkbox1_2,proc= EventModeRadioProc,value=0,mode=1189 CheckBox chkbox1_2,proc=V_EventModeRadioProc,value=0,mode=1 263 190 CheckBox chkbox1_3,pos={104,34},size={37,14},title="TOF",fSize=10 264 CheckBox chkbox1_3,proc= EventModeRadioProc,value=0,mode=1191 CheckBox chkbox1_3,proc=V_EventModeRadioProc,value=1,mode=1 265 192 266 193 GroupBox group0_0,pos={5,5},size={174,112},title="(1) Loading Mode",fSize=12,fStyle=1 … … 297 224 //Static Constant MODE_TOF = 3 298 225 // 299 Function EventModeRadioProc(name,value)226 Function V_EventModeRadioProc(name,value) 300 227 String name 301 228 Variable value … … 325 252 End 326 253 327 Function AdjustEventDataButtonProc(ba) : ButtonControl254 Function V_AdjustEventDataButtonProc(ba) : ButtonControl 328 255 STRUCT WMButtonAction &ba 329 256 … … 331 258 case 2: // mouse up 332 259 // click code here 333 Execute " ShowEventCorrectionPanel()"260 Execute "V_ShowEventCorrectionPanel()" 334 261 // 335 262 break … … 341 268 End 342 269 343 Function CustomBinButtonProc(ba) : ButtonControl270 Function V_CustomBinButtonProc(ba) : ButtonControl 344 271 STRUCT WMButtonAction &ba 345 272 … … 347 274 case 2: // mouse up 348 275 // click code here 349 Execute " Show_CustomBinPanel()"276 Execute "V_Show_CustomBinPanel()" 350 277 // 351 278 break … … 358 285 359 286 360 Function ShowEventDataButtonProc(ba) : ButtonControl287 Function V_ShowEventDataButtonProc(ba) : ButtonControl 361 288 STRUCT WMButtonAction &ba 362 289 … … 364 291 case 2: // mouse up 365 292 // click code here 366 Execute " ShowRescaledTimeGraph()"293 Execute "V_ShowRescaledTimeGraph()" 367 294 // 368 DifferentiatedTime()295 V_DifferentiatedTime() 369 296 // 370 297 break … … 376 303 End 377 304 378 Function BinTypePopMenuProc(pa) : PopupMenuControl305 Function V_BinTypePopMenuProc(pa) : PopupMenuControl 379 306 STRUCT WMPopupAction &pa 380 307 … … 384 311 String popStr = pa.popStr 385 312 if(cmpstr(popStr,"Custom")==0) 386 Execute " Show_CustomBinPanel()"313 Execute "V_Show_CustomBinPanel()" 387 314 endif 388 315 break … … 394 321 End 395 322 396 Function ShowBinDetailsButtonProc(ba) : ButtonControl323 Function V_ShowBinDetailsButtonProc(ba) : ButtonControl 397 324 STRUCT WMButtonAction &ba 398 325 … … 400 327 case 2: // mouse up 401 328 // click code here 402 Execute " ShowBinTable()"403 Execute " BinEventBarGraph()"329 Execute "V_ShowBinTable()" 330 Execute "V_BinEventBarGraph()" 404 331 break 405 332 case -1: // control being killed … … 410 337 End 411 338 412 Function UndoTimeSortButtonProc(ba) : ButtonControl339 Function V_UndoTimeSortButtonProc(ba) : ButtonControl 413 340 STRUCT WMButtonAction &ba 414 341 … … 416 343 case 2: // mouse up 417 344 // click code here 418 Execute " UndoTheSorting()"345 Execute "V_UndoTheSorting()" 419 346 break 420 347 case -1: // control being killed … … 425 352 End 426 353 427 Function ExportSlicesButtonProc(ba) : ButtonControl354 Function V_ExportSlicesButtonProc(ba) : ButtonControl 428 355 STRUCT WMButtonAction &ba 429 356 … … 431 358 case 2: // mouse up 432 359 // click code here 433 Execute " ExportSlicesAsVAX()" //will invoke the dialog360 Execute "V_ExportSlicesAsVAX()" //will invoke the dialog 434 361 break 435 362 case -1: // control being killed … … 440 367 End 441 368 442 Function EventModeHelpButtonProc(ba) : ButtonControl369 Function V_EventModeHelpButtonProc(ba) : ButtonControl 443 370 STRUCT WMButtonAction &ba 444 371 … … 456 383 457 384 458 Function EventDone_Proc(ba) : ButtonControl385 Function V_EventDone_Proc(ba) : ButtonControl 459 386 STRUCT WMButtonAction &ba 460 387 … … 470 397 471 398 472 Function ProcessEventLog_Button(ctrlName) : ButtonControl399 Function V_ProcessEventLog_Button(ctrlName) : ButtonControl 473 400 String ctrlName 474 401 … … 476 403 477 404 if(mode == MODE_STREAM) 478 Stream_ProcessEventLog("")405 V_Stream_ProcessEventLog("") 479 406 endif 480 407 481 408 if(mode == MODE_OSCILL) 482 Osc_ProcessEventLog("")409 V_Osc_ProcessEventLog("") 483 410 endif 484 411 485 412 // If TOF mode, process as Oscillatory -- that is, take the times as is 486 413 if(mode == MODE_TOF) 487 Osc_ProcessEventLog("")414 V_Osc_ProcessEventLog("") 488 415 endif 489 416 490 417 // toggle the checkbox for log display to force the display to be correct 491 418 NVAR gLog = root:Packages:NIST:VSANS:Event:gEvent_logint 492 LogIntEvent_Proc("",gLog)419 V_LogIntEvent_Proc("",gLog) 493 420 494 421 return(0) … … 497 424 // for oscillatory mode 498 425 // 499 Function Osc_ProcessEventLog(ctrlName)426 Function V_Osc_ProcessEventLog(ctrlName) 500 427 String ctrlName 501 428 502 Make/O/D/N=( 128,128) root:Packages:NIST:VSANS:Event:binnedData429 Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 503 430 504 431 Wave binnedData = root:Packages:NIST:VSANS:Event:binnedData … … 518 445 Wave rescaledTime = rescaledTime 519 446 Wave timePt = timePt 520 Make/O/D/N=( 128,128) tmpData447 Make/O/D/N=(XBINS,YBINS) tmpData 521 448 Make/O/D/N=(nslices+1) binEndTime,binCount 522 449 Make/O/D/N=(nslices) timeWidth … … 539 466 strswitch(binTypeStr) // string switch 540 467 case "Equal": // execute if case matches expression 541 SetLinearBins(binEndTime,timeWidth,nslices,t_longest)468 V_SetLinearBins(binEndTime,timeWidth,nslices,t_longest) 542 469 break // exit from switch 543 470 case "Fibonacci": // execute if case matches expression 544 SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest)471 V_SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest) 545 472 break 546 473 case "Log": // execute if case matches expression 547 SetLogBins(binEndTime,timeWidth,nslices,t_longest)474 V_SetLogBins(binEndTime,timeWidth,nslices,t_longest) 548 475 break 549 476 case "Custom": // execute if case matches expression … … 552 479 default: // optional default expression executed 553 480 DoAlert 0,"No match for bin type, Equal bins used" 554 SetLinearBins(binEndTime,timeWidth,nslices,t_longest)481 V_SetLinearBins(binEndTime,timeWidth,nslices,t_longest) 555 482 endswitch 556 483 … … 568 495 IndexSort OscSortIndex, yLoc,xLoc,timePt,rescaledTime 569 496 //SetDataFolder root:Packages:NIST:VSANS:Event 570 IndexForHistogram(xLoc,yLoc,binnedData) // index the events AFTER sorting497 V_IndexForHistogram(xLoc,yLoc,binnedData) // index the events AFTER sorting 571 498 //SetDataFolder root: 572 499 Endif … … 601 528 602 529 tmpData=0 603 JointHistogramWithRange(xLoc,yLoc,tmpData,index,p1,p2)530 V_JointHistogramWithRange(xLoc,yLoc,tmpData,index,p1,p2) 604 531 slicedData[][][ii] = tmpData[p][q] 605 532 … … 623 550 // - since I don't know if I've sorted or un-sorted. Osc mode always forces a re-sort and a re-index 624 551 // 625 Function Stream_ProcessEventLog(ctrlName)552 Function V_Stream_ProcessEventLog(ctrlName) 626 553 String ctrlName 627 554 … … 629 556 630 557 631 Make/O/D/N=( 128,128) root:Packages:NIST:VSANS:Event:binnedData558 Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 632 559 633 560 Wave binnedData = root:Packages:NIST:VSANS:Event:binnedData … … 647 574 Wave slicedData = slicedData 648 575 Wave rescaledTime = rescaledTime 649 Make/O/D/N=( 128,128) tmpData576 Make/O/D/N=(XBINS,YBINS) tmpData 650 577 Make/O/D/N=(nslices+1) binEndTime,binCount//,binStartTime 651 578 Make/O/D/N=(nslices) timeWidth … … 667 594 strswitch(binTypeStr) // string switch 668 595 case "Equal": // execute if case matches expression 669 SetLinearBins(binEndTime,timeWidth,nslices,t_longest)596 V_SetLinearBins(binEndTime,timeWidth,nslices,t_longest) 670 597 break // exit from switch 671 598 case "Fibonacci": // execute if case matches expression 672 SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest)599 V_SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest) 673 600 break 674 601 case "Log": // execute if case matches expression 675 SetLogBins(binEndTime,timeWidth,nslices,t_longest)602 V_SetLogBins(binEndTime,timeWidth,nslices,t_longest) 676 603 break 677 604 case "Custom": // execute if case matches expression … … 680 607 default: // optional default expression executed 681 608 DoAlert 0,"No match for bin type, Equal bins used" 682 SetLinearBins(binEndTime,timeWidth,nslices,t_longest)609 V_SetLinearBins(binEndTime,timeWidth,nslices,t_longest) 683 610 endswitch 684 611 … … 688 615 // 689 616 if(yesSortStream == 1) 690 SortTimeData()617 V_SortTimeData() 691 618 endif 692 619 … … 694 621 // if there is a sort of these events, I need to re-index the events for the histogram 695 622 // SetDataFolder root:Packages:NIST:VSANS:Event 696 IndexForHistogram(xLoc,yLoc,binnedData)623 V_IndexForHistogram(xLoc,yLoc,binnedData) 697 624 // SetDataFolder root: 698 625 Wave index = root:Packages:NIST:VSANS:Event:SavedIndex //the index for the histogram … … 723 650 724 651 tmpData=0 725 JointHistogramWithRange(xLoc,yLoc,tmpData,index,p1,p2)652 V_JointHistogramWithRange(xLoc,yLoc,tmpData,index,p1,p2) 726 653 slicedData[][][ii] = tmpData[p][q] 727 654 … … 739 666 740 667 741 Proc UndoTheSorting()742 Osc_UndoSort()668 Proc V_UndoTheSorting() 669 V_Osc_UndoSort() 743 670 End 744 671 … … 748 675 // "as-collected" state 749 676 // 750 Function Osc_UndoSort()677 Function V_Osc_UndoSort() 751 678 752 679 SetDataFolder root:Packages:NIST:VSANS:Event //don't count on the folder remaining here … … 771 698 // you'll never be able to undo the sort 772 699 // 773 Function SortTimeData()700 Function V_SortTimeData() 774 701 775 702 … … 790 717 791 718 792 Function SetLinearBins(binEndTime,timeWidth,nslices,t_longest)719 Function V_SetLinearBins(binEndTime,timeWidth,nslices,t_longest) 793 720 Wave binEndTime,timeWidth 794 721 Variable nslices,t_longest … … 812 739 // either get this to work, or scrap it entirely. it currently isn't on the popup 813 740 // so it can't be accessed 814 Function SetLogBins(binEndTime,timeWidth,nslices,t_longest)741 Function V_SetLogBins(binEndTime,timeWidth,nslices,t_longest) 815 742 Wave binEndTime,timeWidth 816 743 Variable nslices,t_longest … … 835 762 End 836 763 837 Function MakeFibonacciWave(w,num)764 Function V_MakeFibonacciWave(w,num) 838 765 Wave w 839 766 Variable num … … 854 781 end 855 782 856 Function SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest)783 Function V_SetFibonacciBins(binEndTime,timeWidth,nslices,t_longest) 857 784 Wave binEndTime,timeWidth 858 785 Variable nslices,t_longest … … 861 788 Make/O/D/N=(nslices) fibo 862 789 fibo=0 863 MakeFibonacciWave(fibo,nslices)790 V_MakeFibonacciWave(fibo,nslices) 864 791 865 792 // Make/O/D tmpFib={1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946} … … 884 811 // TODO: 885 812 // 886 // ** currently, the "stream" loader uses the first data point as time=0 887 // and rescales everything to that time. "Osc" loading uses the times "as-is" 888 // from the file, trusting the times to be correct. 889 // 890 // Would TISANE or TOF need a different loader? 891 // 892 Function LoadEventLog_Button(ctrlName) : ButtonControl 813 // 814 // 815 Function V_LoadEventLog_Button(ctrlName) : ButtonControl 893 816 String ctrlName 894 817 … … 910 833 return(0) 911 834 endif 912 913 835 914 836 Open/R/D/P=catPathName/F=fileFilters fileref … … 919 841 return(1) 920 842 endif 921 843 844 // TODO - decide if I want (or need) to keep this 922 845 /// Abort if the files are too large 923 Open/R fileref as fileName 924 FStatus fileref 925 Close fileref 926 927 totBytes = V_logEOF/1e6 //in MB 928 if(totBytes > fileTooLarge) 929 sprintf abortStr,"File is %g MB, larger than the limit of %g MB. Split and Decimate.",totBytes,fileTooLarge 930 Abort abortStr 931 endif 932 933 Print totBytes 934 935 // 936 //#if (exists("EventLoadWave")==4) 937 // LoadEvents_XOP() 938 //#else 939 // LoadEvents() 940 //#endif 846 // Open/R fileref as fileName 847 // FStatus fileref 848 // Close fileref 849 // 850 // totBytes = V_logEOF/1e6 //in MB 851 // if(totBytes > fileTooLarge) 852 // sprintf abortStr,"File is %g MB, larger than the limit of %g MB. Split and Decimate.",totBytes,fileTooLarge 853 // Abort abortStr 854 // endif 855 // 856 // Print "TotalBytes = ",totBytes 857 941 858 942 859 SetDataFolder root:Packages:NIST:VSANS:Event: 943 944 945 V_readFakeEventFile() 946 Wave w = V_Events 947 V_decodeFakeEventWave(w) 948 949 KillWaves/Z timePt,xLoc,yLoc 950 Rename tube xLoc 951 Rename location yLoc 952 Rename eventTime timePt 953 954 Redimension/D xLoc,yLoc,timePt 955 860 861 // load in the event file and decode it 862 863 // V_readFakeEventFile(fileName) 864 V_LoadEvents() // this now loads, decodes, and returns location, tube, and timePt 865 SetDataFolder root:Packages:NIST:VSANS:Event: //GBLoadWave in V_LoadEvents sets back to root: 866 867 868 // Now, I have tube, location, and timePt (no units yet) 869 // assign to the proper panels 870 871 s_tic() 872 V_SortAndSplitEvents() 873 874 Printf "File sort and split time (s) = " 875 s_toc() 876 877 // TODO -- currently, nothing is assigned, and nothing is assigned properly - just a 878 // fake assignment to get the TOF to use all of the data 879 // 880 881 // 882 // switch the "active" panel to the selected group (1-4) (5 concatenates them all together) 883 // 884 // copy the set of tubes over to the "active" set that is to be histogrammed 885 // and redimension them to be sure that they are double precision 886 // 887 888 V_SwitchTubeGroup(1) 889 890 // 956 891 //tic() 957 892 Wave timePt=timePt 958 893 Wave xLoc=xLoc 959 894 Wave yLoc=yLoc 960 CleanupTimes(xLoc,yLoc,timePt) //remove zeroes895 V_CleanupTimes(xLoc,yLoc,timePt) //remove zeroes 961 896 //toc() 962 897 963 898 NVAR gResol = root:Packages:NIST:VSANS:Event:gResol //timeStep in clock frequency (Hz) 964 899 ///// 965 900 // now do a little processing of the times based on the type of data 966 901 // 902 903 // TODO: 904 // -- the time scaling is NOT done. it is still in raw ticks. 905 // 967 906 if(mode == MODE_STREAM) // continuous "Stream" mode - start from zero 968 907 Duplicate/O timePt rescaledTime 969 rescaledTime = 1*(timePt-timePt[0]) //convert to seconds and start from zero908 rescaledTime = 1*(timePt-timePt[0]) //convert to nanoseconds and start from zero 970 909 t_longest = waveMax(rescaledTime) //should be the last point 971 910 endif … … 973 912 if(mode == MODE_OSCILL) // oscillatory mode - don't adjust the times, we get periodic t0 to reset t=0 974 913 Duplicate/O timePt rescaledTime 975 rescaledTime *= 1 //convert to seconds and that's all914 rescaledTime *= 1 //convert to nanoseconds and that's all 976 915 t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 977 916 … … 984 923 if(mode == MODE_TOF) // TOF mode - don't adjust the times, we get periodic t0 to reset t=0 985 924 Duplicate/O timePt rescaledTime 986 rescaledTime *= 1 //convert to seconds and that's all925 rescaledTime *= 1 //convert to nanoseconds and that's all 987 926 t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 988 927 … … 994 933 STRUCT WMButtonAction ba 995 934 ba.eventCode = 2 996 ShowEventDataButtonProc(ba)935 V_ShowEventDataButtonProc(ba) 997 936 998 937 return(0) 999 938 End 1000 939 1001 //// for the mode of "one continuous exposure" 1002 //// 1003 //Function Stream_LoadEventLog(ctrlName) 1004 // String ctrlName 1005 // 1006 // Variable fileref 1007 // 1008 // SVAR filename = root:Packages:NIST:VSANS:Event:gEvent_logfile 1009 // NVAR nslices = root:Packages:NIST:VSANS:Event:gEvent_nslices 1010 // NVAR t_longest = root:Packages:NIST:VSANS:Event:gEvent_t_longest 1011 // 1012 // String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 1013 // 1014 // Open/R/D/F=fileFilters fileref 1015 // filename = S_filename 1016 // if(strlen(S_filename) == 0) 1017 // // user cancelled 1018 // DoAlert 0,"No file selected, no file loaded." 1019 // return(1) 1020 // endif 1021 // 1022 //#if (exists("EventLoadWave")==4) 1023 // LoadEvents_XOP() 1024 //#else 1025 // LoadEvents() 1026 //#endif 1027 // 1028 // SetDataFolder root:Packages:NIST:VSANS:Event: 1029 // 1030 ////tic() 1031 // Wave timePt=timePt 1032 // Wave xLoc=xLoc 1033 // Wave yLoc=yLoc 1034 // CleanupTimes(xLoc,yLoc,timePt) //remove zeroes 1035 // 1036 ////toc() 1037 // 1038 // Duplicate/O timePt rescaledTime 1039 // rescaledTime = 1e-7*(timePt-timePt[0]) //convert to seconds and start from zero 1040 // t_longest = waveMax(rescaledTime) //should be the last point 1041 // 1042 // SetDataFolder root: 1043 // 1044 // return(0) 1045 //End 1046 // 1047 //// for the mode "oscillatory" 1048 //// 1049 //Function Osc_LoadEventLog(ctrlName) 1050 // String ctrlName 1051 // 1052 // Variable fileref 1053 // 1054 // SVAR filename = root:Packages:NIST:VSANS:Event:gEvent_logfile 1055 // NVAR nslices = root:Packages:NIST:VSANS:Event:gEvent_nslices 1056 // NVAR t_longest = root:Packages:NIST:VSANS:Event:gEvent_t_longest 1057 // 1058 // String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 1059 // 1060 // Open/R/D/F=fileFilters fileref 1061 // filename = S_filename 1062 // if(strlen(S_filename) == 0) 1063 // // user cancelled 1064 // DoAlert 0,"No file selected, no file loaded." 1065 // return(1) 1066 // endif 1067 // 1068 //#if (exists("EventLoadWave")==4) 1069 // LoadEvents_XOP() 1070 //#else 1071 // LoadEvents() 1072 //#endif 1073 // 1074 // SetDataFolder root:Packages:NIST:VSANS:Event: 1075 // 1076 // Wave timePt=timePt 1077 // Wave xLoc=xLoc 1078 // Wave yLoc=yLoc 1079 // CleanupTimes(xLoc,yLoc,timePt) //remove zeroes 1080 // 1081 // Duplicate/O timePt rescaledTime 1082 // rescaledTime *= 1e-7 //convert to seconds and that's all 1083 // t_longest = waveMax(rescaledTime) //if oscillatory, won't be the last point, so get it this way 1084 // 1085 // KillWaves/Z OscSortIndex //to make sure that there is no old index hanging around 1086 // 1087 // SetDataFolder root: 1088 // 1089 // return(0) 1090 //End 940 1091 941 1092 942 … … 1094 944 // -- MUCH faster to count the number of lines to remove, then delete (N) 1095 945 // rather then delete them one-by-one in the do-loop 1096 Function CleanupTimes(xLoc,yLoc,timePt)946 Function V_CleanupTimes(xLoc,yLoc,timePt) 1097 947 Wave xLoc,yLoc,timePt 1098 948 … … 1116 966 End 1117 967 1118 Function LogIntEvent_Proc(ctrlName,checked) : CheckBoxControl968 Function V_LogIntEvent_Proc(ctrlName,checked) : CheckBoxControl 1119 969 String ctrlName 1120 970 Variable checked … … 1135 985 NVAR selectedslice = root:Packages:NIST:VSANS:Event:gEvent_tsdisp 1136 986 1137 sliceSelectEvent_Proc("", selectedslice, "", "")987 V_sliceSelectEvent_Proc("", selectedslice, "", "") 1138 988 1139 989 SetDataFolder root: … … 1152 1002 // rather than creating a duplicate wave of log(data) 1153 1003 // 1154 Function sliceSelectEvent_Proc(ctrlName, varNum, varStr, varName) : SetVariableControl1004 Function V_sliceSelectEvent_Proc(ctrlName, varNum, varStr, varName) : SetVariableControl 1155 1005 String ctrlName 1156 1006 Variable varNum … … 1173 1023 End 1174 1024 1175 Function DifferentiatedTime()1025 Function V_DifferentiatedTime() 1176 1026 1177 1027 Wave rescaledTime = root:Packages:NIST:VSANS:Event:rescaledTime … … 1181 1031 Differentiate rescaledTime/D=rescaledTime_DIF 1182 1032 // Display rescaledTime,rescaledTime_DIF 1183 DoWindow/F Differentiated_Time1033 DoWindow/F V_Differentiated_Time 1184 1034 if(V_flag == 0) 1185 Display/N= Differentiated_Time/K=1 rescaledTime_DIF1035 Display/N=V_Differentiated_Time/K=1 rescaledTime_DIF 1186 1036 Legend 1187 1037 Modifygraph gaps=0 … … 1200 1050 // for the bit shifts, see the decimal-binary conversion 1201 1051 // http://www.binaryconvert.com/convert_unsigned_int.html 1052 // and for 64-bit values: 1053 // http://calc.penjee.com 1202 1054 // 1203 1055 // K0 = 536870912 … … 1206 1058 // Print (K0 & 0x20000000)/536870912 //bit 29 only, shift by 2^29 1207 1059 // 1208 // This is duplicated by the XOP, but the Igor code allows quick access to print out 1209 // all of the gorey details of the events and every little bit of them. the print 1210 // statements and flags are kept for this reason, so the code is a bit messy. 1211 // 1212 Function LoadEvents() 1213 1214 NVAR time_msw = root:Packages:NIST:VSANS:Event:gEvent_time_msw 1215 NVAR time_lsw = root:Packages:NIST:VSANS:Event:gEvent_time_lsw 1060 // 1061 // 1062 // This function loads the events, and decodes them. 1063 // Assigning them to detector panels is a separate function 1064 // 1065 // 1066 // 1067 Function V_LoadEvents() 1068 1216 1069 NVAR t_longest = root:Packages:NIST:VSANS:Event:gEvent_t_longest 1217 1070 … … 1219 1072 SVAR dispStr = root:Packages:NIST:VSANS:Event:gEventDisplayString 1220 1073 1221 1222 //// Variable decFac = 10 //decimation factor1223 //// Variable jj,keep1224 1225 1074 SetDataFolder root:Packages:NIST:VSANS:Event 1226 1075 1227 Variable fileref1076 Variable refnum 1228 1077 String buffer 1229 1078 String fileStr,tmpStr 1230 Variable dataval,timeval,type,numLines,verbose,verbose3 1231 Variable xval,yval,rollBit,nRoll,roll_time,bit29,bit28,bit27 1232 Variable ii,flaggedEvent,rolloverHappened,numBad=0,tmpPP=0,tmpT0=0 1233 Variable Xmax, yMax 1234 1235 xMax = 127 // number the detector from 0->127 1236 yMax = 127 1237 1238 verbose3 = 0 //prints out the rollover events (type==3) 1239 verbose = 0 1240 numLines = 0 1241 1242 1243 // what I really need is the number of XY events 1244 Variable numXYevents,num1,num2,num3,num0,totBytes,numPP,numT0,numDL,numFF,numZero 1245 Variable numRemoved 1079 Variable verbose 1080 Variable xval,yval 1081 Variable numXYevents,totBytes 1082 1083 // to read a VSANS event file: 1084 // 1085 // - get the file name 1086 // - read the header (all of it, since I need parts of it) (maybe read as a struct? but I don't know the size!) 1087 // - move to EOF and close 1088 // 1089 // - Use GBLoadWave to read the 64-bit events in 1090 1091 1092 /// globals to report the header back for use or status 1093 SVAR gVSANSStr = root:Packages:NIST:VSANS:Event:gVsansStr 1094 NVAR gRevision = root:Packages:NIST:VSANS:Event:gRevision 1095 NVAR gOffset = root:Packages:NIST:VSANS:Event:gOffset // = 22 bytes if no disabled tubes 1096 NVAR gTime1 = root:Packages:NIST:VSANS:Event:gTime1 1097 NVAR gTime2 = root:Packages:NIST:VSANS:Event:gTime2 1098 NVAR gTime3 = root:Packages:NIST:VSANS:Event:gTime3 1099 NVAR gTime4 = root:Packages:NIST:VSANS:Event:gTime4 // these 4 time pieces are supposed to be 8 bytes total 1100 NVAR gTime5 = root:Packages:NIST:VSANS:Event:gTime5 // these 5 time pieces are supposed to be 10 bytes total 1101 SVAR gDetStr = root:Packages:NIST:VSANS:Event:gDetStr 1102 NVAR gVolt = root:Packages:NIST:VSANS:Event:gVolt 1103 NVAR gResol = root:Packages:NIST:VSANS:Event:gResol //time resolution in nanoseconds 1104 ///// 1105 1106 gVSANSStr = PadString(gVSANSStr,5,0x20) //pad to 5 bytes 1107 gDetStr = PadString(gDetStr,1,0x20) //pad to 1 byte 1108 1246 1109 numXYevents = 0 1247 num0 = 0 1248 num1 = 0 1249 num2 = 0 1250 num3 = 0 1251 numPP = 0 1252 numT0 = 0 1253 numDL = 0 1254 numFF = 0 1255 numZero = 0 1256 numRemoved = 0 1257 1258 //tic() 1259 Open/R fileref as filepathstr 1260 FStatus fileref 1261 Close fileref 1110 1111 1112 Open/R refnum as filepathstr 1113 1114 s_tic() 1115 1116 FBinRead refnum, gVSANSStr 1117 FBinRead/F=2/U refnum, gRevision 1118 FBinRead/F=2/U refnum, gOffset 1119 FBinRead/F=2/U refnum, gTime1 1120 FBinRead/F=2/U refnum, gTime2 1121 FBinRead/F=2/U refnum, gTime3 1122 FBinRead/F=2/U refnum, gTime4 1123 FBinRead/F=2/U refnum, gTime5 1124 FBinRead refnum, gDetStr 1125 FBinRead/F=2/U refnum, gVolt 1126 FBinRead/F=3/U refnum, gResol 1127 1128 FStatus refnum 1129 FSetPos refnum, V_logEOF 1130 1131 Close refnum 1132 1133 // number of data bytes 1134 numXYevents = (V_logEOF-gOffset)/8 1135 Print "Number of data values = ",numXYevents 1136 1137 GBLoadWave/B/T={192,192}/W=1/S=(gOffset) filepathstr 1138 1139 Duplicate/O $(StringFromList(0,S_waveNames)) V_Events 1140 KillWaves/Z $(StringFromList(0,S_waveNames)) 1141 1142 Printf "Time to read file (s) = " 1143 s_toc() 1144 1262 1145 1263 1146 totBytes = V_logEOF 1264 1147 Print "total bytes = ", totBytes 1265 1148 1266 //toc() 1267 // 1268 1269 1270 // do a "pre-scan to get some of the counts, so that I can allocate space. This does 1271 // double the read time, but is still faster than adding points to waves as the file is read 1272 // 1273 1274 s_tic()1275 1276 Open/R fileref as filepathstr1277 do1278 do1279 FReadLine fileref, buffer //skip the "blank" lines that have one character1280 while(strlen(buffer) == 1)1281 1282 if (strlen(buffer) == 0)1283 break1284 endif1149 1150 // V_Events is the uint64 wave that was read in 1151 // 1152 ////// Now decode the events 1153 1154 1155 s_tic() 1156 WAVE V_Events = V_Events 1157 uint64 val,b1,b2,btime 1158 1159 1160 Variable num,ii 1161 num=numpnts(V_Events) 1162 1163 Make/O/L/U/N=(num) eventTime //64 bit unsigned 1164 Make/O/U/B/N=(num) tube,location //8 bit unsigned 1165 1166 for(ii=0;ii<num;ii+=1) 1167 val = V_Events[ii] 1285 1168 1286 sscanf buffer,"%x",dataval 1169 // b1 = (val >> 56 ) & 0xFF // = 255, last two bytes, after shifting 1170 // b2 = (val >> 48 ) & 0xFF 1171 // btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 1172 1173 b1 = val & 0xFF 1174 b2 = (val >> 8) & 0xFF 1175 btime = (val >> 16) 1176 1177 1178 tube[ii] = b1 1179 location[ii] = b2 1180 eventTime[ii] = btime 1287 1181 1288 // two most sig bits (31-30) 1289 type = (dataval & 0xC0000000)/1073741824 //right shift by 2^30 1290 1291 if(type == 0) 1292 num0 += 1 1293 numXYevents += 1 1294 endif 1295 if(type == 2) 1296 num2 += 1 1297 numXYevents += 1 1298 endif 1299 if(type == 1) 1300 num1 += 1 1301 endif 1302 if(type == 3) 1303 num3 += 1 1304 endif 1305 1306 bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1307 1308 if(type==0 || type==2) 1309 numPP += round(bit29) 1310 endif 1311 1312 if(type==1 || type==3) 1313 numT0 += round(bit29) 1314 endif 1315 1316 if(dataval == 0) 1317 numZero += 1 1318 endif 1319 1320 while(1) 1321 Close fileref 1322 // done counting the number of XY events 1323 printf("Igor pre-scan done in ") 1324 s_toc() 1325 1326 1327 Print "(Igor) numT0 = ",numT0 1328 Print "num0 = ",num0 1329 Print "num1 = ",num1 1330 Print "num2 = ",num2 1331 Print "num3 = ",num3 1332 1333 // 1334 // 1335 // Printf "numXYevents = %d\r",numXYevents 1336 // Printf "XY = num0 = %d\r",num0 1337 // Printf "XY time = num2 = %d\r",num2 1338 // Printf "time MSW = num1 = %d\r",num1 1339 // Printf "Rollover = num3 = %d\r",num3 1340 // Printf "num0 + num2 = %d\r",num0+num2 1341 1342 // dispStr will be displayed on the panel 1182 endfor 1183 1184 Printf "File decode time (s) = " 1185 s_toc() 1186 1187 // KillWaves/Z timePt,xLoc,yLoc 1188 // Rename tube xLoc 1189 // Rename location yLoc 1190 // Rename eventTime timePt 1191 // 1192 // Redimension/D xLoc,yLoc,timePt 1193 1194 1195 // TODO 1196 // add more to the status display of the file load/decode 1197 // 1198 // dispStr will be displayed on the panel 1343 1199 fileStr = ParseFilePath(0, filepathstr, ":", 1, 0) 1344 1200 … … 1347 1203 sprintf tmpStr,"numXYevents = %d\r",numXYevents 1348 1204 dispStr += tmpStr 1349 sprintf tmpStr,"PP = %d : ",numPP 1350 dispStr += tmpStr 1351 sprintf tmpStr,"ZeroData = %d\r",numZero 1352 dispStr += tmpStr 1353 sprintf tmpStr,"Rollover = %d",num3 1354 dispStr += tmpStr 1355 1356 // /I/U is unsigned 32-bit integer (for the time) 1357 // /B/U is unsigned 8-bit integer (max val=255) for the x and y values 1358 1359 Make/O/U/N=(numXYevents) xLoc,yLoc 1360 Make/O/D/N=(numXYevents) timePt 1361 //// Make/O/U/N=(numXYevents/decFac) xLoc,yLoc 1362 //// Make/O/D/N=(numXYevents/decFac) timePt 1363 // Make/O/U/N=(totBytes/4) xLoc,yLoc //too large, trim when done (bad idea) 1364 // Make/O/D/N=(totBytes/4) timePt 1365 Make/O/D/N=1000 badTimePt,badEventNum,PPTime,PPEventNum,T0Time,T0EventNum 1366 badTimePt=0 1367 badEventNum=0 1368 PPTime=0 1369 PPEventNum=0 1370 T0Time=0 1371 T0EventNum=0 1372 xLoc=0 1373 yLoc=0 1374 timePt=0 1375 1376 nRoll = 0 //number of rollover events 1377 roll_time = 2^26 //units of 10-7 sec 1378 1379 NVAR removeBadEvents = root:Packages:NIST:VSANS:Event:gRemoveBadEvents 1380 1381 time_msw=0 1382 1383 s_tic() 1384 1385 ii = 0 //indexes the points in xLoc,yLoc,timePt 1386 //// keep = decFac //keep the first point 1387 1388 1389 Open/R fileref as filepathstr 1390 1391 // remove events at the beginning up to a type==2 so that the msw and lsw times are reset properly 1392 if(RemoveBadEvents == 1) 1393 do 1394 do 1395 FReadLine fileref, buffer //skip the "blank" lines that have one character 1396 while(strlen(buffer) == 1) 1397 1398 if (strlen(buffer) == 0) 1399 break 1400 endif 1401 1402 sscanf buffer,"%x",dataval 1403 // two most sig bits (31-30) 1404 type = (dataval & 0xC0000000)/1073741824 //right shift by 2^30 1405 1406 if(type == 2) 1407 // this is the first event with a proper time value, so process the XY-time event as ususal 1408 // and then break to drop to the main loop, where the next event == type 1 1409 1410 xval = xMax - (dataval & 255) //last 8 bits (7-0) 1411 yval = (dataval & 65280)/256 //bits 15-8, right shift by 2^8 1412 1413 time_lsw = (dataval & 536805376)/65536 //13 bits, 28-16, right shift by 2^16 1414 1415 if(verbose) 1416 // printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 1417 printf "%u : %u : %u : %u\r",dataval,timeval,xval,yval 1418 endif 1419 1420 // this is the first point, be sure that ii = 0, and always keep this point 1421 //// if(keep==decFac) 1422 ii = 0 1423 xLoc[ii] = xval 1424 yLoc[ii] = yval 1425 //// keep = 0 1426 //// endif 1427 Print "At beginning of file, numBad = ",numBad 1428 break // the next do loop processes the bulk of the file (** the next event == type 1 = MIR) 1429 else 1430 numBad += 1 1431 numRemoved += 1 1432 endif 1433 1434 //ii+=1 don't increment the counter 1435 while(1) 1436 endif 1437 1438 // now read the main portion of the file. 1439 //// // keep is = 0 if bad points were removed, or is decFac is I need to keep the first point 1440 do 1441 do 1442 FReadLine fileref, buffer //skip the "blank" lines that have one character 1443 while(strlen(buffer) == 1) 1444 1445 if (strlen(buffer) == 0) // this marks the end of the file and is our only way out 1446 break 1447 endif 1448 1449 sscanf buffer,"%x",dataval 1450 1451 1452 // type = (dataval & ~(2^32 - 2^30 -1))/2^30 1453 1454 // two most sig bits (31-30) 1455 type = (dataval & 0xC0000000)/1073741824 //right shift by 2^30 1456 1457 // 1458 // The defintions of the event types 1459 // 1460 //Constant ATXY = 0 1461 //Constant ATXYM = 2 1462 //Constant ATMIR = 1 1463 //Constant ATMAR = 3 1464 // 1465 1466 if(verbose > 0) 1467 verbose -= 1 1468 endif 1469 // 1470 switch(type) 1471 case ATXY: // 0 1472 if(verbose) 1473 printf "XY : " 1474 endif 1475 1476 // if the datavalue is == 0, just skip it now (it can only be interpreted as type 0, obviously) 1477 if(dataval == 0 && RemoveBadEvents == 1) 1478 numRemoved += 1 1479 //Print "zero at ii= ",ii 1480 break //don't increment ii 1481 endif 1482 1483 // if it's a pileup event, skip it now (this can be either type 0 or 2) 1484 bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1485 if(bit29 == 1 && RemoveBadEvents == 1) 1486 PPTime[tmpPP] = timeval 1487 PPEventNum[tmpPP] = ii 1488 tmpPP += 1 1489 numRemoved += 1 1490 break //don't increment ii 1491 endif 1492 1493 // xval = ~(dataval & ~(2^32 - 2^8)) & 127 1494 // yval = ((dataval & ~(2^32 - 2^16 ))/2^8) & 127 1495 // time_lsw = (dataval & ~(2^32 - 2^29))/2^16 1496 1497 xval = xMax - (dataval & 255) //last 8 bits (7-0) 1498 yval = (dataval & 65280)/256 //bits 15-8, right shift by 2^8 1499 time_lsw = (dataval & 536805376)/65536 //13 bits, 28-16, right shift by 2^16 1500 1501 timeval = trunc( nRoll*roll_time + (time_msw * (8192)) + time_lsw ) //left shift msw by 2^13, then add in lsw, as an integer 1502 if (timeval > t_longest) 1503 t_longest = timeval 1504 endif 1505 1506 1507 // catch the "bad" events: 1508 // if an XY event follows a rollover, time_msw is 0 by definition, but does not immediately get 1509 // re-evalulated here. Throw out only the immediately following points where msw is still 8191 1510 if(rolloverHappened && RemoveBadEvents == 1) 1511 // maybe a bad event 1512 if(time_msw == 8191) 1513 badTimePt[numBad] = timeVal 1514 badEventNum[numBad] = ii 1515 numBad +=1 1516 numRemoved += 1 1517 else 1518 // time_msw has been reset, points are good now, so keep this one 1519 //// if(keep==decFac) 1520 xLoc[ii] = xval 1521 yLoc[ii] = yval 1522 timePt[ii] = timeval 1523 1524 // if(xval == 127 && yval == 0) 1525 // // check bit 29 1526 // bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1527 // Print "XY=127,0 : bit29 = ",bit29 1528 // endif 1529 1530 ii+=1 1531 rolloverHappened = 0 1532 //// keep = 0 1533 //// else 1534 //// keep += 1 1535 //// endif 1536 endif 1537 else 1538 // normal processing of good point, keep it 1539 //// if(keep==decFac) 1540 xLoc[ii] = xval 1541 yLoc[ii] = yval 1542 timePt[ii] = timeval 1543 1544 // if(xval == 127 && yval == 0) 1545 // // check bit 29 1546 // bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1547 // Printf "XY=127,0 : bit29 = %u : d=%u\r",bit29,dataval 1548 // endif 1549 ii+=1 1550 //// keep = 0 1551 //// else 1552 //// keep += 1 1553 //// endif 1554 endif 1555 1556 1557 if(verbose) 1558 // printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 1559 printf "d=%u : t=%u : msw=%u : lsw=%u : %u : %u \r",dataval,timeval,time_msw,time_lsw,xval,yval 1560 endif 1561 1562 // verbose = 0 1563 break 1564 case ATXYM: // 2 1565 if(verbose) 1566 printf "XYM : " 1567 endif 1568 1569 // if it's a pileup event, skip it now (this can be either type 0 or 2) 1570 // - but can I do this if this is an XY-time event? This will lead to a wrong time, and a time 1571 // assigned to an XY (0,0)... 1572 // bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1573 // if(bit29 == 1 && RemoveBadEvents == 1) 1574 // Print "*****Bit 29 (PP) event set for Type==2, but not handled, ii = ",ii 1575 //// break //don't increment ii 1576 // endif 1577 1578 // xval = ~(dataval & ~(2^32 - 2^8)) & 127 1579 // yval = ((dataval & ~(2^32 - 2^16 ))/2^8) & 127 1580 // time_lsw = (dataval & ~(2^32 - 2^29 ))/2^16 //this method gives a FP result!! likely since the "^" operation gives FP result... 1581 1582 xval = xMax - (dataval & 255) //last 8 bits (7-0) 1583 yval = (dataval & 65280)/256 //bits 15-8, right shift by 2^8 1584 1585 time_lsw = (dataval & 536805376)/65536 //13 bits, 28-16, right shift by 2^16 (result is integer) 1586 1587 if(verbose) 1588 // printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 1589 printf "%u : %u : %u : %u\r",dataval,timeval,xval,yval 1590 endif 1591 1592 //// if(keep==decFac) //don't reset keep yet, do this only when ii increments 1593 xLoc[ii] = xval 1594 yLoc[ii] = yval 1595 //// endif 1596 1597 // don't fill in the time yet, or increment the index ii 1598 // the next event MUST be ATMIR with the MSW time bits 1599 // 1600 // verbose = 0 1601 break 1602 case ATMIR: // 1 1603 if(verbose) 1604 printf "MIR : " 1605 endif 1606 1607 time_msw = (dataval & 536805376)/65536 //13 bits, 28-16, right shift by 2^16 1608 timeval = trunc( nRoll*roll_time + (time_msw * (8192)) + time_lsw ) 1609 if (timeval > t_longest) 1610 t_longest = timeval 1611 endif 1612 if(verbose) 1613 // printf "%u : %u : %u : %u\r",dataval,time_lsw,time_msw,timeval 1614 printf "d=%u : t=%u : msw=%u : lsw=%u : tlong=%u\r",dataval,timeval,time_msw,time_lsw,t_longest 1615 endif 1616 1617 // the XY position was in the previous event ATXYM 1618 //// if(keep == decFac) 1619 timePt[ii] = timeval 1620 //// endif 1621 1622 bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1623 if(bit29 != 0) // bit 29 set is a T0 event 1624 //Printf "bit29 = 1 at ii = %d : type = %d\r",ii,type 1625 T0Time[tmpT0] = timeval 1626 T0EventNum[tmpT0] = ii 1627 tmpT0 += 1 1628 // reset nRoll = 0 for calcluating the time 1629 nRoll = 0 1630 endif 1631 1632 //// if(keep == decFac) 1633 ii+=1 1634 //// keep = 0 1635 //// endif 1636 // verbose = 0 1637 break 1638 case ATMAR: // 3 1639 if(verbose3) 1640 // verbose = 15 1641 // verbose = 2 1642 printf "MAR : " 1643 endif 1644 1645 // do something with the rollover event? 1646 1647 // check bit 29 1648 bit29 = (dataval & 0x20000000)/536870912 //bit 29 only , shift by 2^29 1649 nRoll += 1 1650 // not doing anything with these bits yet 1651 bit28 = (dataval & 0x10000000)/268435456 //bit 28 only, shift by 2^28 1652 bit27 = (dataval & 0x08000000)/134217728 //bit 27 only, shift by 2^27 1653 1654 if(verbose3) 1655 printf "d=%u : b29=%u : b28=%u : b27=%u : #Roll=%u \r",dataval,bit29, bit28, bit27,nRoll 1656 endif 1657 1658 if(bit29 != 0) // bit 29 set is a T0 event 1659 //Printf "bit29 = 1 at ii = %d : type = %d\r",ii,type 1660 T0Time[tmpT0] = timeval 1661 T0EventNum[tmpT0] = ii 1662 tmpT0 += 1 1663 // reset nRoll = 0 for calcluating the time 1664 nRoll = 0 1665 endif 1666 1667 rolloverHappened = 1 1668 1669 break 1670 endswitch 1671 1672 // if(ii<18) 1673 // printf "TYPE=%d : ii=%d : d=%u : t=%u : msw=%u : lsw=%u : %u : %u \r",type,ii,dataval,timeval,time_msw,time_lsw,xval,yval 1674 // endif 1675 1676 while(1) 1677 1678 Close fileref 1679 1680 printf("Igor full file read done in ") 1681 s_toc() 1682 1683 Print "Events removed (Igor) = ",numRemoved 1684 1685 sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 1686 dispStr += tmpStr 1687 sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 1688 dispStr += tmpStr 1205 // sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 1206 // dispStr += tmpStr 1207 // sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 1208 // dispStr += tmpStr 1209 1689 1210 SetDataFolder root: 1690 1211 … … 1693 1214 End 1694 1215 1216 //////////////// 1217 //// 1218 //// This calls the XOP, as an operation to load the events 1219 //// 1220 //// -- it's about 35x faster than the Igor code, so I guess that's OK. 1221 //// 1222 //// conditional compile the whole inner workings in case XOP is not present 1223 //Function LoadEvents_XOP() 1224 //#if (exists("EventLoadWave")==4) 1225 // 1226 //// NVAR time_msw = root:Packages:NIST:VSANS:Event:gEvent_time_msw 1227 //// NVAR time_lsw = root:Packages:NIST:VSANS:Event:gEvent_time_lsw 1228 // NVAR t_longest = root:Packages:NIST:VSANS:Event:gEvent_t_longest 1229 // 1230 // SVAR filepathstr = root:Packages:NIST:VSANS:Event:gEvent_logfile 1231 // SVAR dispStr = root:Packages:NIST:VSANS:Event:gEventDisplayString 1232 // 1233 // SetDataFolder root:Packages:NIST:VSANS:Event 1234 // 1235 // 1236 // 1237 // Variable fileref 1238 // String buffer 1239 // String fileStr,tmpStr 1240 // Variable dataval,timeval,type,numLines,verbose,verbose3 1241 // Variable xval,yval,rollBit,nRoll,roll_time,bit29,bit28,bit27 1242 // Variable ii,flaggedEvent,rolloverHappened,numBad=0,tmpPP=0,tmpT0=0 1243 // Variable Xmax, yMax 1244 // 1245 // xMax = 127 // number the detector from 0->127 1246 // yMax = 127 1247 // 1248 // numLines = 0 1249 // 1250 // //Have to declare local variables for Loadwave so that this compiles without XOP. 1251 // String S_waveNames 1252 // // and those for the XOP 1253 // Variable V_nXYevents,V_num1,V_num2,V_num3,V_num0,V_totBytes,V_numPP,V_numT0,V_numDL,V_numFF,V_numZero 1254 // Variable V_numBad,V_numRemoved 1255 // 1256 // // what I really need is the number of XY events 1257 // Variable numXYevents,num1,num2,num3,num0,totBytes,numPP,numT0,numDL,numFF,numZero 1258 // Variable numRemoved 1259 // numXYevents = 0 1260 // num0 = 0 1261 // num1 = 0 1262 // num2 = 0 1263 // num3 = 0 1264 // numPP = 0 1265 // numT0 = 0 1266 // numDL = 0 1267 // numFF = 0 1268 // numZero = 0 1269 // numRemoved = 0 1270 // 1271 //// get the total number of bytes in the file 1272 // Open/R fileref as filepathstr 1273 // FStatus fileref 1274 // Close fileref 1275 // 1276 // totBytes = V_logEOF 1277 // Print "total bytes = ", totBytes 1278 // 1279 //// 1280 //// Print "scan only" 1281 //// tic() 1282 //// EventLoadWave/R/N=EventWave/W filepathstr 1283 //// toc() 1284 // 1285 ////// 1286 //// 1287 //// use the XOP operation to load in the data 1288 //// -- this does everything - the pre-scan and creating the waves 1289 //// 1290 //// need to zero the waves before loading, just in case 1291 //// 1292 // 1293 // NVAR removeBadEvents = root:Packages:NIST:VSANS:Event:gRemoveBadEvents 1294 // 1295 //s_tic() 1296 // 1297 //// Wave/Z wave0=wave0 1298 //// Wave/Z wave1=wave1 1299 //// Wave/Z wave2=wave2 1300 //// 1301 //// if(WaveExists(wave0)) 1302 //// MultiThread wave0=0 1303 //// endif 1304 //// if(WaveExists(wave1)) 1305 //// MultiThread wave1=0 1306 //// endif 1307 //// if(WaveExists(wave2)) 1308 //// MultiThread wave2=0 1309 //// endif 1310 // 1311 // if(removeBadEvents) 1312 // EventLoadWave/R/N=EventWave filepathstr 1313 // else 1314 // EventLoadWave/N=EventWave filepathstr 1315 // endif 1316 // 1317 // 1318 // Print "XOP files loaded = ",S_waveNames 1319 // 1320 ////// -- copy the waves over to xLoc,yLoc,timePt 1321 // Wave/Z EventWave0=EventWave0 1322 // Wave/Z EventWave1=EventWave1 1323 // Wave/Z EventWave2=EventWave2 1324 // 1325 // 1326 // Duplicate/O EventWave0,xLoc 1327 // KillWaves/Z EventWave0 1328 // 1329 // Duplicate/O EventWave1,yLoc 1330 // KillWaves/Z EventWave1 1331 // 1332 // Duplicate/O EventWave2,timePt 1333 // KillWaves/Z EventWave2 1334 // 1335 //// could do this, but rescaled time will neeed to be converted to SP (or DP) 1336 //// and Igor loader was written with Make generating SP/DP waves 1337 // // /I/U is unsigned 32-bit integer (for the time) 1338 // // /B/U is unsigned 8-bit integer (max val=255) for the x and y values 1339 // 1340 //// Redimension/B/U xLoc,yLoc 1341 //// Redimension/I/U timePt 1342 // 1343 // // access the variables from the XOP 1344 // numT0 = V_numT0 1345 // numPP = V_numPP 1346 // num0 = V_num0 1347 // num1 = V_num1 1348 // num2 = V_num2 1349 // num3 = V_num3 1350 // numXYevents = V_nXYevents 1351 // numZero = V_numZero 1352 // numBad = V_numBad 1353 // numRemoved = V_numRemoved 1354 // 1355 // Print "(XOP) numT0 = ",numT0 1356 // Print "num0 = ",num0 1357 // Print "num1 = ",num1 1358 // Print "num2 = ",num2 1359 // Print "num3 = ",num3 1360 // 1361 // 1362 //// dispStr will be displayed on the panel 1363 // fileStr = ParseFilePath(0, filepathstr, ":", 1, 0) 1364 // 1365 // sprintf tmpStr, "%s: %d total bytes\r",fileStr,totBytes 1366 // dispStr = tmpStr 1367 // sprintf tmpStr,"numXYevents = %d\r",numXYevents 1368 // dispStr += tmpStr 1369 // sprintf tmpStr,"PP = %d : ",numPP 1370 // dispStr += tmpStr 1371 // sprintf tmpStr,"ZeroData = %d\r",numZero 1372 // dispStr += tmpStr 1373 // sprintf tmpStr,"Rollover = %d",num3 1374 // dispStr += tmpStr 1375 // 1376 // s_toc() 1377 // 1378 // Print "Events removed (XOP) = ",numRemoved 1379 // 1380 // sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 1381 // dispStr += tmpStr 1382 // sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 1383 // dispStr += tmpStr 1384 // 1385 // 1386 //// simply to compile a table of # XY vs # bytes 1387 //// Wave/Z nxy = root:numberXY 1388 //// Wave/Z nBytes = root:numberBytes 1389 //// if(WaveExists(nxy) && WaveExists(nBytes)) 1390 //// InsertPoints 0, 1, nxy,nBytes 1391 //// nxy[0] = numXYevents 1392 //// nBytes[0] = totBytes 1393 //// endif 1394 // 1395 // SetDataFolder root: 1396 // 1397 //#endif 1398 // return(0) 1399 // 1400 //End 1401 1695 1402 ////////////// 1696 // 1697 // This calls the XOP, as an operation to load the events 1698 // 1699 // -- it's about 35x faster than the Igor code, so I guess that's OK. 1700 // 1701 // conditional compile the whole inner workings in case XOP is not present 1702 Function LoadEvents_XOP() 1703 #if (exists("EventLoadWave")==4) 1704 1705 // NVAR time_msw = root:Packages:NIST:VSANS:Event:gEvent_time_msw 1706 // NVAR time_lsw = root:Packages:NIST:VSANS:Event:gEvent_time_lsw 1707 NVAR t_longest = root:Packages:NIST:VSANS:Event:gEvent_t_longest 1708 1709 SVAR filepathstr = root:Packages:NIST:VSANS:Event:gEvent_logfile 1710 SVAR dispStr = root:Packages:NIST:VSANS:Event:gEventDisplayString 1711 1712 SetDataFolder root:Packages:NIST:VSANS:Event 1713 1714 1715 1716 Variable fileref 1717 String buffer 1718 String fileStr,tmpStr 1719 Variable dataval,timeval,type,numLines,verbose,verbose3 1720 Variable xval,yval,rollBit,nRoll,roll_time,bit29,bit28,bit27 1721 Variable ii,flaggedEvent,rolloverHappened,numBad=0,tmpPP=0,tmpT0=0 1722 Variable Xmax, yMax 1723 1724 xMax = 127 // number the detector from 0->127 1725 yMax = 127 1726 1727 numLines = 0 1728 1729 //Have to declare local variables for Loadwave so that this compiles without XOP. 1730 String S_waveNames 1731 // and those for the XOP 1732 Variable V_nXYevents,V_num1,V_num2,V_num3,V_num0,V_totBytes,V_numPP,V_numT0,V_numDL,V_numFF,V_numZero 1733 Variable V_numBad,V_numRemoved 1734 1735 // what I really need is the number of XY events 1736 Variable numXYevents,num1,num2,num3,num0,totBytes,numPP,numT0,numDL,numFF,numZero 1737 Variable numRemoved 1738 numXYevents = 0 1739 num0 = 0 1740 num1 = 0 1741 num2 = 0 1742 num3 = 0 1743 numPP = 0 1744 numT0 = 0 1745 numDL = 0 1746 numFF = 0 1747 numZero = 0 1748 numRemoved = 0 1749 1750 // get the total number of bytes in the file 1751 Open/R fileref as filepathstr 1752 FStatus fileref 1753 Close fileref 1754 1755 totBytes = V_logEOF 1756 Print "total bytes = ", totBytes 1757 1758 // 1759 // Print "scan only" 1760 // tic() 1761 // EventLoadWave/R/N=EventWave/W filepathstr 1762 // toc() 1763 1764 //// 1765 // 1766 // use the XOP operation to load in the data 1767 // -- this does everything - the pre-scan and creating the waves 1768 // 1769 // need to zero the waves before loading, just in case 1770 // 1771 1772 NVAR removeBadEvents = root:Packages:NIST:VSANS:Event:gRemoveBadEvents 1773 1774 s_tic() 1775 1776 // Wave/Z wave0=wave0 1777 // Wave/Z wave1=wave1 1778 // Wave/Z wave2=wave2 1779 // 1780 // if(WaveExists(wave0)) 1781 // MultiThread wave0=0 1782 // endif 1783 // if(WaveExists(wave1)) 1784 // MultiThread wave1=0 1785 // endif 1786 // if(WaveExists(wave2)) 1787 // MultiThread wave2=0 1788 // endif 1789 1790 if(removeBadEvents) 1791 EventLoadWave/R/N=EventWave filepathstr 1792 else 1793 EventLoadWave/N=EventWave filepathstr 1794 endif 1795 1796 1797 Print "XOP files loaded = ",S_waveNames 1798 1799 //// -- copy the waves over to xLoc,yLoc,timePt 1800 Wave/Z EventWave0=EventWave0 1801 Wave/Z EventWave1=EventWave1 1802 Wave/Z EventWave2=EventWave2 1803 1804 1805 Duplicate/O EventWave0,xLoc 1806 KillWaves/Z EventWave0 1807 1808 Duplicate/O EventWave1,yLoc 1809 KillWaves/Z EventWave1 1810 1811 Duplicate/O EventWave2,timePt 1812 KillWaves/Z EventWave2 1813 1814 // could do this, but rescaled time will neeed to be converted to SP (or DP) 1815 // and Igor loader was written with Make generating SP/DP waves 1816 // /I/U is unsigned 32-bit integer (for the time) 1817 // /B/U is unsigned 8-bit integer (max val=255) for the x and y values 1818 1819 // Redimension/B/U xLoc,yLoc 1820 // Redimension/I/U timePt 1821 1822 // access the variables from the XOP 1823 numT0 = V_numT0 1824 numPP = V_numPP 1825 num0 = V_num0 1826 num1 = V_num1 1827 num2 = V_num2 1828 num3 = V_num3 1829 numXYevents = V_nXYevents 1830 numZero = V_numZero 1831 numBad = V_numBad 1832 numRemoved = V_numRemoved 1833 1834 Print "(XOP) numT0 = ",numT0 1835 Print "num0 = ",num0 1836 Print "num1 = ",num1 1837 Print "num2 = ",num2 1838 Print "num3 = ",num3 1839 1840 1841 // dispStr will be displayed on the panel 1842 fileStr = ParseFilePath(0, filepathstr, ":", 1, 0) 1843 1844 sprintf tmpStr, "%s: %d total bytes\r",fileStr,totBytes 1845 dispStr = tmpStr 1846 sprintf tmpStr,"numXYevents = %d\r",numXYevents 1847 dispStr += tmpStr 1848 sprintf tmpStr,"PP = %d : ",numPP 1849 dispStr += tmpStr 1850 sprintf tmpStr,"ZeroData = %d\r",numZero 1851 dispStr += tmpStr 1852 sprintf tmpStr,"Rollover = %d",num3 1853 dispStr += tmpStr 1854 1855 s_toc() 1856 1857 Print "Events removed (XOP) = ",numRemoved 1858 1859 sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 1860 dispStr += tmpStr 1861 sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 1862 dispStr += tmpStr 1863 1864 1865 // simply to compile a table of # XY vs # bytes 1866 // Wave/Z nxy = root:numberXY 1867 // Wave/Z nBytes = root:numberBytes 1868 // if(WaveExists(nxy) && WaveExists(nBytes)) 1869 // InsertPoints 0, 1, nxy,nBytes 1870 // nxy[0] = numXYevents 1871 // nBytes[0] = totBytes 1872 // endif 1873 1874 SetDataFolder root: 1875 1876 #endif 1877 return(0) 1878 1879 End 1880 1881 ////////////// 1882 1883 Proc BinEventBarGraph() 1884 1885 DoWindow/F EventBarGraph 1403 1404 Proc V_BinEventBarGraph() 1405 1406 DoWindow/F V_EventBarGraph 1886 1407 if(V_flag == 0) 1887 1408 PauseUpdate; Silent 1 // building window... 1888 1409 String fldrSav0= GetDataFolder(1) 1889 1410 SetDataFolder root:Packages:NIST:VSANS:Event: 1890 Display /W=(110,705,610,1132)/N= EventBarGraph /K=1 binCount vs binEndTime1411 Display /W=(110,705,610,1132)/N=V_EventBarGraph /K=1 binCount vs binEndTime 1891 1412 SetDataFolder fldrSav0 1892 1413 ModifyGraph mode=5 … … 1898 1419 ModifyGraph gaps=0 1899 1420 ModifyGraph usePlusRGB=1 1900 ModifyGraph toMode= 11421 ModifyGraph toMode=0 1901 1422 ModifyGraph useBarStrokeRGB=1 1902 1423 ModifyGraph standoff=0 … … 1908 1429 1909 1430 1910 Proc ShowBinTable()1911 1912 DoWindow/F BinEventTable1431 Proc V_ShowBinTable() 1432 1433 DoWindow/F V_BinEventTable 1913 1434 if(V_flag == 0) 1914 1435 PauseUpdate; Silent 1 // building window... 1915 1436 String fldrSav0= GetDataFolder(1) 1916 1437 SetDataFolder root:Packages:NIST:VSANS:Event: 1917 Edit/W=(498,699,1003,955) /K=1/N= BinEventTable binCount,binEndTime,timeWidth1438 Edit/W=(498,699,1003,955) /K=1/N=V_BinEventTable binCount,binEndTime,timeWidth 1918 1439 ModifyTable format(Point)=1,sigDigits(binEndTime)=8,width(binEndTime)=100 1919 1440 SetDataFolder fldrSav0 … … 1924 1445 // only show the first 1500 data points 1925 1446 // 1926 Proc ShowRescaledTimeGraph()1927 1928 DoWindow/F RescaledTimeGraph1447 Proc V_ShowRescaledTimeGraph() 1448 1449 DoWindow/F V_RescaledTimeGraph 1929 1450 if(V_flag == 0) 1930 1451 PauseUpdate; Silent 1 // building window... 1931 1452 String fldrSav0= GetDataFolder(1) 1932 1453 SetDataFolder root:Packages:NIST:VSANS:Event: 1933 Display /W=(25,44,486,356)/K=1/N= RescaledTimeGraph rescaledTime1454 Display /W=(25,44,486,356)/K=1/N=V_RescaledTimeGraph rescaledTime 1934 1455 SetDataFolder fldrSav0 1935 1456 ModifyGraph mode=4 … … 2109 1630 // 2110 1631 // 2111 Function JointHistogramWithRange(w0,w1,hist,index,pt1,pt2)1632 Function V_JointHistogramWithRange(w0,w1,hist,index,pt1,pt2) 2112 1633 wave w0,w1,hist,index 2113 1634 Variable pt1,pt2 … … 2131 1652 // just does the indexing, creates wave SavedIndex in the current folder for the index 2132 1653 // 2133 Function IndexForHistogram(w0,w1,hist)1654 Function V_IndexForHistogram(w0,w1,hist) 2134 1655 wave w0,w1,hist 2135 1656 … … 2165 1686 2166 1687 ////////////// Post-processing of the event mode data 2167 Proc ShowEventCorrectionPanel()2168 DoWindow/F EventCorrectionPanel1688 Proc V_ShowEventCorrectionPanel() 1689 DoWindow/F V_EventCorrectionPanel 2169 1690 if(V_flag ==0) 2170 EventCorrectionPanel()1691 V_EventCorrectionPanel() 2171 1692 EndIf 2172 1693 End 2173 1694 2174 Proc EventCorrectionPanel()1695 Proc V_EventCorrectionPanel() 2175 1696 2176 1697 PauseUpdate; Silent 1 // building window... … … 2179 1700 if(exists("rescaledTime") == 1) 2180 1701 Display /W=(35,44,761,533)/K=2 rescaledTime 2181 DoWindow/C EventCorrectionPanel1702 DoWindow/C V_EventCorrectionPanel 2182 1703 ModifyGraph mode=4 2183 1704 ModifyGraph marker=19 … … 2190 1711 2191 1712 ControlBar 100 2192 Button button0,pos={18,12},size={70,20},proc= EC_AddCursorButtonProc,title="Cursors"2193 Button button1,pos={153,12},size={80,20},proc= EC_AddTimeButtonProc,title="Add time"2194 Button button2,pos={153,38},size={80,20},proc= EC_SubtractTimeButtonProc,title="Subtr time"2195 Button button3,pos={153,64},size={90,20},proc= EC_TrimPointsButtonProc,title="Trim points"2196 Button button4,pos={295+150,12},size={90,20},proc= EC_SaveWavesButtonProc,title="Save Waves"2197 Button button5,pos={295,64},size={100,20},proc= EC_FindOutlierButton,title="Find Outlier"2198 Button button6,pos={18,38},size={80,20},proc= EC_ShowAllButtonProc,title="All Data"2199 Button button7,pos={683,12},size={30,20},proc= EC_HelpButtonProc,title="?"2200 Button button8,pos={658,72},size={60,20},proc= EC_DoneButtonProc,title="Done"2201 2202 Button button9,pos={295,12},size={110,20},proc= EC_FindStepButton_down,title="Find Step Down"2203 Button button10,pos={295,38},size={110,20},proc= EC_FindStepButton_up,title="Find Step Up"2204 Button button11,pos={295+150,38},size={110,20},proc= EC_DoDifferential,title="Differential"1713 Button button0,pos={18,12},size={70,20},proc=V_EC_AddCursorButtonProc,title="Cursors" 1714 Button button1,pos={153,12},size={80,20},proc=V_EC_AddTimeButtonProc,title="Add time" 1715 Button button2,pos={153,38},size={80,20},proc=V_EC_SubtractTimeButtonProc,title="Subtr time" 1716 Button button3,pos={153,64},size={90,20},proc=V_EC_TrimPointsButtonProc,title="Trim points" 1717 Button button4,pos={295+150,12},size={90,20},proc=V_EC_SaveWavesButtonProc,title="Save Waves" 1718 Button button5,pos={295,64},size={100,20},proc=V_EC_FindOutlierButton,title="Find Outlier" 1719 Button button6,pos={18,38},size={80,20},proc=V_EC_ShowAllButtonProc,title="All Data" 1720 Button button7,pos={683,12},size={30,20},proc=V_EC_HelpButtonProc,title="?" 1721 Button button8,pos={658,72},size={60,20},proc=V_EC_DoneButtonProc,title="Done" 1722 1723 Button button9,pos={295,12},size={110,20},proc=V_EC_FindStepButton_down,title="Find Step Down" 1724 Button button10,pos={295,38},size={110,20},proc=V_EC_FindStepButton_up,title="Find Step Up" 1725 Button button11,pos={295+150,38},size={110,20},proc=V_EC_DoDifferential,title="Differential" 2205 1726 2206 1727 … … 2213 1734 EndMacro 2214 1735 2215 Function EC_AddCursorButtonProc(ba) : ButtonControl1736 Function V_EC_AddCursorButtonProc(ba) : ButtonControl 2216 1737 STRUCT WMButtonAction &ba 2217 1738 … … 2236 1757 // updates the longest time (as does every operation of adjusting the data) 2237 1758 // 2238 Function EC_AddTimeButtonProc(ba) : ButtonControl1759 Function V_EC_AddTimeButtonProc(ba) : ButtonControl 2239 1760 STRUCT WMButtonAction &ba 2240 1761 … … 2271 1792 End 2272 1793 2273 Function EC_SubtractTimeButtonProc(ba) : ButtonControl1794 Function V_EC_SubtractTimeButtonProc(ba) : ButtonControl 2274 1795 STRUCT WMButtonAction &ba 2275 1796 … … 2311 1832 // put both cursors on the same point to remove just that single point 2312 1833 // 2313 Function EC_TrimPointsButtonProc(ba) : ButtonControl1834 Function V_EC_TrimPointsButtonProc(ba) : ButtonControl 2314 1835 STRUCT WMButtonAction &ba 2315 1836 … … 2350 1871 2351 1872 // un-sort the data first, then save it 2352 Function EC_SaveWavesButtonProc(ba) : ButtonControl1873 Function V_EC_SaveWavesButtonProc(ba) : ButtonControl 2353 1874 STRUCT WMButtonAction &ba 2354 1875 … … 2379 1900 // this duplicates all of the bits that would be done if the "load" button was pressed 2380 1901 // 2381 Function EC_ImportWavesButtonProc(ba) : ButtonControl1902 Function V_EC_ImportWavesButtonProc(ba) : ButtonControl 2382 1903 STRUCT WMButtonAction &ba 2383 1904 … … 2423 1944 2424 1945 2425 Function EC_ShowAllButtonProc(ba) : ButtonControl1946 Function V_EC_ShowAllButtonProc(ba) : ButtonControl 2426 1947 STRUCT WMButtonAction &ba 2427 1948 … … 2438 1959 End 2439 1960 2440 Function EC_HelpButtonProc(ba) : ButtonControl1961 Function V_EC_HelpButtonProc(ba) : ButtonControl 2441 1962 STRUCT WMButtonAction &ba 2442 1963 … … 2453 1974 End 2454 1975 2455 Function EC_DoneButtonProc(ba) : ButtonControl1976 Function V_EC_DoneButtonProc(ba) : ButtonControl 2456 1977 STRUCT WMButtonAction &ba 2457 1978 … … 2459 1980 case 2: // mouse up 2460 1981 // click code here 2461 DoWindow/K EventCorrectionPanel1982 DoWindow/K V_EventCorrectionPanel 2462 1983 break 2463 1984 case -1: // control being killed … … 2469 1990 2470 1991 //upDown 5 or -5 looks for spikes +5 or -5 std deviations from mean 2471 Function PutCursorsAtStep(upDown)1992 Function V_PutCursorsAtStep(upDown) 2472 1993 Variable upDown 2473 1994 … … 2510 2031 // find the max (or min) of the rescaled time set 2511 2032 // and place both cursors there 2512 Function fFindOutlier()2033 Function V_fFindOutlier() 2513 2034 2514 2035 SetDataFolder root:Packages:NIST:VSANS:Event: … … 2543 2064 End 2544 2065 2545 Function EC_FindStepButton_down(ctrlName) : ButtonControl2066 Function V_EC_FindStepButton_down(ctrlName) : ButtonControl 2546 2067 String ctrlName 2547 2068 … … 2549 2070 NVAR upDown = root:Packages:NIST:VSANS:Event:gStepTolerance 2550 2071 2551 PutCursorsAtStep(-1*upDown)2072 V_PutCursorsAtStep(-1*upDown) 2552 2073 2553 2074 return(0) … … 2555 2076 2556 2077 2557 Function EC_FindStepButton_up(ctrlName) : ButtonControl2078 Function V_EC_FindStepButton_up(ctrlName) : ButtonControl 2558 2079 String ctrlName 2559 2080 … … 2561 2082 NVAR upDown = root:Packages:NIST:VSANS:Event:gStepTolerance 2562 2083 2563 PutCursorsAtStep(upDown)2084 V_PutCursorsAtStep(upDown) 2564 2085 2565 2086 return(0) … … 2568 2089 // if the Trim button section is uncommented, it's "Zap outlier" 2569 2090 // 2570 Function EC_FindOutlierButton(ctrlName) : ButtonControl2091 Function V_EC_FindOutlierButton(ctrlName) : ButtonControl 2571 2092 String ctrlName 2572 2093 2573 fFindOutlier()2094 V_fFindOutlier() 2574 2095 // 2575 2096 // STRUCT WMButtonAction ba … … 2581 2102 end 2582 2103 2583 Function EC_DoDifferential(ctrlName) : ButtonControl2104 Function V_EC_DoDifferential(ctrlName) : ButtonControl 2584 2105 String ctrlName 2585 2106 2586 DifferentiatedTime()2587 DoWindow/F EventCorrectionPanel2107 V_DifferentiatedTime() 2108 DoWindow/F V_EventCorrectionPanel 2588 2109 2589 2110 //if trace is not on graph, add it 2590 2111 SetDataFolder root:Packages:NIST:VSANS:Event: 2591 2112 2592 String list = WaveList("*_DIF", ";", "WIN: EventCorrectionPanel")2113 String list = WaveList("*_DIF", ";", "WIN:V_EventCorrectionPanel") 2593 2114 if(strlen(list) == 0) 2594 2115 AppendToGraph/R rescaledTime_DIF … … 2607 2128 // trying to draw the panel 2608 2129 // 2609 Proc Show_CustomBinPanel()2610 DoWindow/F CustomBinPanel2130 Proc V_Show_CustomBinPanel() 2131 DoWindow/F V_CustomBinPanel 2611 2132 if(V_flag ==0) 2612 Init_CustomBins()2613 CustomBinPanel()2133 V_Init_CustomBins() 2134 V_CustomBinPanel() 2614 2135 EndIf 2615 2136 End 2616 2137 2617 2138 2618 Function Init_CustomBins()2139 Function V_Init_CustomBins() 2619 2140 2620 2141 NVAR nSlice = root:Packages:NIST:VSANS:Event:gEvent_nslices … … 2645 2166 // This shares the number of slices and the maximum time with the main panel 2646 2167 // 2647 Proc CustomBinPanel()2168 Proc V_CustomBinPanel() 2648 2169 PauseUpdate; Silent 1 // building window... 2649 NewPanel /W=(130,44,851,455)/K=2 /N= CustomBinPanel2650 DoWindow/C CustomBinPanel2170 NewPanel /W=(130,44,851,455)/K=2 /N=V_CustomBinPanel 2171 DoWindow/C V_CustomBinPanel 2651 2172 ModifyPanel fixedSize=1//,noEdit =1 2652 2173 SetDrawLayer UserBack 2653 2174 2654 2175 Button button0,pos={654,42}, size={50,20},title="Done",fSize=12 2655 Button button0,proc= CB_Done_Proc2656 Button button1,pos={663,14},size={40,20},proc= CB_HelpButtonProc,title="?"2657 Button button2,pos={216,42},size={80,20},title="Update",proc= CB_UpdateWavesButton2176 Button button0,proc=V_CB_Done_Proc 2177 Button button1,pos={663,14},size={40,20},proc=V_CB_HelpButtonProc,title="?" 2178 Button button2,pos={216,42},size={80,20},title="Update",proc=V_CB_UpdateWavesButton 2658 2179 SetVariable setvar1,pos={23,13},size={160,20},title="Number of slices",fSize=12 2659 2180 SetVariable setvar1,proc=CB_NumSlicesSetVarProc,value=root:Packages:NIST:VSANS:Event:gEvent_nslices … … 2663 2184 CheckBox chkbox1,pos={216,14},title="Enforce Max Time?" 2664 2185 CheckBox chkbox1,variable = root:Packages:NIST:VSANS:Event:gEvent_ForceTmaxBin 2665 Button button3,pos={500,14},size={90,20},proc= CB_SaveBinsButtonProc,title="Save Bins"2666 Button button4,pos={500,42},size={100,20},proc= CB_ImportBinsButtonProc,title="Import Bins"2186 Button button3,pos={500,14},size={90,20},proc=V_CB_SaveBinsButtonProc,title="Save Bins" 2187 Button button4,pos={500,42},size={100,20},proc=V_CB_ImportBinsButtonProc,title="Import Bins" 2667 2188 2668 2189 SetDataFolder root:Packages:NIST:VSANS:Event: 2669 2190 2670 Display/W=(291,86,706,395)/HOST= CustomBinPanel/N=BarGraph binCount vs binEndTime2191 Display/W=(291,86,706,395)/HOST=V_CustomBinPanel/N=BarGraph binCount vs binEndTime 2671 2192 ModifyGraph mode=5 2672 2193 ModifyGraph marker=19 … … 2686 2207 2687 2208 // and the table 2688 Edit/W=(13,87,280,394)/HOST= CustomBinPanel/N=T02689 AppendToTable/W= CustomBinPanel#T0 timeWidth,binEndTime2209 Edit/W=(13,87,280,394)/HOST=V_CustomBinPanel/N=T0 2210 AppendToTable/W=V_CustomBinPanel#T0 timeWidth,binEndTime 2690 2211 ModifyTable width(Point)=40 2691 2212 SetActiveSubwindow ## … … 2697 2218 // save the bins - use Igor Text format 2698 2219 // 2699 Function CB_SaveBinsButtonProc(ba) : ButtonControl2220 Function V_CB_SaveBinsButtonProc(ba) : ButtonControl 2700 2221 STRUCT WMButtonAction &ba 2701 2222 … … 2728 2249 // -- loads in timeWidth and binEndTime 2729 2250 // 2730 Function CB_ImportBinsButtonProc(ba) : ButtonControl2251 Function V_CB_ImportBinsButtonProc(ba) : ButtonControl 2731 2252 STRUCT WMButtonAction &ba 2732 2253 … … 2771 2292 // 2772 2293 // 2773 Function CB_UpdateWavesButton(ba) : ButtonControl2294 Function V_CB_UpdateWavesButton(ba) : ButtonControl 2774 2295 STRUCT WMButtonAction &ba 2775 2296 … … 2806 2327 WaveStats/Q timeWidth 2807 2328 if(V_min < 0) 2808 ModifyTable/W= CustomBinPanel#T0 style(timeWidth)=1,rgb(timeWidth)=(65535,0,0)2329 ModifyTable/W=V_CustomBinPanel#T0 style(timeWidth)=1,rgb(timeWidth)=(65535,0,0) 2809 2330 else 2810 ModifyTable/W= CustomBinPanel#T0 style(timeWidth)=0,rgb(timeWidth)=(0,0,0)2331 ModifyTable/W=V_CustomBinPanel#T0 style(timeWidth)=0,rgb(timeWidth)=(0,0,0) 2811 2332 endif 2812 2333 … … 2821 2342 End 2822 2343 2823 Function CB_HelpButtonProc(ba) : ButtonControl2344 Function V_CB_HelpButtonProc(ba) : ButtonControl 2824 2345 STRUCT WMButtonAction &ba 2825 2346 … … 2836 2357 End 2837 2358 2838 Function CB_Done_Proc(ba) : ButtonControl2359 Function V_CB_Done_Proc(ba) : ButtonControl 2839 2360 STRUCT WMButtonAction &ba 2840 2361 … … 2842 2363 switch (ba.eventCode) 2843 2364 case 2: 2844 DoWindow/K CustomBinPanel2365 DoWindow/K V_CustomBinPanel 2845 2366 break 2846 2367 endswitch … … 2849 2370 2850 2371 2851 Function CB_NumSlicesSetVarProc(sva) : SetVariableControl2372 Function V_CB_NumSlicesSetVarProc(sva) : SetVariableControl 2852 2373 STRUCT WMSetVariableAction &sva 2853 2374 … … 2888 2409 // 2889 2410 2890 Proc SplitBigFile(splitSize, baseStr)2411 Proc V_SplitBigFile(splitSize, baseStr) 2891 2412 Variable splitSize = 100 2892 2413 String baseStr="split" … … 2895 2416 2896 2417 2897 fSplitBigFile(splitSize, baseStr)2898 2899 ShowSplitFileTable()2900 End 2901 2902 Function/S fSplitBigFile(splitSize, baseStr)2418 V_fSplitBigFile(splitSize, baseStr) 2419 2420 V_ShowSplitFileTable() 2421 End 2422 2423 Function/S V_fSplitBigFile(splitSize, baseStr) 2903 2424 Variable splitSize 2904 2425 String baseStr … … 3032 2553 // "Display Accumulated Slices",AccumulateSlices(2) 3033 2554 // 3034 Function AccumulateSlicesButton(ctrlName) : ButtonControl2555 Function V_AccumulateSlicesButton(ctrlName) : ButtonControl 3035 2556 String ctrlName 3036 2557 … … 3038 2559 mode = str2num(ctrlName[strlen(ctrlName)-1]) 3039 2560 // Print "mode=",mode 3040 AccumulateSlices(mode)2561 V_AccumulateSlices(mode) 3041 2562 3042 2563 return(0) 3043 2564 End 3044 2565 3045 Function AccumulateSlices(mode)2566 Function V_AccumulateSlices(mode) 3046 2567 Variable mode 3047 2568 … … 3065 2586 // do something to "touch" the display to force it to update 3066 2587 NVAR gLog = root:Packages:NIST:VSANS:Event:gEvent_logint 3067 LogIntEvent_Proc("",gLog)2588 V_LogIntEvent_Proc("",gLog) 3068 2589 break 3069 2590 default: … … 3109 2630 3110 2631 3111 Function SplitFileButtonProc(ctrlName) : ButtonControl2632 Function V_SplitFileButtonProc(ctrlName) : ButtonControl 3112 2633 String ctrlName 3113 2634 3114 Execute " SplitBigFile()"2635 Execute "V_SplitBigFile()" 3115 2636 End 3116 2637 … … 3118 2639 // show all of the data 3119 2640 // 3120 Proc ShowDecimatedGraph()3121 3122 DoWindow/F DecimatedGraph2641 Proc V_ShowDecimatedGraph() 2642 2643 DoWindow/F V_DecimatedGraph 3123 2644 if(V_flag == 0) 3124 2645 PauseUpdate; Silent 1 // building window... 3125 2646 String fldrSav0= GetDataFolder(1) 3126 2647 SetDataFolder root:Packages:NIST:VSANS:Event: 3127 Display /W=(25,44,486,356)/K=1/N= DecimatedGraph rescaledTime_dec2648 Display /W=(25,44,486,356)/K=1/N=V_DecimatedGraph rescaledTime_dec 3128 2649 SetDataFolder fldrSav0 3129 2650 ModifyGraph mode=4 … … 3143 2664 // so work with x,y,t, and rescaled time 3144 2665 // variables -- t_longest 3145 Function ConcatenateButtonProc(ctrlName) : ButtonControl2666 Function V_ConcatenateButtonProc(ctrlName) : ButtonControl 3146 2667 String ctrlName 3147 2668 … … 3149 2670 Variable first = V_flag 3150 2671 3151 fConcatenateButton(first)2672 V_fConcatenateButton(first) 3152 2673 3153 2674 return(0) 3154 2675 End 3155 2676 3156 Function fConcatenateButton(first)2677 Function V_fConcatenateButton(first) 3157 2678 Variable first 3158 2679 … … 3227 2748 End 3228 2749 3229 Function DisplayConcatenatedButtonProc(ctrlName) : ButtonControl2750 Function V_DisplayConcatenatedButtonProc(ctrlName) : ButtonControl 3230 2751 String ctrlName 3231 2752 … … 3257 2778 3258 2779 // unused, old testing procedure 3259 Function LoadDecimateButtonProc(ctrlName) : ButtonControl2780 Function V_LoadDecimateButtonProc(ctrlName) : ButtonControl 3260 2781 String ctrlName 3261 2782 3262 LoadEventLog_Button("")2783 V_LoadEventLog_Button("") 3263 2784 3264 2785 // now decimate -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Event_Testing.ipf
r1045 r1046 116 116 uint64 i64_ticks,i64_start 117 117 118 b1 = 47 119 b2 = 123 120 i64_ticks = 123456789 121 122 123 b2 = b2 << 48 124 b1 = b1 << 56 125 118 // b1 = 47 119 // b2 = 123 120 // i64_ticks = 123456789 121 b1 = 41 122 b2 = 66 123 i64_ticks = 15 124 125 126 // b2 = b2 << 48 127 // b1 = b1 << 56 128 // 129 // i64_num = b1+b2+i64_ticks 130 131 // don't shift b1 132 b2 = b2 << 8 133 i64_ticks = i64_ticks << 16 134 126 135 i64_num = b1+b2+i64_ticks 136 127 137 printf "%64b\r",i64_num 128 138 print i64_num … … 144 154 print val // correct 145 155 146 b1 = (val >> 56 ) & 0xFF // = 255, last byte, after shifting 147 b2 = (val >> 48 ) & 0xFF 148 149 btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 156 // b1 = (val >> 56 ) & 0xFF // = 255, last byte, after shifting 157 // b2 = (val >> 48 ) & 0xFF 158 // btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 159 160 161 b1 = val & 0xFF 162 b2 = (val >> 8) & 0xFF 163 btime = (val >> 16) 164 150 165 151 166 print b1 … … 173 188 // tested up to num=1e8 successfully 174 189 // 175 Function V_MakeFakeEventWave() 176 177 Variable num,ii 178 179 180 num = 1e3 190 Function V_MakeFakeEventWave(num) 191 Variable num 192 193 Variable ii 194 195 196 // num = 1e3 181 197 182 198 // // /l=64 bit, /U=unsigned … … 189 205 // bytes 3-8 (= 6 bytes): time stamp in resolution unit 190 206 191 uint64 i64_num,b1,b2 ,b3,b4,b5,b6,b7,b8207 uint64 i64_num,b1,b2 192 208 uint64 i64_ticks,i64_start 193 209 … … 201 217 i64_ticks = ii+1 202 218 203 b2 = b2 << 48 204 b1 = b1 << 56 219 // b2 = b2 << 48 220 // b1 = b1 << 56 221 222 // don't shift b1 223 b2 = b2 << 8 224 i64_ticks = i64_ticks << 16 205 225 206 226 i64_num = b1+b2+i64_ticks 227 207 228 eventWave[ii] = i64_num 208 229 endfor … … 213 234 214 235 236 // 237 // TODO: 238 // -- can this be multithreaded (eliminating the loop)? 239 // 240 // MultiThread tube = (w >> 56 ) & 0xFF 241 // MultiThread location = (w >> 48 ) & 0xFF 242 // MultiThread eventTime = val & 0xFFFFFFFFFFFF 243 // 244 // 245 // 215 246 Function V_decodeFakeEventWave(w) 216 247 Wave w … … 235 266 val = w[ii] 236 267 237 b1 = (val >> 56 ) & 0xFF // = 255, last two bytes, after shifting 238 b2 = (val >> 48 ) & 0xFF 239 240 btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 268 // b1 = (val >> 56 ) & 0xFF // = 255, last two bytes, after shifting 269 // b2 = (val >> 48 ) & 0xFF 270 // btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 271 272 b1 = val & 0xFF 273 b2 = (val >> 8) & 0xFF 274 btime = (val >> 16) 241 275 242 276 tube[ii] = b1 … … 260 294 String vsansStr="VSANS" 261 295 Variable revision = 11 262 Variable offset = 2 2// no disabled tubes296 Variable offset = 26 // no disabled tubes 263 297 Variable time1 = 2017 264 298 Variable time2 = 0525 265 299 Variable time3 = 1122 266 300 Variable time4 = 3344 // these 4 time pieces are supposed to be 8 bytes total 301 Variable time5 = 3344 // these 5 time pieces are supposed to be 10 bytes total 267 302 String detStr = "M" 268 303 Variable volt = 1500 269 Variable resol = 1 000304 Variable resol = 1e7 270 305 271 306 … … 279 314 FBinWrite/F=2/U refnum, time3 280 315 FBinWrite/F=2/U refnum, time4 316 FBinWrite/F=2/U refnum, time5 281 317 FBinWrite refnum, detStr 282 318 FBinWrite/F=2/U refnum, volt 283 FBinWrite/F= 2/U refnum, resol319 FBinWrite/F=3/U refnum, resol 284 320 285 321 FGetPos refnum 286 Print V_filePos 322 Print "End of header = ",V_filePos 323 offset = V_filePos 324 325 FSetPos refnum,7 326 FBinWrite/F=2/U refnum, offset //write the correct offset 327 328 329 FSetPos refNum, offset 287 330 288 331 FBinWrite refnum, w … … 296 339 // use GBLoadWave to do the reading, then I can do the decoding 297 340 // 298 Function V_readFakeEventFile( )299 300 String fname341 Function V_readFakeEventFile(fileName) 342 String filename 343 301 344 // this reads in uint64 data, to a unit64 wave, skipping 22 bytes 302 345 // GBLoadWave/B/T={192,192}/W=1/S=22 … … 304 347 305 348 306 // so to read:349 // to read a VSANS event file: 307 350 // 308 351 // - get the file name … … 310 353 // - move to EOF and close 311 354 // 312 // - Use GBLoadWave to read itin355 // - Use GBLoadWave to read the 64-bit events in 313 356 314 357 String vsansStr="" … … 319 362 Variable time3 320 363 Variable time4 // these 4 time pieces are supposed to be 8 bytes total 364 Variable time5 // these 5 time pieces are supposed to be 10 bytes total 321 365 String detStr="" 322 366 Variable volt … … 326 370 detStr = PadString(detStr,1,0x20) //pad to 1 byte 327 371 328 Open/R refnum 329 f name = S_fileName372 Open/R refnum as filename 373 filename = S_fileName 330 374 331 375 s_tic() … … 338 382 FBinRead/F=2/U refnum, time3 339 383 FBinRead/F=2/U refnum, time4 340 FBinRead refnum, detStr 384 FBinRead/F=2/U refnum, time5 385 FBinRead refnum, detStr //NOTE - the example data file Phil sent skipped the detStr (no placeholder!) 341 386 FBinRead/F=2/U refnum, volt 342 FBinRead/F= 2/U refnum, resol387 FBinRead/F=3/U refnum, resol 343 388 344 389 FStatus refnum … … 349 394 // number of data bytes 350 395 num = V_logEOF-offset 351 Print num/8 352 353 GBLoadWave/B/T={192,192}/W=1/S=22 fname 396 Print "Number of data values = ",num/8 397 398 GBLoadWave/B/T={192,192}/W=1/S=(offset) filename // intel, little-endian 399 // GBLoadWave/T={192,192}/W=1/S=(offset) filename // motorola, big-endian 354 400 355 401 Duplicate/O $(StringFromList(0,S_waveNames)) V_Events … … 357 403 s_toc() 358 404 359 return(0) 360 End 361 362 // 363 // tested up to num=1e8 successfully 364 // 365 Function V_MakeFakeEventWave_TOF() 366 367 Variable num,ii,jj,delayTime,numRepeat,std 405 Print vsansStr 406 Print revision 407 Print offset 408 Print time1 409 Print time2 410 Print time3 411 Print time4 412 Print time5 413 Print detStr 414 print volt 415 print resol 416 417 return(0) 418 End 419 420 // 421 // 422 // 423 Function V_MakeFakeEventWave_TOF(delayTime,std) 424 Variable delayTime,std 425 426 Variable num,ii,jj,numRepeat 368 427 369 428 370 429 num = 1000 371 numRepeat = 100 372 373 delayTime = 30 //microseconds374 std = 5//std deviation, microseconds430 numRepeat = 1000 431 432 // delayTime = 50 //microseconds 433 // std = 4 //std deviation, microseconds 375 434 376 435 // // /l=64 bit, /U=unsigned … … 402 461 i64_ticks = trunc(arrival[ii]) 403 462 404 b2 = b2 << 48 405 b1 = b1 << 56 463 // b2 = b2 << 48 464 // b1 = b1 << 56 465 466 // don't shift b1 467 b2 = b2 << 8 468 i64_ticks = i64_ticks << 16 406 469 407 470 i64_num = b1+b2+i64_ticks … … 413 476 return(0) 414 477 End 478 479 480 // TODO: 481 // 482 // There may be memory issues with this 483 // 484 // -- do I want to do the time binning first? 485 // -- does it really matter? 486 // 487 Function V_SortAndSplitFakeEvents() 488 489 Wave eventTime = root:EventTime 490 Wave location = root:location 491 Wave tube = root:tube 492 493 Sort tube,tube,eventTime,location 494 495 Variable b1,e1,b2,e2,b3,e3,b4,e4 496 FindValue/S=0/I=48 tube 497 b1 = 0 498 e1 = V_Value - 1 499 b2 = V_Value 500 FindValue/S=(b2)/I=96 tube 501 e2 = V_Value - 1 502 b3 = V_Value 503 FindValue/S=(b3)/I=144 tube 504 e3 = V_Value - 1 505 b4 = V_Value 506 e4 = numpnts(tube)-1 507 508 Print b1,e1 509 Print b2,e2 510 Print b3,e3 511 Print b4,e4 512 513 // tube and location become x and y, and can be byte data 514 // eventTime still needs to be 64 bit - when do I convert it to FP? 515 Make/O/B/U/N=(e1-b1+1) tube1,location1 516 Make/O/L/U/N=(e1-b1+1) eventTime1 517 518 Make/O/B/U/N=(e2-b2+1) tube2,location2 519 Make/O/L/U/N=(e2-b2+1) eventTime2 520 521 Make/O/B/U/N=(e3-b3+1) tube3,location3 522 Make/O/L/U/N=(e3-b3+1) eventTime3 523 524 Make/O/B/U/N=(e4-b4+1) tube4,location4 525 Make/O/L/U/N=(e4-b4+1) eventTime4 526 527 528 tube1 = tube[p+b1] 529 tube2 = tube[p+b2] 530 tube3 = tube[p+b3] 531 tube4 = tube[p+b4] 532 533 location1 = location[p+b1] 534 location2 = location[p+b2] 535 location3 = location[p+b3] 536 location4 = location[p+b4] 537 538 eventTime1 = eventTime[p+b1] 539 eventTime2 = eventTime[p+b2] 540 eventTime3 = eventTime[p+b3] 541 eventTime4 = eventTime[p+b4] 542 543 544 KillWaves/Z eventTime,location,tube 545 546 return(0) 547 End 548 549 550 551 // TODO: 552 // 553 // There may be memory issues with this 554 // 555 // -- do I want to do the time binning first? 556 // -- does it really matter? 557 // 558 Function V_SortAndSplitEvents() 559 560 561 SetDataFolder root:Packages:NIST:VSANS:Event: 562 563 Wave eventTime = EventTime 564 Wave location = location 565 Wave tube = tube 566 567 Sort tube,tube,eventTime,location 568 569 Variable b1,e1,b2,e2,b3,e3,b4,e4 570 FindValue/S=0/I=48 tube 571 b1 = 0 572 e1 = V_Value - 1 573 b2 = V_Value 574 FindValue/S=(b2)/I=96 tube 575 e2 = V_Value - 1 576 b3 = V_Value 577 FindValue/S=(b3)/I=144 tube 578 e3 = V_Value - 1 579 b4 = V_Value 580 e4 = numpnts(tube)-1 581 582 Print b1,e1 583 Print b2,e2 584 Print b3,e3 585 Print b4,e4 586 587 // tube and location become x and y, and can be byte data 588 // eventTime still needs to be 64 bit - when do I convert it to FP? 589 Make/O/B/U/N=(e1-b1+1) tube1,location1 590 Make/O/L/U/N=(e1-b1+1) eventTime1 591 592 Make/O/B/U/N=(e2-b2+1) tube2,location2 593 Make/O/L/U/N=(e2-b2+1) eventTime2 594 595 Make/O/B/U/N=(e3-b3+1) tube3,location3 596 Make/O/L/U/N=(e3-b3+1) eventTime3 597 598 Make/O/B/U/N=(e4-b4+1) tube4,location4 599 Make/O/L/U/N=(e4-b4+1) eventTime4 600 601 602 tube1 = tube[p+b1] 603 tube2 = tube[p+b2] 604 tube3 = tube[p+b3] 605 tube4 = tube[p+b4] 606 607 location1 = location[p+b1] 608 location2 = location[p+b2] 609 location3 = location[p+b3] 610 location4 = location[p+b4] 611 612 eventTime1 = eventTime[p+b1] 613 eventTime2 = eventTime[p+b2] 614 eventTime3 = eventTime[p+b3] 615 eventTime4 = eventTime[p+b4] 616 617 618 KillWaves/Z eventTime,location,tube 619 620 return(0) 621 End 622 623 624 // 625 // switch the "active" panel to the selected group (1-4) (5 concatenates them all together) 626 // 627 // copy the set of tubes over to the "active" set that is to be histogrammed 628 // and redimension them to be sure that they are double precision 629 // 630 Function V_SwitchTubeGroup(tubeGroup) 631 Variable tubeGroup 632 633 SetDataFolder root:Packages:NIST:VSANS:Event: 634 635 if(tubeGroup <= 4) 636 Wave tube = $("tube"+num2Str(tubeGroup)) 637 Wave location = $("location"+num2Str(tubeGroup)) 638 Wave eventTime = $("eventTime"+num2Str(tubeGroup)) 639 640 Wave xloc,yLoc,timePt 641 642 KillWaves/Z timePt,xLoc,yLoc 643 Duplicate/O tube xLoc 644 Duplicate/O location yLoc 645 Duplicate/O eventTime timePt 646 647 Redimension/D xLoc,yLoc,timePt 648 649 endif 650 651 if(tubeGroup == 5) 652 Wave xloc,yLoc,timePt 653 654 KillWaves/Z timePt,xLoc,yLoc 655 656 String str = "" 657 str = "tube1;tube2;tube3;tube4;" 658 Concatenate/O/NP str,xloc 659 str = "location1;location2;location3;location4;" 660 Concatenate/O/NP str,yloc 661 str = "eventTime1;eventTime2;eventTime3;eventTime4;" 662 Concatenate/O/NP str,timePt 663 664 Redimension/D xLoc,yLoc,timePt 665 endif 666 667 668 return(0) 669 End 670 671 Proc V_SwitchGroupAndCleanup(num) 672 Variable num 673 674 V_SwitchTubeGroup(num) 675 SetDataFolder root:Packages:NIST:VSANS:Event: 676 Duplicate/O timePt rescaledTime 677 KillWaves/Z OscSortIndex 678 print WaveMax(rescaledTime) 679 root:Packages:NIST:VSANS:Event:gEvent_t_longest = waveMax(rescaledTime) 680 681 SetDataFolder root: 682 683 end 684 685 Function V_count(num) 686 Variable num 687 688 SetDataFolder root:Packages:NIST:VSANS:Event: 689 690 Wave xloc = xloc 691 wave yloc = yloc 692 Variable ii,npt,total=0 693 npt = numpnts(xloc) 694 for(ii=0;ii<npt;ii+=1) 695 if(xloc[ii] == num) 696 total += 1 697 endif 698 if(yloc[ii] == num) 699 total += 1 700 endif 701 endfor 702 703 Print total 704 705 SetDataFolder root: 706 707 end
Note: See TracChangeset
for help on using the changeset viewer.