Changeset 1047
- Timestamp:
- Jun 20, 2017 3:17:19 PM (6 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_EventModeProcessing.ipf
r1046 r1047 2 2 #pragma IgorVersion=6.22 3 3 4 // vers 7.13e 4 // 5 // Event mode prcessing for VSANS 6 // 7 // First pass, getting the basics to work 8 // 9 // -- need TOF processing for wavelength calibration 10 // -- document this so it can be done quickly and easily. 11 // 12 13 14 5 15 6 16 // TODO: … … 39 49 40 50 41 // TODO -- these dimensions are hard-wired and will be wrong half of the time 42 // 43 Static Constant XBINS=48 44 Static Constant YBINS=128 51 // TODO 52 // x- these dimensions are hard-wired (OK) 53 // 54 Constant XBINS=48 55 Constant NTUBES=192 56 Constant YBINS=128 45 57 46 58 Static Constant MODE_STREAM = 0 … … 60 72 61 73 // TODO: 62 // -- need an index table with the tube <-> panel correspondence 74 // x- need an index table with the tube <-> panel correspondence 75 // NO, per Phil, the tube numbering is sequential: 76 // 77 // Based on the numbering 0-191: 78 // group 1 = R (0,47) MatrixOp out = ReverseRows(in) 79 // group 2 = T (48,95) output = slices_T[q][p][r] 80 // group 3 = B (96,143) output = slices_B[XBINS-q-1][YBINS-p-1][r] (reverses rows and columns) 81 // group 4 = L (144,191) MatrixOp out = ReverseCols(in) 82 // 83 // There is a separate function that does the proper flipping to get the panels into the correct orientation 63 84 // 64 85 Function V_Init_Event() … … 169 190 PopupMenu popup0,mode=1,popvalue="Equal",value= #"\"Equal;Fibonacci;Custom;\"" 170 191 Button button1,pos={389,103},size={120,20},fSize=12,proc=V_ProcessEventLog_Button,title="Bin Event Data" 192 193 194 Button button21,pos={580,70},size={120,20},proc=V_SplitToPanels_Button,title="Split to Panels" 195 Button button22,pos={580,90},size={120,20},proc=V_GraphPanels_Button,title="Show Panels" 171 196 172 197 Button button10,pos={488,305},size={100,20},proc=V_SplitFileButtonProc,title="Split Big File",disable=2 … … 216 241 217 242 218 243 Function V_SplitToPanels_Button(ba) : ButtonControl 244 STRUCT WMButtonAction &ba 245 246 switch( ba.eventCode ) 247 case 2: // mouse up 248 // click code here 249 V_SplitBinnedToPanels() 250 // 251 break 252 case -1: // control being killed 253 break 254 endswitch 255 256 return 0 257 End 258 259 Function V_GraphPanels_Button(ba) : ButtonControl 260 STRUCT WMButtonAction &ba 261 262 switch( ba.eventCode ) 263 case 2: // mouse up 264 // click code here 265 Execute "VSANS_EventPanels()" 266 // 267 break 268 case -1: // control being killed 269 break 270 endswitch 271 272 return 0 273 End 219 274 220 275 // mode selector … … 427 482 String ctrlName 428 483 429 Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 484 // Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 485 Make/O/D/N=(NTUBES,YBINS) root:Packages:NIST:VSANS:Event:binnedData 430 486 431 487 Wave binnedData = root:Packages:NIST:VSANS:Event:binnedData … … 440 496 SetDataFolder root:Packages:NIST:VSANS:Event //don't count on the folder remaining here 441 497 442 Make/D/O/N=(XBINS,YBINS,nslices) slicedData 498 // Make/D/O/N=(XBINS,YBINS,nslices) slicedData 499 Make/D/O/N=(NTUBES,YBINS,nslices) slicedData 443 500 444 501 Wave slicedData = slicedData 445 502 Wave rescaledTime = rescaledTime 446 503 Wave timePt = timePt 447 Make/O/D/N=(XBINS,YBINS) tmpData 504 // Make/O/D/N=(XBINS,YBINS) tmpData 505 Make/O/D/N=(NTUBES,YBINS) tmpData 448 506 Make/O/D/N=(nslices+1) binEndTime,binCount 449 507 Make/O/D/N=(nslices) timeWidth … … 490 548 SetDataFolder root:Packages:NIST:VSANS:Event: 491 549 550 s_tic() 492 551 if(WaveExists($"root:Packages:NIST:VSANS:Event:OscSortIndex") == 0 ) 493 552 Duplicate/O rescaledTime OscSortIndex … … 499 558 Endif 500 559 560 printf "sort time = " 561 s_toc() 562 501 563 Wave index = root:Packages:NIST:VSANS:Event:SavedIndex //this is the histogram index 502 564 565 s_tic() 503 566 for(ii=0;ii<nslices;ii+=1) 504 567 if(ii==0) … … 534 597 binCount[ii] = sum(tmpData,-inf,inf) 535 598 endfor 599 printf "histogram time = " 600 s_toc() 536 601 537 602 Duplicate/O slicedData,root:Packages:NIST:VSANS:Event:dispsliceData,root:Packages:NIST:VSANS:Event:logSlicedData … … 556 621 557 622 558 Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 623 // Make/O/D/N=(XBINS,YBINS) root:Packages:NIST:VSANS:Event:binnedData 624 Make/O/D/N=(NTUBES,YBINS) root:Packages:NIST:VSANS:Event:binnedData 559 625 560 626 Wave binnedData = root:Packages:NIST:VSANS:Event:binnedData … … 570 636 SetDataFolder root:Packages:NIST:VSANS:Event //don't count on the folder remaining here 571 637 572 Make/D/O/N=(XBINS,YBINS,nslices) slicedData 638 // Make/D/O/N=(XBINS,YBINS,nslices) slicedData 639 Make/D/O/N=(NTUBES,YBINS,nslices) slicedData 573 640 574 641 Wave slicedData = slicedData 575 642 Wave rescaledTime = rescaledTime 576 Make/O/D/N=(XBINS,YBINS) tmpData 643 // Make/O/D/N=(XBINS,YBINS) tmpData 644 Make/O/D/N=(NTUBES,YBINS) tmpData 577 645 Make/O/D/N=(nslices+1) binEndTime,binCount//,binStartTime 578 646 Make/O/D/N=(nslices) timeWidth … … 865 933 SetDataFolder root:Packages:NIST:VSANS:Event: //GBLoadWave in V_LoadEvents sets back to root: 866 934 867 868 935 // Now, I have tube, location, and timePt (no units yet) 869 936 // assign to the proper panels 870 937 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 // 938 // TODO: 939 // x- (YES - this is MUCH faster) what if I do the JointHistogram first, then break out the blocks of the 940 // 3D sliced data into the individual panels. Then the sort operation could be skipped, 941 // since it would implicitly be done during the histogram operation 942 // x- go back and redimension as needed to get the 128 x 192 histogram to work 943 // x- MatrixOp or a wave assignemt should be able to break up the 3D 944 // 945 946 KillWaves/Z timePt,xLoc,yLoc 947 Duplicate/O eventTime timePt 948 949 // TODO: 950 // x- for processing, initially treat all of the tubes along x, and 128 pixels along y 951 // panels can be transposed later as needed to get the orientation correct 952 953 Duplicate/O tube xLoc 954 Duplicate/O location yLoc 955 956 Redimension/D xLoc,yLoc,timePt 957 958 //s_tic() 959 // V_SortAndSplitEvents() 960 // 961 //Printf "File sort and split time (s) = " 962 //s_toc() 963 880 964 881 965 // … … 886 970 // 887 971 888 V_SwitchTubeGroup(1)972 // V_SwitchTubeGroup(1) 889 973 890 974 // … … 1050 1134 // for the bit shifts, see the decimal-binary conversion 1051 1135 // http://www.binaryconvert.com/convert_unsigned_int.html 1052 // and for 64-bit values: 1136 // 1137 // for 64-bit values: 1053 1138 // http://calc.penjee.com 1054 1139 // … … 1163 1248 Make/O/L/U/N=(num) eventTime //64 bit unsigned 1164 1249 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] 1168 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 1181 1182 endfor 1250 1251 // MultiThread is about 10x faster than the for loop 1252 MultiThread tube = (V_Events[p]) & 0xFF 1253 MultiThread location = (V_Events[p] >> 8 ) & 0xFF 1254 MultiThread eventTime = (V_Events[p] >> 16) 1255 1256 // for(ii=0;ii<num;ii+=1) 1257 // val = V_Events[ii] 1258 // 1259 //// b1 = (val >> 56 ) & 0xFF // = 255, last two bytes, after shifting 1260 //// b2 = (val >> 48 ) & 0xFF 1261 //// btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 1262 // 1263 // b1 = val & 0xFF 1264 // b2 = (val >> 8) & 0xFF 1265 // btime = (val >> 16) 1266 // 1267 // 1268 // tube[ii] = b1 1269 // location[ii] = b2 1270 // eventTime[ii] = btime 1271 // 1272 // endfor 1183 1273 1184 1274 Printf "File decode time (s) = " … … 1602 1692 1603 1693 1694 // this is not used - it now conflicts with the name of a built-in function in Igor 7 1695 // 1604 1696 Function xJointHistogram(w0,w1,hist,index) 1605 1697 wave w0,w1,hist,index … … 1686 1778 1687 1779 ////////////// Post-processing of the event mode data 1780 // 1781 // 1782 // TODO: 1783 // -- this is ALL geared towards ordela event mode data and the 6.7s errors, and bad signal 1784 // I don't know if I'll need any of this for the VSANS event data. 1785 // 1786 // 1688 1787 Proc V_ShowEventCorrectionPanel() 1689 1788 DoWindow/F V_EventCorrectionPanel -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_TubeAdjustments.ipf
r1024 r1047 85 85 End 86 86 87 Proc V_ArrayToTubes(wStr) 88 String wStr 89 90 Variable ii,numTubes=48 91 String str="tube" 92 93 Variable dim0,dim1 94 dim0 = DimSize($wStr,0) 95 dim1 = DimSize($wStr,1) 96 97 Make/O/D/N=128 tube_pixel 98 tube_pixel = p 99 100 101 ii=0 102 do 103 Make/O/D/N=128 $(str+num2str(ii)) 104 105 if(dim0 == 128) 106 $(str+num2str(ii)) = $(wStr)[p][ii] 107 else 108 $(str+num2str(ii)) = $(wStr)[ii][p] 109 endif 110 111 ii+=1 112 while(ii < numTubes) 113 114 End 115 116 87 117 // (2) -- for each of the tubes, find the x-position (in pixels) of each of the (20) peaks 88 118 // -- load the Analysis Package "MultiPeakFit 2" … … 114 144 Proc V_Identify_AllPeaks() 115 145 116 Variable ii,numTubes= 8146 Variable ii,numTubes=48 117 147 String str="tube" 118 148 119 ii= 1120 do 121 V_Identify_Peaks(str+num2str(ii),ii -1)122 ii+=1 123 while(ii <=numTubes)149 ii=0 150 do 151 V_Identify_Peaks(str+num2str(ii),ii) 152 ii+=1 153 while(ii < numTubes) 124 154 125 155 End … … 197 227 Proc V_PlotFit_AllPeaks() 198 228 199 Variable ii,numTubes= 8200 201 ii= 1202 do 203 V_PlotFit_Peaks(ii -1)204 ii+=1 205 while(ii< =numTubes)229 Variable ii,numTubes=48 230 231 ii=0 232 do 233 V_PlotFit_Peaks(ii) 234 ii+=1 235 while(ii<numTubes) 206 236 207 237 End -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Event_Testing.ipf
r1046 r1047 238 238 // -- can this be multithreaded (eliminating the loop)? 239 239 // 240 // MultiThread tube = (w >> 56 ) & 0xFF 241 // MultiThread location = (w >> 48 ) & 0xFF 242 // MultiThread eventTime = val & 0xFFFFFFFFFFFF 243 // 240 // MultiThread tube = (w[p]) & 0xFF 241 // MultiThread location = (w[p] >> 8 ) & 0xFF 242 // MultiThread eventTime = (w[p] >> 16) 243 // 244 // !!!!- yes - for a 35 MB file: 245 // for loop = 4.3 s 246 // MultiThread = 0.35 s 247 // 248 // !!! can I use the bit operations in MatrixOp? 1D waves are valid 249 // to use with MatrixOp. Would it be better than multiThread? 244 250 // 245 251 // … … 262 268 Make/O/L/U/N=(num) eventTime 263 269 Make/O/U/B/N=(num) tube,location //8 bit unsigned 264 265 for(ii=0;ii<num;ii+=1) 266 val = w[ii] 267 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) 275 276 tube[ii] = b1 277 location[ii] = b2 278 eventTime[ii] = btime 279 280 endfor 270 271 MultiThread tube = (w[p]) & 0xFF 272 MultiThread location = (w[p] >> 8 ) & 0xFF 273 MultiThread eventTime = (w[p] >> 16) 274 275 // for(ii=0;ii<num;ii+=1) 276 // val = w[ii] 277 // 278 //// b1 = (val >> 56 ) & 0xFF // = 255, last two bytes, after shifting 279 //// b2 = (val >> 48 ) & 0xFF 280 //// btime = val & 0xFFFFFFFFFFFF // = really big number, last 6 bytes 281 // 282 // b1 = val & 0xFF 283 // b2 = (val >> 8) & 0xFF 284 // btime = (val >> 16) 285 // 286 // tube[ii] = b1 287 // location[ii] = b2 288 // eventTime[ii] = btime 289 // 290 // endfor 281 291 282 292 s_toc() … … 549 559 550 560 561 562 563 564 565 566 551 567 // TODO: 552 568 // … … 564 580 Wave location = location 565 581 Wave tube = tube 566 582 583 Variable t1=ticks 584 Print "sort started" 567 585 Sort tube,tube,eventTime,location 586 print "sort done ",(ticks-t1)/60 568 587 569 588 Variable b1,e1,b2,e2,b3,e3,b4,e4 … … 625 644 // switch the "active" panel to the selected group (1-4) (5 concatenates them all together) 626 645 // 646 647 // 627 648 // copy the set of tubes over to the "active" set that is to be histogrammed 628 649 // and redimension them to be sure that they are double precision … … 638 659 Wave eventTime = $("eventTime"+num2Str(tubeGroup)) 639 660 640 Wave xloc,yLoc,timePt661 Wave/Z xloc,yLoc,timePt 641 662 642 663 KillWaves/Z timePt,xLoc,yLoc 643 Duplicate/O tube xLoc644 Duplicate/O location yLoc645 664 Duplicate/O eventTime timePt 665 666 // TODO: 667 // -- for processing, initially treat all of the tubes along x, and 128 pixels along y 668 // panels can be transposed later as needed to get the orientation correct 669 670 671 // if(tubeGroup == 1 || tubeGroup == 4) 672 // L/R panels, they have tubes along x 673 Duplicate/O tube xLoc 674 Duplicate/O location yLoc 675 // else 676 // // T/B panels, tubes are along y 677 // Duplicate/O tube yLoc 678 // Duplicate/O location xLoc 679 // endif 646 680 647 681 Redimension/D xLoc,yLoc,timePt … … 704 738 705 739 SetDataFolder root: 706 740 return(0) 707 741 end 742 743 744 745 // Based on the numbering 0-191: 746 // group 1 = R (0,47) MatrixOp out = ReverseRows(in) 747 // group 2 = T (48,95) output = slices_T[q][p][r] 748 // group 3 = B (96,143) output = slices_B[XBINS-q-1][YBINS-p-1][r] (reverses rows and columns) 749 // group 4 = L (144,191) MatrixOp out = ReverseCols(in) 750 // 751 // the transformation flips the panel to the view as if the detector was viewed from the sample position 752 // (this is the standard view for SANS and VSANS) 753 // 754 // Takes the data that was binned, and separates it into the 4 detector panels 755 // Waves are 3D waves x-y-time 756 // 757 // MatrixOp may not be necessary for the R/L transformations, but indexing or MatrixOp are both really fast. 758 // 759 // 760 Function V_SplitBinnedToPanels() 761 762 SetDataFolder root:Packages:NIST:VSANS:Event: 763 Wave slicedData = slicedData //this is 3D 764 765 Variable nSlices = DimSize(slicedData,2) 766 767 Make/O/D/N=(XBINS,YBINS,nSlices) slices_R, slices_L, slices_T, slices_B, output 768 769 slices_R = slicedData[p][q][r] 770 slices_T = slicedData[p+48][q][r] 771 slices_B = slicedData[p+96][q][r] 772 slices_L = slicedData[p+144][q][r] 773 774 MatrixOp/O output = ReverseRows(slices_R) 775 slices_R = output 776 777 MatrixOp/O output = ReverseCols(slices_L) 778 slices_L = output 779 780 781 Redimension/N=(YBINS,XBINS,nSlices) output 782 output = slices_T[q][p][r] 783 KillWaves/Z slices_T 784 Duplicate/O output slices_T 785 786 output = slices_B[XBINS-q-1][YBINS-p-1][r] 787 KillWaves/Z slices_B 788 Duplicate/O output slices_B 789 790 KillWaves/Z output 791 SetDataFolder root: 792 793 return(0) 794 End 795 796 797 // simple panel to display the 4 detector panels after the data has been binned and sliced 798 // 799 // TODO: 800 // -- label panels, axes 801 // -- add a way to display different slices (this can still be done on the main panel, all at once) 802 // -- any other manipulations? 803 // 804 805 Proc VSANS_EventPanels() 806 PauseUpdate; Silent 1 // building window... 807 NewPanel /W=(720,45,1530,570)/N=VSANS_EventPanels/K=1 808 DoWindow/C VSANS_EventPanels 809 ModifyPanel fixedSize=1,noEdit =1 810 811 // Display/W=(745,45,945,425)/HOST=# 812 Display/W=(10,45,210,425)/HOST=# 813 AppendImage/T/G=1 :Packages:NIST:VSANS:Event:slices_L // /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 814 ModifyImage slices_L ctab= {*,*,ColdWarm,0} 815 ModifyImage slices_L ctabAutoscale=3 816 ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 817 ModifyGraph mirror=2 818 ModifyGraph nticks=4 819 ModifyGraph minor=1 820 ModifyGraph fSize=9 821 ModifyGraph standoff=0 822 ModifyGraph tkLblRot(left)=90 823 ModifyGraph btLen=3 824 ModifyGraph tlOffset=-2 825 RenameWindow #,Event_slice_L 826 SetActiveSubwindow ## 827 828 // Display/W=(1300,45,1500,425)/HOST=# 829 Display/W=(565,45,765,425)/HOST=# 830 AppendImage/T/G=1 :Packages:NIST:VSANS:Event:slices_R // /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 831 ModifyImage slices_R ctab= {*,*,ColdWarm,0} 832 ModifyImage slices_R ctabAutoscale=3 833 ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 834 ModifyGraph mirror=2 835 ModifyGraph nticks=4 836 ModifyGraph minor=1 837 ModifyGraph fSize=9 838 ModifyGraph standoff=0 839 ModifyGraph tkLblRot(left)=90 840 ModifyGraph btLen=3 841 ModifyGraph tlOffset=-2 842 RenameWindow #,Event_slice_R 843 SetActiveSubwindow ## 844 845 // Display/W=(945,45,1300,235)/HOST=# 846 Display/W=(210,45,565,235)/HOST=# 847 AppendImage/T/G=1 :Packages:NIST:VSANS:Event:slices_T // /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 848 ModifyImage slices_T ctab= {*,*,ColdWarm,0} 849 ModifyImage slices_T ctabAutoscale=3 850 ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 851 ModifyGraph mirror=2 852 ModifyGraph nticks=4 853 ModifyGraph minor=1 854 ModifyGraph fSize=9 855 ModifyGraph standoff=0 856 ModifyGraph tkLblRot(left)=90 857 ModifyGraph btLen=3 858 ModifyGraph tlOffset=-2 859 RenameWindow #,Event_slice_T 860 SetActiveSubwindow ## 861 862 // Display/W=(945,235,1300,425)/HOST=# 863 Display/W=(210,235,565,425)/HOST=# 864 AppendImage/T/G=1 :Packages:NIST:VSANS:Event:slices_B // /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 865 ModifyImage slices_B ctab= {*,*,ColdWarm,0} 866 ModifyImage slices_B ctabAutoscale=3 867 ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 868 ModifyGraph mirror=2 869 ModifyGraph nticks=4 870 ModifyGraph minor=1 871 ModifyGraph fSize=9 872 ModifyGraph standoff=0 873 ModifyGraph tkLblRot(left)=90 874 ModifyGraph btLen=3 875 ModifyGraph tlOffset=-2 876 RenameWindow #,Event_slice_B 877 SetActiveSubwindow ## 878 // 879 880 881 End 882 883
Note: See TracChangeset
for help on using the changeset viewer.