Changeset 881 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- Nov 30, 2012 5:04:56 PM (10 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf
r880 r881 6 6 // TODO: 7 7 // 8 // -- search for TODO for unresolved issues not on this list 9 // 10 // -- add comments to the code as needed 11 // 12 // -- write the help file, and link the help buttons to the help docs 13 // 14 // -- examples? 15 // 16 // -- add the XOP to the distribution package 17 // 8 18 // -- Need to make sure that the rescaledTime and the differentiated time graphs are 9 19 // being properly updated when the data is processed, modified, etc. … … 12 22 // It's all a stream, just sometimes it's not oscillatory 13 23 // 14 // X- fix the log/lin display - it's not working correctly15 // I could use ModifyImage and log = 0|1 keyword for the log Z display16 // rather than creating a duplicate wave of log(data)17 // -- it's in the Function sliceSelectEvent_Proc()18 24 // 19 25 // -- the slice display "fails" for data sets that have 3 or 4 slices, as the ModifyImage command … … 27 33 // points. Maybe not kosher, but would clean things up. 28 34 // 29 // -- Is there any way to improve the speed of the loader? How could an XOP be structured 30 // for maximum flexibility? Leave the post processing to Igor, but how much for the XOP 31 // to do? And can it handle such large amounts of data to pass back and forth, or 32 // does it need to be written as an operation, rather than a function??? I'd really 33 // rather that Igor handles the memory management, not me, if I write the XOP. 34 // 35 // **- as of 11/27, the OSX version of the XOP event loader is about 35x faster for the load! 36 // and is taking approx 1.8s/28MB, or about 6.5s/100MB of file. quite reasonable now, and 37 // probably a bit faster yet on the PC. 38 // 39 // -- memory issues: 35 // 36 ///////// DONE ////////// 37 // 38 // X- memory issues: 40 39 // -- in LoadEvents -- should I change the MAKE to: 41 40 // /I/U is unsigned 32-bit integer (for the time) … … 48 47 // generate only SP waves. this will at least save some space. 49 48 // 49 // 50 // 51 // x- Is there any way to improve the speed of the loader? How could an XOP be structured 52 // for maximum flexibility? Leave the post processing to Igor, but how much for the XOP 53 // to do? And can it handle such large amounts of data to pass back and forth, or 54 // does it need to be written as an operation, rather than a function??? I'd really 55 // rather that Igor handles the memory management, not me, if I write the XOP. 56 // 57 // **- as of 11/27, the OSX version of the XOP event loader is about 35x faster for the load! 58 // and is taking approx 1.8s/28MB, or about 6.5s/100MB of file. quite reasonable now, and 59 // probably a bit faster yet on the PC. 60 // 61 // 62 // X- fix the log/lin display - it's not working correctly 63 // I could use ModifyImage and log = 0|1 keyword for the log Z display 64 // rather than creating a duplicate wave of log(data) 65 // -- it's in the Function sliceSelectEvent_Proc() 66 // 50 67 // X- add controls to show the bar graph 51 68 // x- add popup for selecting the binning type … … 65 82 66 83 // 67 // These are currently defined in the TISANE procedure file. If that file becomes depricated 68 // or is not loaded in, then these lines should be activated, and those in TISANE should also 69 // be re-declared as Static, so they will be local to each procedure 70 // 71 //Static Constant ATXY = 0 72 //Static Constant ATXYM = 2 73 //Static Constant ATMIR = 1 74 //Static Constant ATMAR = 3 75 // 76 //Static Constant USECSPERTICK=0.1 // microseconds 77 //Static Constant TICKSPERUSEC=10 78 //Static Constant XBINS=128 79 //Static Constant YBINS=128 84 // These are also defined in the TISANE procedure file. In both files they are declared 85 // as Static, so they are local to each procedure 86 // 87 Static Constant ATXY = 0 88 Static Constant ATXYM = 2 89 Static Constant ATMIR = 1 90 Static Constant ATMAR = 3 91 92 Static Constant USECSPERTICK=0.1 // microseconds 93 Static Constant TICKSPERUSEC=10 94 Static Constant XBINS=128 95 Static Constant YBINS=128 80 96 // 81 97 … … 154 170 Button button6,pos={378,13},size={40,20},proc=EventModeHelpButtonProc,title="?" 155 171 156 //DrawLine 10,35,490,35157 172 Button button1,pos = {10,50}, size={150,20},title="Process Data",fSize=12 158 173 Button button1,proc=ProcessEventLog_Button … … 161 176 SetVariable setvar2,pos={330,50},size={160,20},title="Max Time (s)",fSize=12 162 177 SetVariable setvar2,value=root:Packages:NIST:gEvent_t_longest 163 //DrawLine 10,65,490,65 164 165 // PopupMenu popup0 title="Bin Spacing",pos={150,90},value="Equal;Fibonacci;Log;" 178 166 179 PopupMenu popup0 title="Bin Spacing",pos={150,90},value="Equal;Fibonacci;Custom;" 167 180 PopupMenu popup0 proc=BinTypePopMenuProc … … 334 347 // now with the number of slices and max time, process the events 335 348 336 337 349 NVAR t_longest = root:Packages:NIST:gEvent_t_longest 338 350 NVAR nslices = root:Packages:NIST:gEvent_nslices … … 373 385 case "Log": // execute if case matches expression 374 386 SetLogBins(binEndTime,timeWidth,nslices,t_longest) 387 break 388 case "Custom": // execute if case matches expression 389 //bins are set by the user on the panel - assume it's good to go 375 390 break 376 391 default: // optional default expression executed … … 500 515 break 501 516 case "Custom": // execute if case matches expression 502 // SetLogBins(binEndTime,nslices,t_longest)517 //bins are set by the user on the panel - assume it's good to go 503 518 break 504 519 default: // optional default expression executed … … 507 522 endswitch 508 523 524 // TODO 525 // the global exists for this switch, but it is not implemented - not sure whether 526 // it's correct to implement this at all -- 527 // 509 528 if(yesSortStream == 1) 510 529 SortTimeData() 511 530 endif 531 512 532 // index the events before binning 513 533 // if there is a sort of these events, I need to re-index the events for the histogram … … 585 605 586 606 587 607 // now before binning, sort the data 608 // 609 //this is slow - undoing the sorting and starting over, but if you don't, 610 // you'll never be able to undo the sort 611 // 588 612 Function SortTimeData() 589 613 590 // now before binning, sort the data 591 592 //this is slow - undoing the sorting and starting over, but if you don't, 593 // you'll never be able to undo the sort 594 // 614 595 615 SetDataFolder root:Packages:NIST:Event: 596 616 597 617 KillWaves/Z OscSortIndex 598 // Print WaveExists($"root:Packages:NIST:Event:OscSortIndex")599 618 600 619 if(WaveExists($"root:Packages:NIST:Event:OscSortIndex") == 0 ) … … 629 648 End 630 649 631 650 // TODO 651 // either get this to work, or scrap it entirely. it currently isn't on the popup 652 // so it can't be accessed 632 653 Function SetLogBins(binEndTime,timeWidth,nslices,t_longest) 633 654 Wave binEndTime,timeWidth … … 700 721 701 722 702 723 // TODO: 724 // 725 // What, if anything is different about the OSC or STREAM load? 726 // I think that only the processing is different. so this could be 727 // consolidated into a single loader. 728 // 729 // Would TISANE or TOF need a different loader? 730 // 703 731 Function LoadEventLog_Button(ctrlName) : ButtonControl 704 732 String ctrlName … … 750 778 751 779 #if (exists("EventLoadWave")==4) 752 753 780 LoadEvents_XOP() 754 755 781 #else 756 757 782 LoadEvents() 758 759 783 #endif 760 784 … … 800 824 801 825 #if (exists("EventLoadWave")==4) 802 803 826 LoadEvents_XOP() 804 805 827 #else 806 807 828 LoadEvents() 808 809 829 #endif 810 830 … … 873 893 874 894 875 895 // TODO 876 896 // this "fails" for data sets that have 3 or 4 slices, as the ModifyImage command 877 897 // interprets the data as being RGB - and so does nothing. … … 935 955 // Print (K0 & 0x20000000)/536870912 //bit 29 only, shift by 2^29 936 956 // 957 // This is duplicated by the XOP, but the Igor code allows quick access to print out 958 // all of the gorey details of the events and every little bit of them. the print 959 // statements and flags are kept for this reason, so the code is a bit messy. 937 960 // 938 961 Function LoadEvents() … … 1047 1070 1048 1071 1049 Print "(Igor) numT0 = ",numT01050 Print "num0 = ",num01051 Print "num1 = ",num11052 Print "num2 = ",num21053 Print "num3 = ",num31072 Print "(Igor) numT0 = ",numT0 1073 Print "num0 = ",num0 1074 Print "num1 = ",num1 1075 Print "num2 = ",num2 1076 Print "num3 = ",num3 1054 1077 1055 1078 // … … 1069 1092 sprintf tmpStr,"numXYevents = %d\r",numXYevents 1070 1093 dispStr += tmpStr 1071 // sprintf tmpStr,"XY = num0 = %d\r",num01072 // dispStr += tmpStr1073 // sprintf tmpStr,"\rXY time = num2 = %d\rtime MSW = num1 = %d",num2,num11074 // dispStr += tmpStr1075 // sprintf tmpStr,"XY time = num2 = %d\r",num21076 // dispStr += tmpStr1077 // sprintf tmpStr,"time MSW = num1 = %d\r",num11078 // dispStr += tmpStr1079 1094 sprintf tmpStr,"PP = %d : ",numPP 1080 1095 dispStr += tmpStr … … 1178 1193 type = (dataval & 0xC0000000)/1073741824 //right shift by 2^30 1179 1194 1195 // 1196 // The defintions of the event types 1180 1197 // 1181 1198 //Constant ATXY = 0 … … 1399 1416 ////////////// 1400 1417 // 1401 // This calls the XOP, as an operation 1418 // This calls the XOP, as an operation to load the events 1419 // 1420 // -- it's about 35x faster than the Igor code, so I guess that's OK. 1402 1421 // 1403 1422 // … … 1484 1503 EventLoadWave/N=EventWave filepathstr 1485 1504 endif 1486 1487 1505 #endif 1488 1506 … … 1538 1556 sprintf tmpStr,"numXYevents = %d\r",numXYevents 1539 1557 dispStr += tmpStr 1540 // sprintf tmpStr,"XY = num0 = %d\r",num01541 // dispStr += tmpStr1542 // sprintf tmpStr,"\rXY time = num2 = %d\rtime MSW = num1 = %d",num2,num11543 // dispStr += tmpStr1544 // sprintf tmpStr,"XY time = num2 = %d\r",num21545 // dispStr += tmpStr1546 // sprintf tmpStr,"time MSW = num1 = %d\r",num11547 // dispStr += tmpStr1548 1558 sprintf tmpStr,"PP = %d : ",numPP 1549 1559 dispStr += tmpStr … … 1589 1599 ModifyGraph toMode=1 1590 1600 ModifyGraph useBarStrokeRGB=1 1591 // ModifyGraph log=11592 1601 ModifyGraph standoff=0 1593 1602 SetAxis left 0,* 1594 1603 Label bottom "\\Z14Time (seconds)" 1595 1604 Label left "\\Z14Number of Events" 1596 // SetAxis left 0.1,41891597 // SetAxis bottom 0.0001,180.848531598 1605 endif 1599 1606 End … … 1649 1656 1650 1657 //////// procedures to be able to export the slices as RAW VAX files. 1651 1658 // 1652 1659 // 1- load the raw data file to use the header (it must already be in RAW) 1653 1660 // 1.5- copy the raw data to the temp folder (STO) … … 1755 1762 // -- see the related thread on the mailing list 1756 1763 // 1757 1758 // 1759 // Now see if this can be succesfully applied to the timeslicing data sets 1760 // -- talk to Jeff about what he's gotten implemented, and what's still missing 1761 // - both in timeslicing, and in TISANE 1762 // - un-scale the wave? or make it work as 128x128 1763 1764 Function Setup_JointHistogram() 1765 1766 // tic() 1767 1768 make/D /o/n=1000000 data1=gnoise(1), data2=gnoise(1) 1769 make/D /o/n=(25,25) myHist 1770 setscale x,-3,3,myHist 1771 setscale y,-3,3,myHist 1772 IndexForHistogram(data1,data2,myhist) 1773 Wave index=SavedIndex 1774 JointHistogram(data1,data2,myHist,index) 1775 NewImage myHist 1776 1777 // toc() 1778 1779 End 1764 //Function Setup_JointHistogram() 1765 // 1766 //// tic() 1767 // 1768 // make/D /o/n=1000000 data1=gnoise(1), data2=gnoise(1) 1769 // make/D /o/n=(25,25) myHist 1770 // setscale x,-3,3,myHist 1771 // setscale y,-3,3,myHist 1772 // IndexForHistogram(data1,data2,myhist) 1773 // Wave index=SavedIndex 1774 // JointHistogram(data1,data2,myHist,index) 1775 // NewImage myHist 1776 // 1777 //// toc() 1778 // 1779 //End 1780 1780 1781 1781 … … 1799 1799 1800 1800 1801 // need a way of visualizing the bin spacing / number of bins vs the full time of the data collection 1802 // then set the range of the source to send to the joint histogram operation 1803 // to assign to arrays (or a 3D wave) 1804 // 1805 // -- see my model with the "layered" form factor - or whatever I called it. That shows different 1806 // binning and visualizing as bar graphs. 1807 // 1808 // -- just need to send x2pnt or findLevel, or something similar to define the POINT 1801 // histogram with a point range 1802 // 1803 // x- just need to send x2pnt or findLevel, or something similar to define the POINT 1809 1804 // values 1810 1805 // 1811 // can also speed this up since the index only needs to be done once, so the1806 // x- can also speed this up since the index only needs to be done once, so the 1812 1807 // histogram operation can be done separately, as the bins require 1813 1808 // … … 1867 1862 1868 1863 1869 ///////1870 //// @ IgorExchange1871 ////TicToc1872 ////Posted April 16th, 2009 by bgallarda1873 //// ¥ in Programming 6.10.x1874 //1875 //function tic()1876 // variable/G tictoc = startMSTimer1877 //end1878 //1879 //function toc()1880 // NVAR/Z tictoc1881 // variable ttTime = stopMSTimer(tictoc)1882 // printf "%g seconds\r", (ttTime/1e6)1883 // killvariables/Z tictoc1884 //end1885 //1886 //1887 //Function testTicToc()1888 //1889 // tic()1890 // variable i1891 // For(i=0;i<10000;i+=1)1892 // make/O/N=512 temp = gnoise(2)1893 // FFT temp1894 // Endfor1895 // killwaves/z temp1896 // toc()1897 //End1898 //1899 ////////////////1900 1901 1864 1902 1865 ////////////// Post-processing of the event mode data … … 2093 2056 SetDataFolder root:Packages:NIST:Event: 2094 2057 2095 //SVAR filename = root:Packages:NIST:gEvent_logfile2096 //NVAR nslices = root:Packages:NIST:gEvent_nslices2097 2058 NVAR t_longest = root:Packages:NIST:gEvent_t_longest 2098 2059 SVAR dispStr = root:Packages:NIST:gEventDisplayString … … 2108 2069 endif 2109 2070 2110 2111 2071 Wave timePt=timePt 2112 2072 … … 2176 2136 2177 2137 2178 ////////////// 2179 2180 2181 2138 ////////////// Custom Bins ///////////////////// 2139 // 2140 // 2141 // 2182 2142 // make sure that the bins are defined and the waves exist before 2183 2143 // trying to draw the panel … … 2241 2201 Button button3,pos={500,14},size={90,20},proc=CB_SaveBinsButtonProc,title="Save Bins" 2242 2202 Button button4,pos={500,42},size={100,20},proc=CB_ImportBinsButtonProc,title="Import Bins" 2243 2244 2245 2203 2246 2204 SetDataFolder root:Packages:NIST:Event: 2247 2205 … … 2274 2232 2275 2233 // save the bins - use Igor Text format 2234 // 2276 2235 Function CB_SaveBinsButtonProc(ba) : ButtonControl 2277 2236 STRUCT WMButtonAction &ba -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/TISANE.ipf
r871 r881 6 6 //Functions to deal with TISANE data 7 7 8 Constant ATXY = 09 Constant ATXYM = 210 Constant ATMIR = 111 Constant ATMAR = 312 13 Constant USECSPERTICK=0.1 // microseconds14 Constant TICKSPERUSEC=1015 Constant XBINS=12816 Constant YBINS=1288 Static Constant ATXY = 0 9 Static Constant ATXYM = 2 10 Static Constant ATMIR = 1 11 Static Constant ATMAR = 3 12 13 Static Constant USECSPERTICK=0.1 // microseconds 14 Static Constant TICKSPERUSEC=10 15 Static Constant XBINS=128 16 Static Constant YBINS=128 17 17 18 18 Proc Show_TISANE_Panel()
Note: See TracChangeset
for help on using the changeset viewer.