Ignore:
Timestamp:
Jun 24, 2013 4:29:54 PM (10 years ago)
Author:
srkline
Message:

Changes to panels so that they fit on a low-resolution laptop screen (Nx768).

  • Auto Fit
  • Event Mode
  • All polarization panels

In addition, Functionality was added to the event mode processing to (better) handle large files. Files can be split and either added as slices (if oscillatory) or decimated (if stream). The "tweaking" of the data stream is also a little bit more automated now, using some intelligent locating of the time steps and an overlay of the derivative.

Corrected a few bugs in file handling on the polarization panels in cases where the user canceled out of a file dialog.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf

    r912 r915  
    9696// 
    9797 
     98Static Constant MODE_STREAM = 0 
     99Static Constant MODE_OSCILL = 1 
     100Static Constant MODE_TISANE = 2 
     101Static Constant MODE_TOF = 3 
     102 
    98103//Menu "Macros" 
    99104//      "Split Large File",SplitBigFile() 
     
    132137        Variable/G root:Packages:NIST:gEvent_logint = 1 
    133138 
    134         Variable/G root:Packages:NIST:gEvent_Mode = 0                           // ==0 for "stream", ==1 for Oscillatory 
     139        Variable/G root:Packages:NIST:gEvent_Mode = MODE_OSCILL                         // ==0 for "stream", ==1 for Oscillatory 
    135140        Variable/G root:Packages:NIST:gRemoveBadEvents = 1              // ==1 to remove "bad" events, ==0 to read "as-is" 
    136141        Variable/G root:Packages:NIST:gSortStreamEvents = 0             // ==1 to sort the event stream, a last resort for a stream of data 
     
    146151        Duplicate/O slicedData logslicedData 
    147152        Duplicate/O slicedData dispsliceData 
     153 
     154 
     155// for decimation 
     156        Variable/G root:Packages:NIST:Event:gDecimation = 100 
     157        Variable/G root:Packages:NIST:gEvent_t_longest_decimated = 0 
     158 
     159// for large file splitting 
     160        String/G root:Packages:NIST:Event:gSplitFileList = ""           // a list of the file names as split 
    148161         
    149162        SetDataFolder root: 
    150163End 
    151164 
     165// 
     166// -- extra bits of buttons... not used 
     167// 
     168//      Button button9 title="Decimation",size={100,20},pos={490,400},proc=E_ShowDecimateButton 
     169// 
     170//      Button button11,pos={490,245},size={150,20},proc=LoadDecimateButtonProc,title="Load and Decimate" 
     171//      Button button12,pos={490,277},size={150,20},proc=ConcatenateButtonProc,title="Concatenate" 
     172//      Button button13,pos={490,305},size={150,20},proc=DisplayConcatenatedButtonProc,title="Display Concatenated" 
     173//       
     174//      GroupBox group0 title="Manual Controls",size={185,112},pos={490,220} 
     175// 
     176//      NewPanel /W=(82,44,854,664)/N=EventModePanel/K=2 
     177//      DoWindow/C EventModePanel 
     178//      ModifyPanel fixedSize=1,noEdit =1 
    152179Proc EventModePanel() 
    153180        PauseUpdate; Silent 1           // building window... 
    154         NewPanel /W=(100,50,600,840)/N=EventModePanel/K=2 
     181        NewPanel /W=(82,44,854,664)/N=EventModePanel/K=2 
    155182        DoWindow/C EventModePanel 
    156183        ModifyPanel fixedSize=1,noEdit =1 
    157         //ShowTools/A 
     184 
    158185        SetDrawLayer UserBack 
    159         Button button0,pos={10,10}, size={150,20},title="Load Event Log File",fSize=12 
    160         Button button0,proc=LoadEventLog_Button 
    161          
    162         TitleBox tb1,pos={20,650},size={460,80},fSize=12 
    163         TitleBox tb1,variable=root:Packages:NIST:gEventDisplayString 
    164          
    165         CheckBox chkbox1,pos={170,8},title="Oscillatory Mode?" 
    166         CheckBox chkbox1,variable = root:Packages:NIST:gEvent_mode 
    167         CheckBox chkbox3,pos={170,27},title="Remove Bad Events?" 
    168         CheckBox chkbox3,variable = root:Packages:NIST:gRemoveBadEvents 
    169          
    170         Button doneButton,pos={435,12}, size={50,20},title="Done",fSize=12 
    171         Button doneButton,proc=EventDone_Proc 
    172  
    173         Button button2,pos={20,122},size={140,20},proc=ShowEventDataButtonProc,title="Show Event Data" 
    174         Button button3,pos={20,147},size={140,20},proc=ShowBinDetailsButtonProc,title="Show Bin Details" 
    175         Button button4,pos={175,122},size={140,20},proc=UndoTimeSortButtonProc,title="Undo Time Sort" 
    176         Button button5,pos={175,147},size={140,20},proc=ExportSlicesButtonProc,title="Export Slices as VAX" 
    177         Button button6,pos={378,13},size={40,20},proc=EventModeHelpButtonProc,title="?" 
    178  
    179         Button button7,pos={175+155,122},size={140,20},proc=AdjustEventDataButtonProc,title="Adjust Events" 
    180         Button button8,pos={175+155,147},size={140,20},proc=CustomBinButtonProc,title="Custom Bins" 
    181          
    182         Button button1,pos = {10,50}, size={150,20},title="Process Data",fSize=12 
    183         Button button1,proc=ProcessEventLog_Button 
    184         SetVariable setvar1,pos={170,50},size={160,20},title="Number of slices",fSize=12,limits={1,1000,1} 
    185         SetVariable setvar1,value=root:Packages:NIST:gEvent_nslices 
    186         SetVariable setvar2,pos={330,50},size={160,20},title="Max Time (s)",fSize=12 
    187         SetVariable setvar2,value=root:Packages:NIST:gEvent_t_longest 
    188          
    189         PopupMenu popup0 title="Bin Spacing",pos={150,90},value="Equal;Fibonacci;Custom;" 
    190         PopupMenu popup0 proc=BinTypePopMenuProc 
    191          
    192         CheckBox chkbox2,pos={20,95},title="Log Intensity",value=1 
    193         CheckBox chkbox2,variable=root:Packages:NIST:gEvent_logint,proc=LogIntEvent_Proc 
    194         SetVariable setvar0,pos={320,90},size={160,20},title="Display Time Slice",fSize=12 
    195         SetVariable setvar0,limits={0,1000,1},value= root:Packages:NIST:gEvent_tsdisp 
    196         SetVariable setvar0,proc=sliceSelectEvent_Proc 
    197         Display/W=(20,180,480,640)/HOST=EventModePanel/N=Event_slicegraph 
    198         AppendImage/W=EventModePanel#Event_slicegraph/T root:Packages:NIST:Event:dispsliceData 
    199         ModifyImage/W=EventModePanel#Event_slicegraph  ''#0 ctab= {*,*,ColdWarm,0} 
    200         ModifyImage/W=EventModePanel#Event_slicegraph ''#0 ctabAutoscale=3 
     186        DrawText 479,345,"Stream Data" 
     187        DrawLine 563,338,731,338 
     188        DrawText 479,419,"Oscillatory Data" 
     189        DrawLine 578,411,731,411 
     190 
     191//      ShowTools/A 
     192        Button button0,pos={14,87},size={150,20},proc=LoadEventLog_Button,title="Load Event Log File" 
     193        Button button0,fSize=12 
     194        TitleBox tb1,pos={475,500},size={135,24},fSize=10 
     195        TitleBox tb1,variable= root:Packages:NIST:gEventDisplayString 
     196 
     197        CheckBox chkbox2,pos={376,151},size={81,14},proc=LogIntEvent_Proc,title="Log Intensity" 
     198        CheckBox chkbox2,fSize=10,variable= root:Packages:NIST:gEvent_logint 
     199        CheckBox chkbox3,pos={14,125},size={119,14},title="Remove Bad Events?",fSize=10 
     200        CheckBox chkbox3,variable= root:Packages:NIST:gRemoveBadEvents 
     201         
     202        Button doneButton,pos={708,36},size={50,20},proc=EventDone_Proc,title="Done" 
     203        Button doneButton,fSize=12 
     204        Button button2,pos={419,28},size={140,20},proc=ShowEventDataButtonProc,title="Show Event Data" 
     205        Button button3,pos={419,56},size={140,20},proc=ShowBinDetailsButtonProc,title="Show Bin Details" 
     206        Button button4,pos={487,227},size={120,20},proc=UndoTimeSortButtonProc,title="Undo Time Sort" 
     207        Button button5,pos={419,85},size={140,20},proc=ExportSlicesButtonProc,title="Export Slices as VAX" 
     208        Button button6,pos={718,9},size={40,20},proc=EventModeHelpButtonProc,title="?" 
     209        Button button7,pos={487,197},size={120,20},proc=AdjustEventDataButtonProc,title="Adjust Events" 
     210        Button button8,pos={619,197},size={120,20},proc=CustomBinButtonProc,title="Custom Bins" 
     211        Button button1,pos={206,100},size={120,20},proc=ProcessEventLog_Button,title="Bin Event Data" 
     212        Button button1,fSize=12 
     213         
     214        SetVariable setvar0,pos={208,149},size={160,16},proc=sliceSelectEvent_Proc,title="Display Time Slice" 
     215        SetVariable setvar0,fSize=10 
     216        SetVariable setvar0,limits={0,1000,1},value= root:Packages:NIST:gEvent_tsdisp    
     217        SetVariable setvar1,pos={206,26},size={160,16},title="Number of slices",fSize=10 
     218        SetVariable setvar1,limits={1,1000,1},value= root:Packages:NIST:gEvent_nslices 
     219        SetVariable setvar2,pos={206,51},size={160,16},title="Max Time (s)",fSize=10 
     220        SetVariable setvar2,value= root:Packages:NIST:gEvent_t_longest 
     221         
     222        PopupMenu popup0,pos={206,74},size={119,20},proc=BinTypePopMenuProc,title="Bin Spacing" 
     223        PopupMenu popup0,fSize=10 
     224        PopupMenu popup0,mode=1,popvalue="Equal",value= #"\"Equal;Fibonacci;Custom;\"" 
     225 
     226        Button button10,pos={488,305},size={100,20},proc=SplitFileButtonProc,title="Split Big File" 
     227        Button button14,pos={488,350},size={130,20},proc=Stream_LoadDecim,title="Load From List" 
     228        SetVariable setvar3,pos={487,378},size={150,16},title="Decimation factor" 
     229        SetVariable setvar3,fSize=10 
     230        SetVariable setvar3,limits={1,inf,1},value= root:Packages:NIST:Event:gDecimation 
     231 
     232        Button button15_0,pos={488,425},size={110,20},proc=AccumulateSlicesButton,title="Add First Slice" 
     233        Button button16_1,pos={488,450},size={110,20},proc=AccumulateSlicesButton,title="Add Next Slice" 
     234        Button button17_2,pos={620,425},size={110,20},proc=AccumulateSlicesButton,title="Display Total" 
     235 
     236 
     237        CheckBox chkbox1_0,pos={25,34},size={69,14},title="Oscillatory",fSize=10 
     238        CheckBox chkbox1_0,mode=1,proc=EventModeRadioProc,value=1 
     239        CheckBox chkbox1_1,pos={25,59},size={53,14},title="Stream",fSize=10 
     240        CheckBox chkbox1_1,proc=EventModeRadioProc,value=0,mode=1 
     241        CheckBox chkbox1_2,pos={104,59},size={53,14},title="TISANE",fSize=10 
     242        CheckBox chkbox1_2,proc=EventModeRadioProc,value=0,mode=1 
     243        CheckBox chkbox1_3,pos={104,34},size={37,14},title="TOF",fSize=10 
     244        CheckBox chkbox1_3,proc=EventModeRadioProc,value=0,mode=1 
     245         
     246        GroupBox group0_0,pos={5,5},size={174,112},title="Mode",fSize=12,fStyle=1 
     247        GroupBox group0_1,pos={192,5},size={192,123},title="Binning",fSize=12,fStyle=1 
     248        GroupBox group0_2,pos={403,5},size={173,109},title="Viewing",fSize=12,fStyle=1 
     249        GroupBox group0_3,pos={476,169},size={277,92},title="Editing",fSize=12,fStyle=1 
     250        GroupBox group0_4,pos={474,278},size={279,200},title="Big Files",fSize=12 
     251        GroupBox group0_4,fStyle=1 
     252         
     253        Display/W=(10,170,460,610)/HOST=#  
     254        AppendImage/T :Packages:NIST:Event:dispsliceData 
     255        ModifyImage dispsliceData ctab= {*,*,ColdWarm,0} 
     256        ModifyImage dispsliceData ctabAutoscale=3 
    201257        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    202258        ModifyGraph mirror=2 
     
    208264        ModifyGraph btLen=3 
    209265        ModifyGraph tlOffset=-2 
    210         SetAxis/A left 
     266        RenameWindow #,Event_slicegraph 
    211267        SetActiveSubwindow ## 
    212268EndMacro 
    213269 
     270 
     271 
     272 
     273// mode selector 
     274//Static Constant MODE_STREAM = 0 
     275//Static Constant MODE_OSCILL = 1 
     276//Static Constant MODE_TISANE = 2 
     277//Static Constant MODE_TOF = 3 
     278// 
     279Function EventModeRadioProc(name,value) 
     280        String name 
     281        Variable value 
     282         
     283        NVAR gEventModeRadioVal= root:Packages:NIST:gEvent_mode 
     284         
     285        strswitch (name) 
     286                case "chkbox1_0": 
     287                        gEventModeRadioVal= MODE_OSCILL 
     288                        break 
     289                case "chkbox1_1": 
     290                        gEventModeRadioVal= MODE_STREAM 
     291                        break 
     292                case "chkbox1_2": 
     293                        gEventModeRadioVal= MODE_TISANE 
     294                        break 
     295                case "chkbox1_3": 
     296                        gEventModeRadioVal= MODE_TOF 
     297                        break 
     298        endswitch 
     299        CheckBox chkbox1_0,value= gEventModeRadioVal==MODE_OSCILL 
     300        CheckBox chkbox1_1,value= gEventModeRadioVal==MODE_STREAM 
     301        CheckBox chkbox1_2,value= gEventModeRadioVal==MODE_TISANE 
     302        CheckBox chkbox1_3,value= gEventModeRadioVal==MODE_TOF 
     303 
     304        return(0) 
     305End 
    214306 
    215307Function AdjustEventDataButtonProc(ba) : ButtonControl 
     
    363455        NVAR mode=root:Packages:NIST:gEvent_Mode 
    364456         
    365         if(mode == 0) 
     457        if(mode == MODE_STREAM) 
    366458                Stream_ProcessEventLog("") 
    367459        endif 
    368460         
    369         if(mode == 1) 
     461        if(mode == MODE_OSCILL) 
    370462                Osc_ProcessEventLog("") 
    371463        endif 
     
    776868// 
    777869// Would TISANE or TOF need a different loader? 
    778 // 
     870//       
    779871Function LoadEventLog_Button(ctrlName) : ButtonControl 
    780872        String ctrlName 
     
    782874        NVAR mode=root:Packages:NIST:gEvent_mode 
    783875        Variable err=0 
    784          
    785         if(mode == 0) 
    786                 err = Stream_LoadEventLog("") 
    787                 if(err == 1) 
    788                         return(0)               // user cancelled from file load 
    789                 endif 
    790         endif 
    791          
    792         if(mode == 1) 
    793                 err = Osc_LoadEventLog("") 
    794                 if(err == 1) 
    795                         return(0)               // user cancelled from file load 
    796                 endif 
    797         endif 
    798  
    799         STRUCT WMButtonAction ba 
    800         ba.eventCode = 2 
    801         ShowEventDataButtonProc(ba) 
    802  
    803         return(0) 
    804 End 
    805  
    806 // for the mode of "one continuous exposure" 
    807 // 
    808 Function Stream_LoadEventLog(ctrlName) 
    809         String ctrlName 
    810          
    811         Variable fileref 
     876        Variable fileref,totBytes 
     877        Variable fileTooLarge = 150             //limit load to 150MB 
    812878 
    813879        SVAR filename = root:Packages:NIST:gEvent_logfile 
     
    816882         
    817883        String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 
     884        String abortStr 
    818885         
    819886        Open/R/D/F=fileFilters fileref 
     
    824891                return(1) 
    825892        endif 
     893         
     894/// Abort if the files are too large 
     895        Open/R fileref as fileName 
     896                FStatus fileref 
     897        Close fileref 
     898 
     899        totBytes = V_logEOF/1e6         //in MB 
     900        if(totBytes > fileTooLarge) 
     901                sprintf abortStr,"File is %g MB, larger than the limit of %g MB. Split and Decimate.",totBytes,fileTooLarge 
     902                Abort abortStr 
     903        endif 
     904         
    826905 
    827906#if (exists("EventLoadWave")==4) 
     
    833912        SetDataFolder root:Packages:NIST:Event: 
    834913 
    835 tic() 
     914//tic() 
    836915        Wave timePt=timePt 
    837916        Wave xLoc=xLoc 
    838917        Wave yLoc=yLoc 
    839         CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes 
    840          
    841 toc() 
    842  
    843         Duplicate/O timePt rescaledTime 
    844         rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
    845         t_longest = waveMax(rescaledTime)               //should be the last point 
     918        CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes  
     919//toc() 
     920         
     921         
     922///// 
     923// now do a little processing of the times based on the type of data 
     924//       
     925        if(mode == MODE_STREAM)         // continuous "Stream" mode - start from zero 
     926                Duplicate/O timePt rescaledTime 
     927                rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
     928                t_longest = waveMax(rescaledTime)               //should be the last point       
     929        endif 
     930         
     931        if(mode == MODE_OSCILL)         // oscillatory mode - don't adjust the times, we get periodic t0 to reset t=0 
     932                Duplicate/O timePt rescaledTime 
     933                rescaledTime *= 1e-7                    //convert to seconds and that's all 
     934                t_longest = waveMax(rescaledTime)               //if oscillatory, won't be the last point, so get it this way 
     935         
     936                KillWaves/Z OscSortIndex                        //to make sure that there is no old index hanging around 
     937        endif 
     938 
     939 
    846940 
    847941        SetDataFolder root: 
    848942 
     943        STRUCT WMButtonAction ba 
     944        ba.eventCode = 2 
     945        ShowEventDataButtonProc(ba) 
     946 
    849947        return(0) 
    850948End 
    851949 
    852 // for the mode "oscillatory" 
    853 // 
    854 Function Osc_LoadEventLog(ctrlName) 
    855         String ctrlName 
    856          
    857         Variable fileref 
    858  
    859         SVAR filename = root:Packages:NIST:gEvent_logfile 
    860         NVAR nslices = root:Packages:NIST:gEvent_nslices 
    861         NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
    862          
    863         String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 
    864          
    865         Open/R/D/F=fileFilters fileref 
    866         filename = S_filename 
    867                 if(strlen(S_filename) == 0) 
    868                 // user cancelled 
    869                 DoAlert 0,"No file selected, no file loaded." 
    870                 return(1) 
    871         endif 
    872          
    873 #if (exists("EventLoadWave")==4) 
    874         LoadEvents_XOP() 
    875 #else 
    876         LoadEvents() 
    877 #endif   
    878          
    879         SetDataFolder root:Packages:NIST:Event: 
    880  
    881         Wave timePt=timePt 
    882         Wave xLoc=xLoc 
    883         Wave yLoc=yLoc 
    884         CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes 
    885          
    886         Duplicate/O timePt rescaledTime 
    887         rescaledTime *= 1e-7                    //convert to seconds and that's all 
    888         t_longest = waveMax(rescaledTime)               //if oscillatory, won't be the last point, so get it this way 
    889  
    890         KillWaves/Z OscSortIndex                        //to make sure that there is no old index hanging around 
    891  
    892         SetDataFolder root: 
    893  
    894         return(0) 
    895 End 
     950//// for the mode of "one continuous exposure" 
     951//// 
     952//Function Stream_LoadEventLog(ctrlName) 
     953//      String ctrlName 
     954//       
     955//      Variable fileref 
     956// 
     957//      SVAR filename = root:Packages:NIST:gEvent_logfile 
     958//      NVAR nslices = root:Packages:NIST:gEvent_nslices 
     959//      NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
     960//       
     961//      String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 
     962//       
     963//      Open/R/D/F=fileFilters fileref 
     964//      filename = S_filename 
     965//      if(strlen(S_filename) == 0) 
     966//              // user cancelled 
     967//              DoAlert 0,"No file selected, no file loaded." 
     968//              return(1) 
     969//      endif 
     970// 
     971//#if (exists("EventLoadWave")==4) 
     972//      LoadEvents_XOP() 
     973//#else 
     974//      LoadEvents() 
     975//#endif         
     976// 
     977//      SetDataFolder root:Packages:NIST:Event: 
     978// 
     979////tic() 
     980//      Wave timePt=timePt 
     981//      Wave xLoc=xLoc 
     982//      Wave yLoc=yLoc 
     983//      CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes 
     984//       
     985////toc() 
     986// 
     987//      Duplicate/O timePt rescaledTime 
     988//      rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
     989//      t_longest = waveMax(rescaledTime)               //should be the last point 
     990// 
     991//      SetDataFolder root: 
     992// 
     993//      return(0) 
     994//End 
     995// 
     996//// for the mode "oscillatory" 
     997//// 
     998//Function Osc_LoadEventLog(ctrlName) 
     999//      String ctrlName 
     1000//       
     1001//      Variable fileref 
     1002// 
     1003//      SVAR filename = root:Packages:NIST:gEvent_logfile 
     1004//      NVAR nslices = root:Packages:NIST:gEvent_nslices 
     1005//      NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
     1006//       
     1007//      String fileFilters = "All Files:.*;Data Files (*.txt):.txt;" 
     1008//       
     1009//      Open/R/D/F=fileFilters fileref 
     1010//      filename = S_filename 
     1011//              if(strlen(S_filename) == 0) 
     1012//              // user cancelled 
     1013//              DoAlert 0,"No file selected, no file loaded." 
     1014//              return(1) 
     1015//      endif 
     1016//       
     1017//#if (exists("EventLoadWave")==4) 
     1018//      LoadEvents_XOP() 
     1019//#else 
     1020//      LoadEvents() 
     1021//#endif         
     1022//       
     1023//      SetDataFolder root:Packages:NIST:Event: 
     1024// 
     1025//      Wave timePt=timePt 
     1026//      Wave xLoc=xLoc 
     1027//      Wave yLoc=yLoc 
     1028//      CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes 
     1029//       
     1030//      Duplicate/O timePt rescaledTime 
     1031//      rescaledTime *= 1e-7                    //convert to seconds and that's all 
     1032//      t_longest = waveMax(rescaledTime)               //if oscillatory, won't be the last point, so get it this way 
     1033// 
     1034//      KillWaves/Z OscSortIndex                        //to make sure that there is no old index hanging around 
     1035// 
     1036//      SetDataFolder root: 
     1037// 
     1038//      return(0) 
     1039//End 
    8961040 
    8971041 
     
    10151159        SVAR filepathstr = root:Packages:NIST:gEvent_logfile 
    10161160        SVAR dispStr = root:Packages:NIST:gEventDisplayString 
     1161         
     1162         
     1163////    Variable decFac = 10                    //decimation factor 
     1164////    Variable jj,keep 
    10171165         
    10181166        SetDataFolder root:Packages:NIST:Event 
     
    11231271        Print "num2 = ",num2     
    11241272        Print "num3 = ",num3     
    1125          
     1273 
    11261274// 
    11271275//       
     
    11521300        Make/O/U/N=(numXYevents) xLoc,yLoc 
    11531301        Make/O/D/N=(numXYevents) timePt 
     1302////    Make/O/U/N=(numXYevents/decFac) xLoc,yLoc 
     1303////    Make/O/D/N=(numXYevents/decFac) timePt 
    11541304//      Make/O/U/N=(totBytes/4) xLoc,yLoc               //too large, trim when done (bad idea) 
    11551305//      Make/O/D/N=(totBytes/4) timePt 
     
    11741324        tic() 
    11751325         
    1176         ii = 0 
     1326        ii = 0          //indexes the points in xLoc,yLoc,timePt 
     1327////    keep = decFac           //keep the first point 
     1328         
    11771329         
    11781330        Open/R fileref as filepathstr 
     
    12071359                                endif 
    12081360                                 
    1209                                 // this is the first point, be sure that ii = 0 
    1210                                 ii = 0 
    1211                                 xLoc[ii] = xval 
    1212                                 yLoc[ii] = yval 
    1213                                  
     1361                                // this is the first point, be sure that ii = 0, and always keep this point 
     1362////                            if(keep==decFac) 
     1363                                        ii = 0 
     1364                                        xLoc[ii] = xval 
     1365                                        yLoc[ii] = yval 
     1366////                                    keep = 0 
     1367////                            endif 
    12141368                                Print "At beginning of file, numBad = ",numBad 
    12151369                                break   // the next do loop processes the bulk of the file (** the next event == type 1 = MIR) 
     
    12241378         
    12251379        // now read the main portion of the file. 
     1380////    // keep is = 0 if bad points were removed, or is decFac is I need to keep the first point 
    12261381        do 
    12271382                do 
     
    12291384                while(strlen(buffer) == 1)               
    12301385 
    1231                 if (strlen(buffer) == 0) 
     1386                if (strlen(buffer) == 0)                                // this marks the end of the file and is our only way out 
    12321387                        break 
    12331388                endif 
     
    13031458                                        else 
    13041459                                                // time_msw has been reset, points are good now, so keep this one 
     1460////                                            if(keep==decFac) 
     1461                                                        xLoc[ii] = xval 
     1462                                                        yLoc[ii] = yval 
     1463                                                        timePt[ii] = timeval 
     1464                                                         
     1465        //                                              if(xval == 127 && yval == 0) 
     1466        //                                                      // check bit 29 
     1467        //                                                      bit29 = (dataval & 0x20000000)/536870912                //bit 29 only , shift by 2^29 
     1468        //                                                      Print "XY=127,0 : bit29 = ",bit29 
     1469        //                                              endif 
     1470                                                         
     1471                                                        ii+=1 
     1472                                                        rolloverHappened = 0 
     1473////                                                    keep = 0 
     1474////                                            else 
     1475////                                                    keep += 1 
     1476////                                            endif 
     1477                                        endif 
     1478                                else 
     1479                                        // normal processing of good point, keep it 
     1480////                                    if(keep==decFac) 
    13051481                                                xLoc[ii] = xval 
    13061482                                                yLoc[ii] = yval 
    13071483                                                timePt[ii] = timeval 
    1308                                                  
    1309 //                                              if(xval == 127 && yval == 0) 
    1310 //                                                      // check bit 29 
    1311 //                                                      bit29 = (dataval & 0x20000000)/536870912                //bit 29 only , shift by 2^29 
    1312 //                                                      Print "XY=127,0 : bit29 = ",bit29 
    1313 //                                              endif 
    1314                                                  
     1484                                         
     1485        //                                      if(xval == 127 && yval == 0) 
     1486        //                                              // check bit 29 
     1487        //                                              bit29 = (dataval & 0x20000000)/536870912                //bit 29 only , shift by 2^29 
     1488        //                                              Printf "XY=127,0 : bit29 = %u : d=%u\r",bit29,dataval 
     1489        //                                      endif 
    13151490                                                ii+=1 
    1316                                                 rolloverHappened = 0 
    1317                                         endif 
    1318                                 else 
    1319                                         // normal processing of good point, keep it 
    1320                                         xLoc[ii] = xval 
    1321                                         yLoc[ii] = yval 
    1322                                         timePt[ii] = timeval 
    1323                                  
    1324 //                                      if(xval == 127 && yval == 0) 
    1325 //                                              // check bit 29 
    1326 //                                              bit29 = (dataval & 0x20000000)/536870912                //bit 29 only , shift by 2^29 
    1327 //                                              Printf "XY=127,0 : bit29 = %u : d=%u\r",bit29,dataval 
    1328 //                                      endif 
    1329                                         ii+=1 
     1491////                                            keep = 0 
     1492////                                    else 
     1493////                                            keep += 1 
     1494////                                    endif 
    13301495                                endif 
    13311496 
     
    13661531                                endif 
    13671532                                 
    1368                                 xLoc[ii] = xval 
    1369                                 yLoc[ii] = yval 
    1370  
     1533////                            if(keep==decFac)                        //don't reset keep yet, do this only when ii increments 
     1534                                        xLoc[ii] = xval 
     1535                                        yLoc[ii] = yval 
     1536////                            endif 
     1537                                 
    13711538                                // don't fill in the time yet, or increment the index ii 
    13721539                                // the next event MUST be ATMIR with the MSW time bits 
     
    13901557                                 
    13911558                                // the XY position was in the previous event ATXYM 
    1392                                 timePt[ii] = timeval 
     1559////                            if(keep == decFac) 
     1560                                        timePt[ii] = timeval 
     1561////                            endif 
    13931562 
    13941563                                bit29 = (dataval & 0x20000000)/536870912                //bit 29 only , shift by 2^29 
     
    14011570                                        nRoll = 0 
    14021571                                endif 
    1403                                                                  
    1404                                 ii+=1 
     1572                                 
     1573////                            if(keep == decFac)                       
     1574                                        ii+=1 
     1575////                                    keep = 0 
     1576////                            endif 
    14051577//                              verbose = 0 
    14061578                                break 
     
    14521624        Print "Events removed (Igor) = ",numRemoved 
    14531625         
    1454         sPrintf tmpStr,"\rBad Rollover Events = %d (%g %% of events)",numBad,numBad/numXYevents*100 
     1626        sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 
    14551627        dispStr += tmpStr 
    1456         sPrintf tmpStr,"\rTotal Events Removed = %d (%g %% of events)",numRemoved,numRemoved/numXYevents*100 
     1628        sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 
    14571629        dispStr += tmpStr 
    14581630        SetDataFolder root: 
     
    16261798        Print "Events removed (XOP) = ",numRemoved 
    16271799         
    1628         sPrintf tmpStr,"\rBad Rollover Events = %d (%g %% of events)",numBad,numBad/numXYevents*100 
     1800        sPrintf tmpStr,"\rBad Rollover Events = %d (%4.4g %% of events)",numBad,numBad/numXYevents*100 
    16291801        dispStr += tmpStr 
    1630         sPrintf tmpStr,"\rTotal Events Removed = %d (%g %% of events)",numRemoved,numRemoved/numXYevents*100 
     1802        sPrintf tmpStr,"\rTotal Events Removed = %d (%4.4g %% of events)",numRemoved,numRemoved/numXYevents*100 
    16311803        dispStr += tmpStr 
    16321804 
     
    19492121        ControlBar 100 
    19502122        Button button0,pos={18,12},size={70,20},proc=EC_AddCursorButtonProc,title="Cursors" 
    1951         Button button1,pos={153,11},size={80,20},proc=EC_AddTimeButtonProc,title="Add time" 
    1952         Button button2,pos={153,37},size={80,20},proc=EC_SubtractTimeButtonProc,title="Subtr time" 
     2123        Button button1,pos={153,12},size={80,20},proc=EC_AddTimeButtonProc,title="Add time" 
     2124        Button button2,pos={153,38},size={80,20},proc=EC_SubtractTimeButtonProc,title="Subtr time" 
    19532125        Button button3,pos={153,64},size={90,20},proc=EC_TrimPointsButtonProc,title="Trim points" 
    1954         Button button4,pos={295,12},size={90,20},proc=EC_SaveWavesButtonProc,title="Save Waves" 
    1955         Button button5,pos={294,38},size={100,20},proc=EC_ImportWavesButtonProc,title="Import Waves" 
    1956         Button button6,pos={18,39},size={80,20},proc=EC_ShowAllButtonProc,title="All Data" 
    1957         Button button7,pos={683,9},size={30,20},proc=EC_HelpButtonProc,title="?" 
     2126        Button button4,pos={295+200,12},size={90,20},proc=EC_SaveWavesButtonProc,title="Save Waves" 
     2127        Button button5,pos={295+200,38},size={100,20},proc=EC_ImportWavesButtonProc,title="Import Waves" 
     2128        Button button6,pos={18,38},size={80,20},proc=EC_ShowAllButtonProc,title="All Data" 
     2129        Button button7,pos={683,12},size={30,20},proc=EC_HelpButtonProc,title="?" 
    19582130        Button button8,pos={658,72},size={60,20},proc=EC_DoneButtonProc,title="Done" 
     2131 
     2132        Button button9,pos={295,12},size={110,20},proc=EC_FindStepButton_down,title="Find Step Down" 
     2133        Button button10,pos={295,38},size={110,20},proc=EC_FindStepButton_up,title="Find Step Up" 
     2134        Button button11,pos={295,64},size={110,20},proc=EC_DoDifferential,title="Differential" 
    19592135         
    19602136        SetDataFolder root: 
     
    21002276                        Wave xLoc = xLoc 
    21012277                        Wave yLoc = yLoc 
    2102                         Save/T xLoc,yLoc,timePt                 //will ask for a name 
     2278                        Save/T xLoc,yLoc,timePt ,rescaledTime           //will ask for a name 
    21032279                         
    21042280                        SetDataFolder root: 
     
    21392315                        KillWaves/Z OscSortIndex 
    21402316                        Wave timePt=timePt 
    2141  
    2142                         Duplicate/O timePt rescaledTime 
    2143                         if(mode==0) 
    2144                                 rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
    2145                         else 
    2146                                 rescaledTime = timePt*1e-7                                              //just take the times as-is 
    2147                         endif 
     2317                        Wave rescaledTime=rescaledTime 
     2318 
     2319//                      Duplicate/O timePt rescaledTime 
     2320//                      if(mode==MODE_STREAM) 
     2321//                              rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
     2322//                      else 
     2323//                              rescaledTime = timePt*1e-7                                              //just take the times as-is 
     2324//                      endif 
    21482325                         
    21492326                        t_longest = waveMax(rescaledTime)               //should be the last point 
     
    22082385End 
    22092386 
    2210  
    2211  
     2387//upDown 5 or -5 looks for spikes +5 or -5 std deviations from mean 
     2388Function PutCursorsAtStep(upDown) 
     2389        Variable upDown 
     2390         
     2391        SetDataFolder root:Packages:NIST:Event: 
     2392 
     2393        Wave rescaledTime=rescaledTime 
     2394        Wave rescaledTime_DIF=rescaledTime_DIF 
     2395        Variable avg,pt,zoom 
     2396         
     2397        zoom = 200              //points in each direction 
     2398         
     2399        WaveStats/Q rescaledTime_DIF 
     2400        avg = V_avg 
     2401         
     2402         
     2403        FindLevel/P/Q rescaledTime_DIF avg*upDown 
     2404        if(V_flag==0) 
     2405                pt = V_levelX 
     2406                WaveStats/Q/R=[pt-zoom,pt+zoom] rescaledTime            // find the max/min y-vallues within the point range 
     2407        else 
     2408                Print "Level not found" 
     2409                return(0) 
     2410        endif 
     2411         
     2412        Variable loLeft,hiLeft, loBottom,hiBottom 
     2413        loLeft = V_min*0.98             //+/- 2% 
     2414        hiLeft = V_max*1.02 
     2415         
     2416        SetAxis left loLeft,hiLeft 
     2417        SetAxis bottom pnt2x(rescaledTime,pt-zoom),pnt2x(rescaledTime,pt+zoom) 
     2418         
     2419        Cursor/P A rescaledTime pt+2    //at the point 
     2420        Cursor/P B rescaledTime numpnts(rescaledTime)-1         //at the end 
     2421 
     2422        SetDataFolder root: 
     2423 
     2424        return(0) 
     2425End 
     2426 
     2427 
     2428Function EC_FindStepButton_down(ctrlName) : ButtonControl 
     2429        String ctrlName 
     2430         
     2431        Variable upDown = -5 
     2432        PutCursorsAtStep(upDown) 
     2433 
     2434        return(0) 
     2435end 
     2436 
     2437 
     2438Function EC_FindStepButton_up(ctrlName) : ButtonControl 
     2439        String ctrlName 
     2440         
     2441        Variable upDown = 5 
     2442        PutCursorsAtStep(upDown) 
     2443 
     2444        return(0) 
     2445end 
     2446 
     2447 
     2448Function EC_DoDifferential(ctrlName) : ButtonControl 
     2449        String ctrlName 
     2450         
     2451        DifferentiatedTime() 
     2452        DoWindow/F EventCorrectionPanel 
     2453         
     2454        //if trace is not on graph, add it 
     2455        SetDataFolder root:Packages:NIST:Event: 
     2456 
     2457        String list = WaveList("*_DIF", ";", "WIN:EventCorrectionPanel") 
     2458        if(strlen(list) == 0) 
     2459                AppendToGraph/R rescaledTime_DIF 
     2460                ModifyGraph msize=1,rgb(rescaledTime_DIF)=(65535,0,0) 
     2461                ReorderTraces rescaledTime,{rescaledTime_DIF}           // put the differential behind the event data 
     2462        endif 
     2463        SetDataFolder root: 
     2464        return(0) 
     2465end 
    22122466 
    22132467//////////////   Custom Bins  ///////////////////// 
     
    22692523        SetVariable setvar1,pos={23,13},size={160,20},title="Number of slices",fSize=12 
    22702524        SetVariable setvar1,proc=CB_NumSlicesSetVarProc,value=root:Packages:NIST:gEvent_nslices 
    2271         SetVariable setvar2,pos={24,44},size={160,20},title="Max Time (s)",fSize=12 
     2525        SetVariable setvar2,pos={24,44},size={160,20},title="Max Time (s)",fSize=10 
    22722526        SetVariable setvar2,value=root:Packages:NIST:gEvent_t_longest    
    22732527 
     
    25052759        Prompt baseStr,"File prefix, number will be appended" 
    25062760         
     2761         
    25072762        fSplitBigFile(splitSize, baseStr) 
    2508 End 
    2509  
    2510 Function fSplitBigFile(splitSize, baseStr) 
     2763         
     2764End 
     2765 
     2766Function/S fSplitBigFile(splitSize, baseStr) 
    25112767        Variable splitSize 
    25122768        String baseStr           
     
    25172773        Variable refNum 
    25182774        String str 
     2775        SVAR listStr = root:Packages:NIST:Event:gSplitFileList 
     2776         
     2777        listStr=""              //initialize output list 
    25192778 
    25202779        Variable readSize=1e6           //1 MB 
     
    25222781        Variable numSplit 
    25232782        Variable num,ii,jj,outRef,frac 
    2524         String thePath 
     2783        String thePath, outStr 
    25252784         
    25262785        Printf "SplitSize = %u MB\r",splitSize 
     
    25302789        // Open file for read. 
    25312790        Open/R/Z=2/F="????"/P=$pathName refNum as fileName 
    2532         thePath = ParseFilePath(1, fileName, ":", 1, 0) 
     2791        thePath = ParseFilePath(1, S_fileName, ":", 1, 0) 
     2792        Print "thePath = ",thePath 
    25332793         
    25342794        // Store results from Open in a safe place. 
     
    25382798        if (err == -1) 
    25392799                Print "cancelled by user." 
    2540                 return -1 
     2800                return ("") 
    25412801        endif 
    25422802 
     
    25652825        Printf "frac = %u\r",frac 
    25662826         
    2567         baseStr = "split" 
     2827//      baseStr = "split" 
    25682828         
    25692829        for(ii=0;ii<numSplit;ii+=1) 
    2570                 Open outRef as (thePath+baseStr+num2str(ii)) 
     2830                outStr = (thePath+baseStr+num2str(ii)) 
     2831//              Print "outStr = ",outStr 
     2832                Open outRef as outStr 
    25712833 
    25722834                for(jj=0;jj<(splitSize/readSize);jj+=1) 
     
    25762838 
    25772839                Close outRef 
     2840                listStr += outStr+";" 
    25782841        endfor 
    25792842 
    25802843        Make/O/B/U/N=(frac) leftover 
    25812844        // ii was already incremented past the loop 
    2582         Open outRef as (thePath+baseStr+num2str(ii)) 
     2845        outStr = (thePath+baseStr+num2str(ii)) 
     2846        Open outRef as outStr 
    25832847        for(jj=0;jj<num;jj+=1) 
    25842848                FBinRead refNum,aBlob 
     
    25892853 
    25902854        Close outRef 
     2855        listStr += outStr+";" 
    25912856 
    25922857 
     
    25942859        Close refNum 
    25952860         
    2596          
    2597         return 0 
     2861        KillWaves/Z aBlob,leftover 
     2862        return(listStr) 
    25982863End 
    25992864 
     
    26012866 
    26022867//// save the sliced data, and accumulate slices 
    2603 // 
    2604 // need some way of ensuring that the slices match up since I' blindly adding them together. 
    2605 // 
    2606 // 
    2607 //  
     2868//  *** this works with sliced data -- that is data that has been PROCESSED 
     2869// 
     2870// need some way of ensuring that the slices match up since I'm blindly adding them together.  
    26082871// 
    26092872// mode = 0             wipe out the old accumulated, copy slicedData to accumulatedData 
    26102873// mode = 1             add current slicedData to accumulatedData 
    26112874// mode = 2             copy accumulatedData to slicedData in preparation of export or display 
    2612 // mode = 3             sing a song, dance a dance 
    2613 // 
     2875// mode = 3             unused... 
     2876// 
     2877//      "Split Large File",SplitBigFile() 
     2878//      "Accumulate First Slice",AccumulateSlices(0) 
     2879//      "Add Current Slice",AccumulateSlices(1) 
     2880//      "Display Accumulated Slices",AccumulateSlices(2)         
     2881// 
     2882Function AccumulateSlicesButton(ctrlName) : ButtonControl 
     2883        String ctrlName 
     2884         
     2885        Variable mode 
     2886        mode = str2num(ctrlName[strlen(ctrlName)-1]) 
     2887//      Print "mode=",mode 
     2888        AccumulateSlices(mode) 
     2889         
     2890        return(0) 
     2891End 
     2892 
    26142893Function AccumulateSlices(mode) 
    26152894        Variable mode 
     
    26402919        return(0) 
    26412920end 
     2921 
     2922 
     2923//////////////////////////////////////////// 
     2924// 
     2925// Panel and procedures for decimation 
     2926// 
     2927//////////////////////////////////////////// 
     2928 
     2929//Function E_ShowDecimateButton(ctrlName) : ButtonControl 
     2930//      String ctrlName 
     2931// 
     2932//      DoWindow/F DecimatePanel 
     2933//      if(V_flag ==0) 
     2934//              Execute "DecimatePanel()" 
     2935//      endif 
     2936//End 
     2937// 
     2938// 
     2939//Proc DecimatePanel() //: Panel 
     2940//       
     2941//      PauseUpdate; Silent 1           // building window... 
     2942//      NewPanel /W=(1602,44,1961,380)/K=1 
     2943////    ShowTools/A 
     2944//      Button button0,pos={29,15},size={100,20},proc=SplitFileButtonProc,title="Split Big File" 
     2945//      SetVariable setvar0,pos={182,55},size={150,15},title="Decimation factor",fsize=10 
     2946//      SetVariable setvar0,limits={1,inf,1},value= root:Packages:NIST:Event:gDecimation 
     2947//      Button button1,pos={26,245},size={150,20},proc=LoadDecimateButtonProc,title="Load and Decimate" 
     2948//      Button button2,pos={25,277},size={150,20},proc=ConcatenateButtonProc,title="Concatenate" 
     2949//      Button button3,pos={25,305},size={150,20},proc=DisplayConcatenatedButtonProc,title="Display Concatenated" 
     2950//      Button button4,pos={29,52},size={130,20},proc=Stream_LoadDecim,title="Load From List" 
     2951//       
     2952//      GroupBox group0 title="Manual Controls",size={185,112},pos={14,220} 
     2953//EndMacro 
     2954 
     2955 
     2956Function SplitFileButtonProc(ctrlName) : ButtonControl 
     2957        String ctrlName 
     2958 
     2959        Execute "SplitBigFile()" 
     2960End 
     2961 
     2962 
     2963// show all of the data 
     2964// 
     2965Proc ShowDecimatedGraph() 
     2966 
     2967        DoWindow/F DecimatedGraph 
     2968        if(V_flag == 0) 
     2969                PauseUpdate; Silent 1           // building window... 
     2970                String fldrSav0= GetDataFolder(1) 
     2971                SetDataFolder root:Packages:NIST:Event: 
     2972                Display /W=(25,44,486,356)/K=1/N=DecimatedGraph rescaledTime_dec 
     2973                SetDataFolder fldrSav0 
     2974                ModifyGraph mode=4 
     2975                ModifyGraph marker=19 
     2976                ModifyGraph rgb(rescaledTime_dec)=(0,0,0) 
     2977                ModifyGraph msize=1 
     2978                ErrorBars rescaledTime_dec OFF  
     2979                Label left "\\Z14Time (seconds)" 
     2980                Label bottom "\\Z14Event number" 
     2981                ShowInfo 
     2982        endif 
     2983         
     2984EndMacro 
     2985 
     2986// data has NOT been processed 
     2987// 
     2988// so work with x,y,t, and rescaled time 
     2989// variables -- t_longest 
     2990Function ConcatenateButtonProc(ctrlName) : ButtonControl 
     2991        String ctrlName 
     2992         
     2993        DoAlert 1,"Is this the first file?" 
     2994        Variable first = V_flag 
     2995         
     2996        fConcatenateButton(first) 
     2997         
     2998        return(0) 
     2999End 
     3000 
     3001Function fConcatenateButton(first) 
     3002        Variable first 
     3003 
     3004 
     3005        SetDataFolder root:Packages:NIST:Event: 
     3006 
     3007        Wave timePt_dTmp=timePt_dTmp 
     3008        Wave xLoc_dTmp=xLoc_dTmp 
     3009        Wave yLoc_dTmp=yLoc_dTmp 
     3010        Wave rescaledTime_dTmp=rescaledTime_dTmp 
     3011         
     3012        NVAR t_longest_dec = root:Packages:NIST:gEvent_t_longest_decimated 
     3013        NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
     3014         
     3015         
     3016        if(first==1)            //1==yes, 2==no 
     3017                //then copy the files over, adjusting the time to start from zero 
     3018                // rescaledTime starts from zero (set by the loader) 
     3019 
     3020                timePt_dTmp -= timePt_dTmp[0]                   //subtract the first value 
     3021                 
     3022                Duplicate/O timePt_dTmp timePt_dec 
     3023                Duplicate/O xLoc_dTmp xLoc_dec 
     3024                Duplicate/O yLoc_dTmp yLoc_dec 
     3025                Duplicate/O rescaledTime_dTmp rescaledTime_dec 
     3026                 
     3027                t_longest_dec = t_longest 
     3028         
     3029        else 
     3030                // concatenate the files + adjust the time 
     3031                Wave timePt_dec=timePt_dec 
     3032                Wave xLoc_dec=xLoc_dec 
     3033                Wave yLoc_dec=yLoc_dec 
     3034                Wave rescaledTime_dec=rescaledTime_dec 
     3035 
     3036                // adjust the times -- assuming they add 
     3037                // rescaledTime starts from zero (set by the loader) 
     3038                // 
     3039                // 
     3040                rescaledTime_dTmp += rescaledTime_dec[numpnts(rescaledTime_dec)-1] 
     3041                rescaledTime_dTmp += abs(rescaledTime_dec[numpnts(rescaledTime_dec)-1] - rescaledTime_dec[numpnts(rescaledTime_dec)-2]) 
     3042                 
     3043                timePt_dTmp -= timePt_dTmp[0]                   //subtract the first value       
     3044                 
     3045                timePt_dTmp += timePt_dec[numpnts(timePt_dec)-1]                // offset by the last point 
     3046                timePt_dTmp += abs(timePt_dec[numpnts(timePt_dec)-1] - timePt_dec[numpnts(timePt_dec)-2])               // plus delta so there's not a flat step 
     3047                 
     3048                Concatenate/NP/O {timePt_dec,timePt_dTmp}, tmp 
     3049                Duplicate/O tmp timePt_dec 
     3050                 
     3051                Concatenate/NP/O {xLoc_dec,xLoc_dTmp}, tmp 
     3052                Duplicate/O tmp xLoc_dec 
     3053                 
     3054                Concatenate/NP/O {yLoc_dec,yLoc_dTmp}, tmp 
     3055                Duplicate/O tmp yLoc_dec 
     3056                 
     3057                Concatenate/NP/O {rescaledTime_dec,rescaledTime_dTmp}, tmp 
     3058                Duplicate/O tmp rescaledTime_dec 
     3059                 
     3060 
     3061                KillWaves tmp 
     3062 
     3063                t_longest_dec = rescaledTime_dec[numpnts(rescaledTime_dec)-1] 
     3064 
     3065        endif 
     3066         
     3067         
     3068        SetDataFolder root: 
     3069         
     3070        return(0) 
     3071 
     3072End 
     3073 
     3074Function DisplayConcatenatedButtonProc(ctrlName) : ButtonControl 
     3075        String ctrlName 
     3076 
     3077        //copy the files over to the display set for processing 
     3078        SetDataFolder root:Packages:NIST:Event: 
     3079 
     3080        Wave timePt_dec=timePt_dec 
     3081        Wave xLoc_dec=xLoc_dec 
     3082        Wave yLoc_dec=yLoc_dec 
     3083        Wave rescaledTime_dec=rescaledTime_dec 
     3084                 
     3085        NVAR t_longest_dec = root:Packages:NIST:gEvent_t_longest_decimated 
     3086        NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
     3087         
     3088        Duplicate/O timePt_dec timePt 
     3089        Duplicate/O xLoc_dec xLoc 
     3090        Duplicate/O yLoc_dec yLoc 
     3091        Duplicate/O rescaledTime_dec rescaledTime 
     3092         
     3093        t_longest = t_longest_dec        
     3094         
     3095        SetDataFolder root: 
     3096         
     3097        return(0) 
     3098 
     3099End 
     3100 
     3101 
     3102 
     3103 
     3104Function LoadDecimateButtonProc(ctrlName) : ButtonControl 
     3105        String ctrlName 
     3106 
     3107        LoadEventLog_Button("") 
     3108         
     3109        // now decimate 
     3110        SetDataFolder root:Packages:NIST:Event: 
     3111 
     3112        Wave timePt=timePt 
     3113        Wave xLoc=xLoc 
     3114        Wave yLoc=yLoc 
     3115        NVAR t_longest_dec = root:Packages:NIST:gEvent_t_longest_decimated 
     3116 
     3117        NVAR decimation = root:Packages:NIST:Event:gDecimation 
     3118 
     3119 
     3120        Duplicate/O timePt, timePt_dTmp 
     3121        Duplicate/O xLoc, xLoc_dTmp 
     3122        Duplicate/O yLoc, yLoc_dTmp 
     3123        Resample/DOWN=(decimation)/N=1 timePt_dTmp 
     3124        Resample/DOWN=(decimation)/N=1 xLoc_dTmp 
     3125        Resample/DOWN=(decimation)/N=1 yLoc_dTmp 
     3126 
     3127 
     3128        Duplicate/O timePt_dTmp rescaledTime_dTmp 
     3129        rescaledTime_dTmp = 1e-7*(timePt_dTmp - timePt_dTmp[0])         //convert to seconds and start from zero 
     3130        t_longest_dec = waveMax(rescaledTime_dTmp)              //should be the last point 
     3131 
     3132        SetDataFolder root: 
     3133 
     3134         
     3135End 
     3136 
     3137// functions that take file names as arguments so that the loading an be done in batch mode 
     3138// for the mode of "one continuous exposure" 
     3139// 
     3140Function Stream_LoadDecim(ctrlName) 
     3141        String ctrlName 
     3142         
     3143        Variable fileref 
     3144 
     3145        SVAR filename = root:Packages:NIST:gEvent_logfile 
     3146        NVAR t_longest = root:Packages:NIST:gEvent_t_longest 
     3147         
     3148        SVAR listStr = root:Packages:NIST:Event:gSplitFileList 
     3149 
     3150        NVAR t_longest_dec = root:Packages:NIST:gEvent_t_longest_decimated 
     3151        NVAR decimation = root:Packages:NIST:Event:gDecimation 
     3152 
     3153 
     3154 
     3155        //loop through everything in the list 
     3156        Variable num,ii 
     3157        num = ItemsInList(listStr) 
     3158         
     3159        for(ii=0;ii<num;ii+=1) 
     3160 
     3161// (1) load the file             
     3162                filename = StringFromList(ii, listStr  ,";") 
     3163                 
     3164 
     3165#if (exists("EventLoadWave")==4) 
     3166                LoadEvents_XOP() 
     3167#else 
     3168                LoadEvents() 
     3169#endif   
     3170 
     3171                SetDataFolder root:Packages:NIST:Event:                 //LoadEvents sets back to root: 
     3172 
     3173                Wave timePt=timePt 
     3174                Wave xLoc=xLoc 
     3175                Wave yLoc=yLoc 
     3176                CleanupTimes(xLoc,yLoc,timePt)          //remove zeroes 
     3177 
     3178                Duplicate/O timePt rescaledTime 
     3179                rescaledTime = 1e-7*(timePt-timePt[0])          //convert to seconds and start from zero 
     3180                t_longest = waveMax(rescaledTime)               //should be the last point 
     3181                 
     3182// (2) do the decimation, just on timePt. Ignore rescaledTime for now    
     3183                 
     3184                Duplicate/O timePt, timePt_dTmp 
     3185                Duplicate/O xLoc, xLoc_dTmp 
     3186                Duplicate/O yLoc, yLoc_dTmp 
     3187                Resample/DOWN=(decimation)/N=1 timePt_dTmp 
     3188                Resample/DOWN=(decimation)/N=1 xLoc_dTmp 
     3189                Resample/DOWN=(decimation)/N=1 yLoc_dTmp 
     3190         
     3191         
     3192                Duplicate/O timePt_dTmp rescaledTime_dTmp 
     3193                rescaledTime_dTmp = 1e-7*(timePt_dTmp - timePt_dTmp[0])         //convert to seconds and start from zero 
     3194                t_longest_dec = waveMax(rescaledTime_dTmp)              //should be the last point 
     3195                 
     3196 
     3197// (3) concatenate 
     3198                fConcatenateButton(ii+1)                //passes 1 for the first time, >1 each other time 
     3199         
     3200        endfor 
     3201 
     3202////            Now that everything is decimated and concatenated, create the rescaled time wave 
     3203//      SetDataFolder root:Packages:NIST:Event:                 //LoadEvents sets back to root: 
     3204//      Wave timePt_dec = timePt_dec 
     3205//      Duplicate/O timePt_dec rescaledTime_dec 
     3206//      rescaledTime_dec = 1e-7*(timePt_dec - timePt_dec[0])            //convert to seconds and start from zero 
     3207//      t_longest_dec = waveMax(rescaledTime_dec)               //should be the last point 
     3208         
     3209        DisplayConcatenatedButtonProc("") 
     3210         
     3211        SetDataFolder root: 
     3212 
     3213        return(0) 
     3214End 
     3215 
     3216///////////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.