Changeset 941
- Timestamp:
- Jun 4, 2014 4:01:26 PM (8 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_Cubes_Includes.ipf
r936 r941 54 54 end 55 55 Submenu "Automation Examples" 56 "Vary_One_Cyl_Param",Vary_One_Cyl_Param() 57 "Vary_Two_Cyl_Param",Vary_Two_Cyl_Param() 56 58 // "Hexagonal Cylinders" 57 59 // "Conc Sphere Loop" -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_KR_Parser.ipf
r940 r941 373 373 // sld = SLD of cylinder 374 374 // 375 //376 //377 375 // Put this into a panel with the table and the data 378 376 // and fields for all of the inputs … … 414 412 415 413 414 415 416 416 Function KR_Plot1DButtonProc(ba) : ButtonControl 417 417 STRUCT WMButtonAction &ba … … 613 613 614 614 ///////////////////////////////////// 615 // 616 // 617 // for the "manual" fitting 618 // 619 620 Proc Vary_One_Cyl_Param(waveStr,row,percent,numStep) 621 // pick the wave and row and % 622 String waveStr="xx" 623 Variable row=1 624 Variable percent = 105 625 Variable numStep = 10 626 Prompt waveStr,"wave",popup,"xx;yy;zz;rri;hti;rotx;roty;sld;" 627 628 print waveStr 629 630 // dispatch to calculation 631 MultiCyl_Loop($waveStr,row,percent,numStep) 632 633 // plot the chi2_map 634 DoWindow/F MultiCyl_ChiMap 635 if(V_flag==0) 636 MultiCyl_ChiMap() 637 endif 638 639 end 640 641 Function MultiCyl_Loop(w,row,percent,numStep) 642 Wave w 643 Variable row,percent,numStep 644 645 Variable loLim,hiLim,ii,minIndex,minChiSq 646 String folderStr 647 648 Make/O/D/N=(numStep) chi2_map,testVals 649 Wave chi2_map=chi2_map 650 Wave testVals=testVals 651 652 loLim = w[row] - percent*w[row]/100 653 hiLim = w[row] + percent*w[row]/100 654 testVals = loLim + x*(hiLim-loLim)/numStep 655 656 // the experimental data 657 ControlInfo/W=WrapperPanel popup_0 658 folderStr=S_Value 659 // wave references for the data (to pass) 660 String DF="root:"+folderStr+":" 661 662 WAVE yw=$(DF+folderStr+"_i") 663 WAVE xw=$(DF+folderStr+"_q") 664 WAVE sw=$(DF+folderStr+"_s") 665 666 duplicate/o yw, interpCalc,chi2_data 667 Wave chi2_data=chi2_data 668 Wave interpCalc=interpCalc 669 670 STRUCT WMButtonAction ba 671 ba.eventCode = 2 672 673 // loop 674 for(ii=0;ii<numStep;ii+=1) 675 // set the value 676 w[row] = testVals[ii] 677 // generate the structure 678 // 679 KR_GenerateButtonProc(ba) 680 681 // do the calculation 682 KR_DoCalcButtonProc(ba) 683 684 WAVE ival_KR=ival_KR 685 WAVE qval_KR=qval_KR 686 687 interpCalc = interp(xw, qval_KR, ival_KR ) 688 689 // calculate chi-squared 690 chi2_data = (yw-interpCalc)^2 691 chi2_data /= sw^2 692 693 694 Wavestats/Q chi2_data 695 chi2_map[ii] = V_avg * V_npnts 696 // end loop 697 endfor 698 699 // find the best chi squared 700 WaveStats/Q chi2_map 701 // reset the value to the best 702 minIndex = V_minRowLoc 703 w[row] = testVals[minIndex] 704 705 minChiSq = chi2_map[minIndex] 706 print "Minimum chi2 = ",minChiSq 707 708 709 // and then recalculate at the best solution 710 KR_GenerateButtonProc(ba) 711 712 // do the calculation 713 KR_DoCalcButtonProc(ba) 714 715 return(0) 716 End 717 718 Proc MultiCyl_ChiMap() 719 PauseUpdate; Silent 1 // building window... 720 Display /W=(35,44,466,414) chi2_map vs testVals 721 DoWindow/C MultiCyl_ChiMap 722 ModifyGraph mode=4 723 ModifyGraph marker=19 724 ModifyGraph msize=2 725 Label left "chi-squared" 726 Label bottom "test values" 727 end 728 729 //Function testKRPar() 730 // 731 // Variable row, col 732 // String wStr 733 // 734 // getParamFromKRSetup(row,col,wStr) 735 // Print row, col, wStr 736 // 737 // wStr = StringFromList(0, wStr) // some wave "xx.d" 738 // wStr = StringFromList(0, wStr, ".") // removes the ".d" 739 // Wave w=$wStr 740 // print w[row] 741 // 742 // Variable numStep,loLim,hiLim,percent 743 // numStep = 25 744 // percent = 50 745 // 746 // loLim = w[row] - percent*w[row]/100 747 // hiLim = w[row] + percent*w[row]/100 748 // 749 // 750 // Make/O/D/N=(numStep) testKRVals 751 // testKRVals = loLim + x*(hiLim-loLim)/numStep 752 // 753 // print testKRvals 754 // return(0) 755 // 756 //End 757 // 758 //Function getParamFromKRSetup(row,col,wStr) 759 // Variable &row,&col 760 // String &wStr 761 // 762 // Variable parNum 763 // 764 // GetSelection table, MultiCyl#T0, 3 765 // row = V_startRow 766 // col = V_startCol 767 // Print S_Selection 768 // wStr = S_Selection 769 // 770 // 771 // return(0) 772 //End 773 774 Proc Vary_Two_Cyl_Param(waveStr,row,waveStr2,row2,percent,percent2,numStep) 775 // pick the wave and row and % 776 String waveStr="xx" 777 Variable row=1 778 String waveStr2="rri" 779 Variable row2=0 780 Variable percent = 105 781 Variable percent2 = 50 782 Variable numStep=5 783 Prompt waveStr,"wave",popup,"xx;yy;zz;rri;hti;rotx;roty;sld;" 784 Prompt waveStr2,"wave2",popup,"xx;yy;zz;rri;hti;rotx;roty;sld;" 785 786 // dispatch to calculation 787 MultiCyl_Loop_2D($waveStr,row,$waveStr2,row2,percent,percent2,numStep) 788 789 // plot the chi2_map 790 DoWindow/F MultiCyl_ChiMap_2D 791 if(V_flag==0) 792 MultiCyl_ChiMap_2D() 793 else 794 //V_min*1.01 = the 1% neighborhood around the solution 795 WaveStats/Q chi2_Map_2D 796 ModifyImage/W=MultiCyl_ChiMap_2D chi2_Map_2D ctab= {(V_min*1.01),*,ColdWarm,0} 797 ModifyImage/W=MultiCyl_ChiMap_2D chi2_Map_2D minRGB=(0,65535,0),maxRGB=(0,65535,0) 798 endif 799 800 end 801 802 803 Function MultiCyl_Loop_2D(w,row,w2,row2,percent,percent2,numStep) 804 Wave w 805 Variable row 806 Wave w2 807 Variable row2,percent,percent2,numStep 808 809 Variable loLim,hiLim,ii,jj,minIndex,minChiSq 810 String folderStr 811 812 Make/O/D/N=(numStep,numStep) chi2_Map_2D 813 Make/O/D/N=(numStep) testVals,testVals2 814 Wave chi2_Map_2D=chi2_Map_2D 815 Wave testVals=testVals 816 Wave testVals2=testVals2 817 818 testVals = 0 819 testVals2 = 0 820 chi2_Map_2D = 0 821 822 823 loLim = w[row] - percent*w[row]/100 824 hiLim = w[row] + percent*w[row]/100 825 testVals = loLim + x*(hiLim-loLim)/(numStep-1) 826 // Print lolim,hilim 827 828 SetScale/I x LoLim,HiLim,"", chi2_Map_2D 829 830 loLim = w2[row2] - percent2*w2[row2]/100 831 hiLim = w2[row2] + percent2*w2[row2]/100 832 testVals2 = loLim + x*(hiLim-loLim)/(numStep-1) 833 // Print lolim,hilim 834 835 SetScale/I y LoLim,HiLim,"", chi2_Map_2D 836 837 838 // the experimental data 839 ControlInfo/W=WrapperPanel popup_0 840 folderStr=S_Value 841 // wave references for the data (to pass) 842 String DF="root:"+folderStr+":" 843 844 WAVE yw=$(DF+folderStr+"_i") 845 WAVE xw=$(DF+folderStr+"_q") 846 WAVE sw=$(DF+folderStr+"_s") 847 848 duplicate/o yw, interpCalc,chi2_data 849 Wave chi2_data=chi2_data 850 Wave interpCalc=interpCalc 851 852 STRUCT WMButtonAction ba 853 ba.eventCode = 2 854 855 // double loop 856 for(ii=0;ii<numStep;ii+=1) 857 Print " Outer Loop Index = ",ii," out of ",numStep 858 //set the value from the outer loop 859 w[row] = testVals[ii] 860 861 for(jj=0;jj<numStep;jj+=1) 862 863 // set the inner value 864 w2[row2] = testVals2[jj] 865 // generate the structure 866 // 867 KR_GenerateButtonProc(ba) 868 869 // do the calculation 870 KR_DoCalcButtonProc(ba) 871 872 WAVE ival_KR=ival_KR 873 WAVE qval_KR=qval_KR 874 875 interpCalc = interp(xw, qval_KR, ival_KR ) 876 877 // calculate chi-squared 878 chi2_data = (yw-interpCalc)^2 879 chi2_data /= sw^2 880 881 Wavestats/Q chi2_data 882 chi2_Map_2D[ii][jj] = V_avg * V_npnts 883 884 endfor 885 endfor 886 887 888 // find the best chi squared 889 WaveStats/Q chi2_Map_2D 890 // reset the value to the best 891 w[row] = V_MinRowLoc 892 w2[row2] = V_MinColLoc 893 894 minChiSq = V_Min 895 print "Minimum chi2 = ",minChiSq 896 897 // and then recalculate at the best solution 898 KR_GenerateButtonProc(ba) 899 900 // do the calculation 901 KR_DoCalcButtonProc(ba) 902 903 return(0) 904 End 905 906 Proc MultiCyl_ChiMap_2D() 907 PauseUpdate; Silent 1 // building window... 908 Display /W=(35,44,466,414) 909 AppendImage chi2_Map_2D 910 DoWindow/C MultiCyl_ChiMap_2D 911 ModifyImage chi2_Map_2D ctab= {*,*,ColdWarm,0} 912 913 //V_min*1.01 = the 1% neighborhood around the solution 914 WaveStats/Q chi2_Map_2D 915 ModifyImage/W=MultiCyl_ChiMap_2D chi2_Map_2D ctab= {(V_min*1.01),*,ColdWarm,0} 916 ModifyImage/W=MultiCyl_ChiMap_2D chi2_Map_2D minRGB=(0,65535,0),maxRGB=(0,65535,0) 917 918 Label bottom "test values" 919 Label left "test values" 920 end -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Tinker/FFT_VoxelDisplay.ipf
r925 r941 86 86 87 87 // ModifyGizmo/N=Gizmo_VoxelMat ModifyObject=voxelgram0 property={ valueRGBA,ii,SLD_id[ii],rr[ii],gg[ii],bb[ii],aa[ii]} 88 print str88 // print str 89 89 execute str 90 90 endfor -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf
r914 r941 1600 1600 1601 1601 1602 // this does the setup 1603 Function fChiMap(paramNum,percent) 1604 Variable paramNum,percent 1605 1606 String folderStr,funcStr,coefStr 1607 Variable useCursors,useResol=0,pt1,pt2,minIndex 1608 1609 ControlInfo/W=WrapperPanel popup_0 1610 folderStr=S_Value 1611 1612 ControlInfo/W=WrapperPanel popup_1 1613 funcStr=S_Value 1614 1615 ControlInfo/W=WrapperPanel popup_2 1616 coefStr=S_Value 1617 1618 ControlInfo/W=WrapperPanel check_0 1619 useCursors=V_Value 1620 1621 1622 // first, figure out where we are... 1623 String suffix=getModelSuffix(funcStr) 1624 1625 SetDataFolder $("root:"+folderStr) 1626 if(!exists(coefStr)) 1627 // must be unsmeared model, work in the root folder 1628 SetDataFolder root: 1629 if(!exists(coefStr)) //this should be fine if the coef filter is working, but check anyhow 1630 DoAlert 0,"the coefficient and data sets do not match" 1631 return 0 1632 endif 1633 endif 1634 1635 WAVE cw=$(coefStr) 1636 1637 1638 // test for smeared function 1639 if(stringmatch(funcStr, "Smear*")) // if it's a smeared function, need a struct 1640 useResol=1 1641 endif 1642 1643 // fill a struct instance whether I need one or not 1644 String DF="root:"+folderStr+":" 1645 1646 // Struct ResSmearAAOStruct fs 1647 // WAVE/Z resW = $(DF+folderStr+"_res") //these may not exist, if 3-column data is used 1648 // WAVE/Z fs.resW = resW 1649 WAVE yw=$(DF+folderStr+"_i") 1650 WAVE xw=$(DF+folderStr+"_q") 1651 WAVE sw=$(DF+folderStr+"_s") 1652 // Wave fs.coefW = cw 1653 // Wave fs.yW = yw 1654 // Wave fs.xW = xw 1655 1656 if(useCursors) 1657 if(pcsr(A) > pcsr(B)) 1658 pt1 = pcsr(B) 1659 pt2 = pcsr(A) 1660 else 1661 pt1 = pcsr(A) 1662 pt2 = pcsr(B) 1663 endif 1664 else 1665 //if cursors are not being used, find the first and last points of the data set, and pass them 1666 pt1 = 0 1667 pt2 = numpnts(yw)-1 1668 endif 1669 1670 minIndex = chi2gen(funcStr,folderStr,xw,yw,sw,cw,paramNum,percent,pt1,pt2,useResol) 1671 1672 WAVE chi2_map=chi2_map 1673 cw[paramNum] = pnt2x(chi2_map, minIndex) 1674 1675 return(0) 1676 End 1677 1602 1678 // this does the math for a single value of "whichParam" 1603 1679 Function chi2gen(funcStr,folderStr,xw,yw,sw,cw,whichParam,searchArea,lhs,rhs,useResol) … … 1610 1686 variable originalvalue = cw[whichparam] 1611 1687 variable range = originalValue * searchArea/100 1612 variable ii,err 1688 variable ii,err,minIndex 1613 1689 1614 1690 duplicate/o yw, :theoretical_data, :chi2_data 1615 1691 Wave theoretical_data, chi2_data 1616 1692 1617 make/o/n= 200/d chi2_map1618 setscale/I x, originalvalue - range /2, originalvalue + range/2, chi2_map1693 make/o/n=50/d chi2_map 1694 setscale/I x, originalvalue - range, originalvalue + range, chi2_map 1619 1695 1620 1696 String DF="root:"+folderStr+":" … … 1666 1742 Label bottom parW[whichParam] 1667 1743 1744 WaveStats/Q chi2_map 1745 minIndex = V_minRowLoc 1746 Print "minimum at: ", minIndex,chi2_map[minIndex] 1747 1668 1748 1669 1749 killwaves/z theoretical_data, chi2_data 1670 End 1671 1672 1673 // this does the setup 1674 Function fChiMap(paramNum,percent) 1675 Variable paramNum,percent 1676 1750 return(minIndex) 1751 End 1752 1753 1754 ////////////////////////////////// 1755 // this is based on a snippet from Andy Nelson, posted at the Igor Exchange web site. 1756 // -- modified to do "manual fitting" - mapping out chi-squared along one or two directions 1757 ////////////////////////////////// 1758 1759 Proc OpenManualFitPanel() 1760 1761 DoWindow/F ManualFitPanel 1762 if(V_flag==0) 1763 init_manualFit() 1764 ManualFitPanel() 1765 Endif 1766 1767 End 1768 1769 Function init_manualFit() 1770 1771 Variable/G root:gNumManualParam=0 1772 Variable/G root:gNumManualParam2=1 1773 Variable/G root:gCurrentChiSq=0 1774 Variable/G root:gNumManualSteps=50 1775 1776 Make/O/D/N=1 root:chi2_map,root:testVals 1777 Make/O/D/N=(1,1) root:chi2D 1778 1779 return(0) 1780 end 1781 1782 Window ManualFitPanel() : Panel 1783 PauseUpdate; Silent 1 // building window... 1784 NewPanel /W=(1170,44,1842,412) /K=1 1785 ModifyPanel cbRGB=(51664,44236,58982) 1786 DoWindow/C ManualFitPanel 1787 1788 // ShowTools/A 1789 SetVariable setvar0,pos={25,10},size={150,15},title="Parameter number" 1790 SetVariable setvar0,limits={0,inf,1},value=root:gNumManualParam,disable=0 1791 SetVariable setvar3,pos={25,30},size={150,15},title="Parameter number" 1792 SetVariable setvar3,limits={0,inf,1},value=root:gNumManualParam2,disable=2 1793 1794 CheckBox check0,pos={200,10},size={37,15},value=0,title="2D?",proc=Vary2DCheck 1795 1796 Button button0,pos={25,55},size={100,20},title="Vary 100 %",proc=VaryPCTButton 1797 Button button1,pos={25,80},size={100,20},title="Vary 25 %",proc=VaryPCTButton 1798 Button button2,pos={25,105},size={100,20},title="Vary 5 %",proc=VaryPCTButton 1799 Button button3,pos={25,130},size={100,20},title="Vary 1 %",proc=VaryPCTButton 1800 SetVariable setvar1,pos={31,196},size={200,15},title="Current Chi-Squared" 1801 SetVariable setvar1,limits={0,0,0},value=root:gCurrentChiSq 1802 SetVariable setvar2,pos={31,222},size={200,15},title="Number of steps" 1803 SetVariable setvar2,limits={5,500,1},value=root:gNumManualSteps 1804 1805 // 1806 Display/W=(259,23,643,346)/HOST=# root:chi2_map vs root:testVals 1807 RenameWindow #,G0 1808 ModifyGraph mode=4,msize=1,rgb=(65535,0,0) 1809 ModifyGraph tick=2,mirror=1 1810 // Label left "Chi-squared" 1811 // Label bottom "degrees" 1812 SetActiveSubwindow ## 1813 1814 EndMacro 1815 1816 1817 Function Vary2DCheck(ctrlName,checked) 1818 String ctrlName 1819 Variable checked 1820 1821 ControlInfo check0 1822 Variable isChecked = V_Value 1823 1824 Wave chi2D=chi2D 1825 Wave chi2_map=chi2_map 1826 wave testVals=testVals 1827 1828 if(isChecked) 1829 SetVariable setvar0,disable=0 1830 SetVariable setvar3,disable=0 1831 1832 // 1833 RemoveFromGraph/W=ManualFitPanel#G0 chi2_map 1834 1835 // Display/W=(259,23,643,346)/HOST=# 1836 AppendImage/W=ManualFitPanel#G0 chi2D 1837 SetActiveSubwindow ManualFitPanel#G0 1838 ModifyImage chi2D ctab= {*,*,ColdWarm,0} 1839 Label left "par" 1840 Label bottom "par2" 1841 SetActiveSubwindow ## 1842 1843 else 1844 SetVariable setvar0,disable=0 1845 SetVariable setvar3,disable=2 1846 1847 // 1848 RemoveImage/W=ManualFitPanel#G0 chi2D 1849 1850 AppendToGraph/W=ManualFitPanel#G0 root:chi2_map vs root:testVals 1851 SetActiveSubwindow ManualFitPanel#G0 1852 // Display/W=(259,23,643,346)/HOST=# root:chi2_map vs root:testVals 1853 ModifyGraph mode=4,msize=1,rgb=(65535,0,0) 1854 ModifyGraph tick=2,mirror=1 1855 Label left "Chi-squared" 1856 // Label bottom "degrees" 1857 SetActiveSubwindow ## 1858 1859 1860 endif 1861 1862 return(0) 1863 End 1864 1865 1866 Function getParamFromWrapper() 1867 1868 Variable parNum 1869 1870 GetSelection table, WrapperPanel#T0, 1 1871 parNum = V_startRow 1872 return(parNum) 1873 End 1874 1875 1876 Function VaryPCTButton(ctrlName) : ButtonControl 1877 String ctrlName 1878 1879 Variable percent 1880 strswitch(ctrlName) // string switch 1881 case "button0": 1882 percent = 105 1883 break 1884 case "button1": 1885 percent = 25 1886 break 1887 case "button2": 1888 percent = 5 1889 break 1890 case "button3": 1891 percent = 1 1892 break 1893 default: 1894 percent = 10 1895 endswitch 1896 1897 ControlInfo check0 1898 Variable isChecked = V_Value 1899 1900 // get the necessary info about parameters, etc. 1677 1901 String folderStr,funcStr,coefStr 1678 Variable useCursors,useResol=0,pt1,pt2 1902 Variable useCursors,useResol=0,pt1,pt2,minIndex 1679 1903 1680 1904 ControlInfo/W=WrapperPanel popup_0 … … 1687 1911 coefStr=S_Value 1688 1912 1689 ControlInfo/W=WrapperPanel check_01690 useCursors=V_Value1691 1913 // ControlInfo/W=WrapperPanel check_0 1914 // useCursors=V_Value 1915 // 1692 1916 1693 1917 // first, figure out where we are... … … 1705 1929 1706 1930 WAVE cw=$(coefStr) 1707 1931 SetDataFolder root: 1932 1933 1934 Variable loLim,hiLim,minChiSq 1935 1936 NVAR numStep = root:gNumManualSteps 1937 make/o/n=(numStep)/D root:testVals 1938 Wave testVals = root:testVals 1939 WAVE chi2_map = root:chi2_map 1940 Make/O/D/N=(numStep,numStep) root:chi2D 1941 WAVE chi2D = root:chi2D 1942 1943 1944 // then do either a 1D or 2D map of the chi squared 1945 if(isChecked) 1946 1947 NVAR par = root:gNumManualParam 1948 NVAR par2 = root:gNumManualParam2 1949 1950 Variable ii,jj,saveVal2 1951 saveVal2 = cw[par2] //initial value of par2 1952 1953 //steps in par2 direction 1954 make/o/n=(numStep)/D root:testVals2 1955 Wave testVals2 = root:testVals2 1956 loLim = cw[par2] - percent*cw[par2]/100 1957 hiLim = cw[par2] + percent*cw[par2]/100 1958 testVals2 = loLim + x*(hiLim-loLim)/numStep 1959 1960 SetScale/I x LoLim,HiLim,"", chi2D 1961 1962 //steps in par1 direction 1963 if(cw[par] != 0) 1964 loLim = cw[par] - percent*cw[par]/100 1965 hiLim = cw[par] + percent*cw[par]/100 1966 else 1967 loLim = -1 1968 hiLim = 1 1969 endif 1970 testVals = loLim + x*(hiLim-loLim)/numStep 1971 SetScale/I y LoLim,HiLim,"", chi2D 1972 1973 1974 for(ii=0;ii<numStep;ii+=1) 1975 cw[par2] = testVals2[ii] //set the value for par2, vary par 1976 1977 fChiMap_new(par,percent,cw,testVals) //the wave chi2_map is generated 1978 1979 chi2D[ii][] = chi2_map[q] 1980 1981 endfor 1982 1983 // set the new minimum value 1984 WaveStats/Q chi2D 1985 // now with scaled dimensions of Chi2D, the reported values are the values, not the point index 1986 cw[par] = V_MinColLoc 1987 cw[par2] = V_MinRowLoc 1988 1989 // the minimum chi_squared along this path is at: -- is it better? 1990 minChiSq = V_Min 1991 1992 NVAR curChi2=root:gCurrentChiSq 1993 curChi2 = minChiSq 1994 1995 //V_min*1.01 = the 1% neighborhood around the solution 1996 ModifyImage/W=ManualFitPanel#G0 chi2D ctab= {(V_min*1.01),*,ColdWarm,0} 1997 ModifyImage/W=ManualFitPanel#G0 chi2D minRGB=(0,65535,0),maxRGB=(0,65535,0) 1998 1999 else 2000 NVAR par = root:gNumManualParam 2001 par = getParamFromWrapper() 2002 2003 if(cw[par] != 0) 2004 loLim = cw[par] - percent*cw[par]/100 2005 hiLim = cw[par] + percent*cw[par]/100 2006 else 2007 loLim = -1 2008 hiLim = 1 2009 endif 2010 testVals = loLim + x*(hiLim-loLim)/numStep 2011 2012 2013 fChiMap_new(par,percent,cw,testVals) //the wave chi2_map is generated 2014 2015 // set the new minimum value 2016 WaveStats/Q chi2_map 2017 minIndex = V_minRowLoc 2018 cw[par] = testVals[minIndex] 2019 2020 // the minimum chi_squared along this path is at: -- is it better? 2021 minChiSq = chi2_map[minIndex] 2022 2023 NVAR curChi2=root:gCurrentChiSq 2024 curChi2 = minChiSq 2025 endif 2026 2027 2028 return(0) 2029 End 2030 2031 2032 Proc mMapChiSquared_Pct(paramNum,percent) 2033 Variable paramNum=0,percent=50 2034 Prompt paramNum, "Enter parameter number: " 2035 Prompt percent, "Enter percent variation:" 2036 2037 fChiMap_new(paramNum,percent) 2038 End 2039 2040 //Macro mMapChiSquared(paramNum,loLim,hiLim) 2041 // Variable paramNum=0,loLim=0,hiLim=1 2042 // Prompt paramNum, "Enter parameter number: " 2043 // Prompt loLim, "Enter lower value:" 2044 // Prompt hiLim, "Enter higher value:" 2045 // 2046 // fChiMap_new(paramNum,loLim,hiLim) 2047 //End 2048 2049 2050 // this does the setup 2051 Function fChiMap_new(paramNum,percent,cw,testVals) 2052 Variable paramNum,percent 2053 Wave cw,testVals 2054 2055 //Function fChiMap_new(paramNum,percent) 2056 // Variable paramNum,percent 2057 2058 2059 String folderStr,funcStr,coefStr 2060 Variable useCursors,useResol=0,pt1,pt2,minIndex 2061 2062 ControlInfo/W=WrapperPanel popup_0 2063 folderStr=S_Value 2064 2065 ControlInfo/W=WrapperPanel popup_1 2066 funcStr=S_Value 2067 2068 ControlInfo/W=WrapperPanel popup_2 2069 coefStr=S_Value 2070 2071 ControlInfo/W=WrapperPanel check_0 2072 useCursors=V_Value 2073 2074 // coefficent wave cw is passed in 1708 2075 1709 2076 // test for smeared function … … 1712 2079 endif 1713 2080 1714 // fill a struct instance whether I need one or not2081 // wave references for the data (to pass) 1715 2082 String DF="root:"+folderStr+":" 1716 2083 1717 // Struct ResSmearAAOStruct fs1718 // WAVE/Z resW = $(DF+folderStr+"_res") //these may not exist, if 3-column data is used1719 // WAVE/Z fs.resW = resW1720 2084 WAVE yw=$(DF+folderStr+"_i") 1721 2085 WAVE xw=$(DF+folderStr+"_q") 1722 2086 WAVE sw=$(DF+folderStr+"_s") 1723 // Wave fs.coefW = cw 1724 // Wave fs.yW = yw 1725 // Wave fs.xW = xw 1726 2087 1727 2088 if(useCursors) 1728 2089 if(pcsr(A) > pcsr(B)) … … 1738 2099 pt2 = numpnts(yw)-1 1739 2100 endif 1740 1741 1742 1743 chi2gen(funcStr,folderStr,xw,yw,sw,cw,paramNum,percent,pt1,pt2,useResol) 1744 1745 1746 End 1747 1748 //////////////////////////////////// 1749 // Modification from Matt Wasbrough to allow rescaling of the 1750 // axes while plotting and fitting. allows export of the rescaled 1751 // data and of the rescaled model 1752 // Nov 2012 1753 /// 1754 1755 Function UseRescaleAxisCheckProc(cba) : CheckBoxControl 1756 STRUCT WMCheckboxAction &cba 1757 1758 switch( cba.eventCode ) 1759 case 2: // mouse up 1760 Variable checked = cba.checked 1761 if(checked) 1762 Execute "OpenAxisPanel()" 1763 else 1764 if(exists("RescaleAxisPanel") !=0) 1765 DoWindow/K RescaleAxisPanel 1766 endif 1767 endif 1768 break 1769 endswitch 1770 1771 return 0 1772 End 1773 1774 Proc OpenAxisPanel() 1775 If(WinType("RescaleAxisPanel") == 0) 1776 //create the necessary data folder 1777 NewDataFolder/O root:Packages 1778 NewDataFolder/O root:Packages:NIST 1779 NewDataFolder/O root:Packages:NIST:RescaleAxis 1780 //initialize the values 1781 Variable/G root:Packages:NIST:RescaleAxis:gRAExpA = 1 1782 Variable/G root:Packages:NIST:RescaleAxis:gRAExpB = 1 1783 Variable/G root:Packages:NIST:RescaleAxis:gRAExpC = 1 1784 RescaleAxisPanel() 1785 else 1786 //window already exists, just bring to front for update 1787 DoWindow/F RescaleAxisPanel 1788 endif 1789 End 1790 1791 Window RescaleAxisPanel() 1792 PauseUpdate; Silent 1 // building window... 1793 NewPanel /W=(461,46,735,195)/K=1 1794 ModifyPanel cbRGB=(49360,30954,64507), fixedSize=1 1795 SetDrawLayer UserBack 1796 PopupMenu ymodel,pos={20,10},size={76,19},title="y-axis" 1797 PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"} 1798 PopupMenu ymodel,mode=1,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\"" 1799 Button GoRescale,pos={50,80},size={70,20},proc=RescalePlot,title="Rescale" 1800 Button GoRescale,help={"This button will rescale the axis using the selections in this panel"} 1801 Button DoneButton,pos={170,80},size={70,20},proc=RADoneButton,title="Done" 1802 Button DoneButton,help={"This button will close the panel"} 1803 Button ExportData, pos={100,110}, size={90,20}, proc=ExportData, title="Export Data" 1804 Button ExportData, help={"This button will export data from the top graph"} 1805 SetVariable expa,pos={13,45},size={80,17},title="pow \"a\"" 1806 SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"} 1807 SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpA 1808 SetVariable expb,pos={98,45},size={80,17},title="pow \"b\"" 1809 SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"} 1810 SetVariable expb,limits={0,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpB 1811 PopupMenu xmodel,pos={155,10},size={79,19},title="x-axis" 1812 PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"} 1813 PopupMenu xmodel,mode=1,value= #"\"q;log(q);q^2;q^c\"" 1814 SetVariable expc,pos={182,45},size={80,17},title="pow \"c\"" 1815 SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"} 1816 SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpC 1817 Button RAHelp, pos={220,110}, size={20,20}, proc=RAHelpButtonProc, title="?" 1818 EndMacro 1819 1820 Proc RADoneButton(ctrlName): ButtonControl 1821 String ctrlName 1822 DoWindow/K RescaleAxisPanel 1823 DoWindow/F WrapperPanel 1824 CheckBox check_8 value=0 1825 end 1826 1827 Function RAHelpButtonProc(ba) : ButtonControl 1828 STRUCT WMButtonAction &ba 1829 1830 switch( ba.eventCode ) 1831 case 2: // mouse up 1832 // click code here 1833 DisplayHelpTopic/Z/K=1 "Rescaled Axis" 1834 if(V_flag !=0) 1835 DoAlert 0,"The Rescaled Axis Help file could not be found" 1836 endif 1837 break 1838 endswitch 1839 1840 return 0 1841 End 1842 1843 Proc ExportData(ctrlName): ButtonControl 1844 string ctrlName 1845 WriteRescaledData() 1846 End 1847 1848 1849 Function RescalePlot (ctrlName): ButtonControl 1850 String ctrlName 2101 2102 Variable loLim,hiLim,minChiSq 2103 1851 2104 SetDataFolder root: 1852 String topGraph= WinName(0,1) //this is the topmost graph 1853 if(strlen(topGraph)==0) 1854 Abort "There is no graph" 1855 endif 1856 1857 DoWindow/F $topGraph 1858 GetWindow/Z $topGraph, wavelist 1859 wave/t W_Wavelist 1860 SetDataFolder root:Packages:NIST:RescaleAxis 1861 if (exists("W_WaveList")==1) 1862 KillWaves/Z root:Packages:NIST:RescaleAxis:W_WaveList 1863 endif 1864 MoveWave root:W_WaveList, root:Packages:NIST:RescaleAxis:W_WaveList 1865 SetDataFolder root:Packages:NIST:RescaleAxis 1866 variable i,j,k 1867 string DF,DF1,temp, temp2, t1 1868 for (i=0; i < numpnts(W_WaveList)/3; i+=1) 1869 temp = W_WaveList[i][1] 1870 if (stringmatch(temp, "*_i") || stringmatch(temp, "*_i_RA")) 1871 temp = W_WaveList[i][0] 1872 if(stringmatch(temp, "*_i")) 1873 temp = removeending(temp, "_i") 1874 elseif(stringmatch(temp, "*_i_RA")) 1875 temp = removeending(temp, "_i_RA") 1876 endif 1877 Make/T/O $temp/Wave=tempWave 1878 DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") 1879 if (strlen(DF) ==0) 1880 DF = ":" 1881 endif 1882 DF1 = "root"+DF 1883 tempWave[0] = DF1 1884 k = 1 1885 for(j=0;j<numpnts(W_WaveList)/3; j+=1) 1886 if (stringmatch(W_WaveList[j][1], "*"+temp+"*")) 1887 tempWave[k] = W_WaveList[j][0] 1888 k = k+1 1889 endif 1890 endfor 1891 redimension/N=(k) tempWave 1892 elseif(stringmatch(temp, "*ywave*")) 1893 temp = W_WaveList[i][0] 1894 if(stringmatch(temp, "*_RA")) 1895 temp = removeending(temp, "_RA") 1896 endif 1897 Make/T/O $temp/Wave=tempWave 1898 DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") 1899 if (strlen(DF) ==0) 1900 DF = ":" 1901 endif 1902 DF1 = "root"+DF 1903 tempWave[0] = DF1 1904 temp2 = replacestring("ywave", temp, "") 1905 k = 1 1906 for(j=0;j<numpnts(W_WaveList)/3; j+=1) 1907 t1 = W_Wavelist[j][1] 1908 if (stringmatch(W_WaveList[j][1], "*wave"+temp2+"*")) 1909 tempWave[k] = W_WaveList[j][1] 1910 k = k+1 1911 endif 1912 endfor 1913 redimension/N=(k) tempWave 1914 endif 2105 2106 NVAR numStep = root:gNumManualSteps 2107 make/o/n=(numStep)/D root:chi2_map 2108 Wave chi2_map = root:chi2_map 2109 // Wave testVals = root:testVals 2110 2111 //the testVals are genereated and passed by the calling routine 2112 2113 minIndex = chi2gen_new(funcStr,folderStr,xw,yw,sw,cw,paramNum,pt1,pt2,useResol,chi2_map,testVals) 2114 2115 return(0) 2116 End 2117 2118 2119 // this does the math for a single value of "whichParam" 2120 Function chi2gen_new(funcStr,folderStr,xw,yw,sw,cw,whichParam,lhs,rhs,useResol,chi2_map,testVals) 2121 String funcStr,folderStr 2122 Wave xw,yw,sw,cw // x data, y data, error wave, and coefficient wave 2123 variable whichParam //which of the parameters to you want to vary, how far from the original value do you want to search (%) 2124 variable lhs, rhs //specify a region of interest in the data using a left hand side and right hand side. 2125 variable useResol // =1 if smeared used 2126 Wave chi2_map,testVals 2127 2128 variable originalvalue = cw[whichparam] 2129 // variable range = originalValue * searchArea/100 2130 variable ii,err,minIndex 2131 2132 duplicate/o yw, :theoretical_data, :chi2_data 2133 Wave theoretical_data, chi2_data 2134 2135 String DF="root:"+folderStr+":" 2136 String suffix=getModelSuffix(funcStr) 2137 2138 // fill a struct instance whether it is needed or not 2139 Struct ResSmearAAOStruct fs 2140 WAVE/Z resW = $(DF+folderStr+"_res") //these may not exist, if 3-column data is used 2141 WAVE/Z fs.resW = resW 2142 // WAVE yw=$(DF+folderStr+"_i") //these are passed in 2143 // WAVE xw=$(DF+folderStr+"_q") 2144 // WAVE sw=$(DF+folderStr+"_s") 2145 Wave fs.coefW = cw 2146 Wave fs.yW = theoretical_data 2147 Wave fs.xW = xw 2148 2149 2150 2151 for(ii=0 ; ii < numpnts(chi2_map) ; ii+=1) 2152 cw[whichparam] = testVals[ii] 2153 2154 if(useResol) 2155 FUNCREF SANSModelSTRUCT_proto func1=$funcStr 2156 err = func1(fs) 2157 else 2158 FUNCREF SANSModelAAO_proto func2=$funcStr 2159 func2(cw,theoretical_data,xw) 2160 endif 2161 2162 chi2_data = (yw-theoretical_data)^2 2163 2164 chi2_data /= sw^2 2165 2166 Wavestats/q/R=[lhs, rhs] chi2_data 2167 2168 chi2_map[ii] = V_avg * V_npnts 1915 2169 endfor 1916 KillWaves/Z W_Wavelist 1917 string listWave = Wavelist("*", ";", "TEXT:1") 1918 string WaveToRescale, WaveDataFolder,xwave, ywave, swave 1919 1920 for (i = 0; i < ItemsInList(listWave,";"); i+=1) 1921 temp = StringFromList(i,listWave,";") 1922 Wave/T WaveString = $temp 1923 for (j=1; j < numpnts(WaveString); j+=1) 1924 WaveToRescale = Wavestring[j] 1925 if (stringmatch(WaveToRescale, "*_RA")) 1926 WaveToRescale = RemoveEnding(WaveToRescale, "_RA") 1927 endif 1928 WaveDataFolder = WaveString[0] 1929 SetDataFolder $WaveDataFolder 1930 if (stringmatch(WaveToRescale, "*_q")) 1931 xwave = WaveToRescale 1932 XRescale(xwave) 1933 elseif (stringmatch(WaveToRescale, "*_i")) 1934 ywave = WaveToRescale 1935 xwave = RemoveEnding(WaveToRescale, "_i")+"_q" 1936 YRescale(ywave, xwave) 1937 elseif (stringmatch(WaveToRescale, "*_s")) 1938 swave = WaveToRescale 1939 ywave = RemoveEnding(WaveToRescale, "_s")+"_i" 1940 xwave = RemoveEnding(WaveToRescale, "_s")+"_q" 1941 ERescale(swave, ywave, xwave) 1942 elseif (stringmatch(WaveToRescale, "xwave_*")) 1943 xwave=WaveToRescale 1944 XRescale(xwave) 1945 elseif (stringmatch(WaveToRescale, "ywave_*")) 1946 ywave = WaveToRescale 1947 xwave= ReplaceString("ywave", WaveToRescale, "xwave") 1948 YRescale(ywave, xwave) 1949 elseif(stringmatch(WaveToRescale, "*_qvals")) 1950 xwave = WaveToRescale 1951 XRescale(xwave) 1952 elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) 1953 ywave = WaveToRescale 1954 for (k=1; k < numpnts(WaveString); k+=1) 1955 if (stringmatch(Wavestring[k], "*_qvals")) 1956 xwave = Wavestring[k] 1957 endif 1958 endfor 1959 YRescale(ywave, xwave) 1960 else 1961 ywave = WaveToRescale 1962 for (k=1; k < numpnts(WaveString); k+=1) 1963 if (stringmatch(Wavestring[k], "*_q")) 1964 xwave = Wavestring[k] 1965 endif 1966 endfor 1967 YRescale(ywave,xwave) 1968 string yAxis = ywave+"_RA" 1969 wave yAxisWave = $yAxis 1970 SetFormula yAxisWave, "YRescale(ywave,xwave)" 1971 endif 1972 SetDataFolder root:Packages:NIST:RescaleAxis 1973 endfor 1974 endfor 1975 1976 string oldywave, xstr, ystr 1977 for (i = 0; i < ItemsInList(listWave,";"); i+=1) 1978 temp = StringFromList(i,listWave,";") 1979 Wave/T WaveString = $temp 1980 for (j=1; j < numpnts(WaveString); j+=1) 1981 WaveToRescale = Wavestring[j] 1982 WaveDataFolder = WaveString[0] 1983 SetDataFolder $WaveDataFolder 1984 ControlInfo/W=RescaleAxisPanel yModel 1985 ystr = S_Value 1986 ControlInfo/W=RescaleAxisPanel xModel 1987 xstr = S_Value 1988 if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) 1989 if(stringmatch(WaveToRescale, "*_i_RA")) 1990 oldywave = WaveToRescale 1991 ywave = RemoveEnding(WaveToRescale,"_RA") 1992 xwave = RemoveEnding(WaveToRescale, "_i_RA")+"_q" 1993 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1994 replacewave/X/W=$topGraph trace=$ywave, $xwave 1995 swave = RemoveEnding(WaveToRescale, "_i_RA")+"_s" 1996 if(exists(swave)==1) 1997 ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) 1998 endif 1999 elseif (stringmatch(WaveToRescale, "smeared*")) 2000 if(stringmatch(WaveToRescale,"*_RA") && stringmatch(WaveToRescale,"!*_qvals*") ) 2001 oldywave = WaveToRescale 2002 ywave = RemoveEnding(WaveToRescale,"_RA") 2003 xwave = "smeared_qvals" 2004 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2005 replacewave/X/W=$topGraph trace=$ywave, $xwave 2006 endif 2007 elseif(stringmatch(WaveToRescale,"ywave*") && stringmatch(WaveToRescale,"*_RA")) 2008 oldywave = WaveToRescale 2009 ywave = RemoveEnding(WaveToRescale,"_RA") 2010 xwave = ReplaceString("ywave",ywave,"xwave") 2011 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2012 replacewave/X/W=$topGraph trace=$ywave, $xwave 2013 elseif(stringmatch(WaveToRescale, "*FitYw*") && stringmatch(WaveToRescale, "*_RA")) 2014 oldywave = WaveToRescale 2015 ywave = RemoveEnding(WaveToRescale,"_RA") 2016 for (k=1; k < numpnts(WaveString); k+=1) 2017 if (stringmatch(Wavestring[k], "*_q")) 2018 xwave = Wavestring[k] 2019 endif 2020 endfor 2021 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2022 replacewave/X/W=$topGraph trace=$ywave, $xwave 2023 endif 2024 elseif(stringmatch(WaveToRescale, "*_RA")) 2025 elseif (stringmatch(WaveToRescale, "*_i")) 2026 DoWindow/F topGraph 2027 oldywave = WaveToRescale 2028 xwave = RemoveEnding(WaveToRescale, "_i")+"_q_RA" 2029 ywave = WaveToRescale + "_RA" 2030 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2031 replacewave/X/W=$topGraph trace=$ywave, $xwave 2032 ModifyGraph log=0 2033 swave = RemoveEnding(WaveToRescale, "_i")+"_s_RA" 2034 if(exists(swave)==1) 2035 ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) 2036 endif 2037 DoUpdate 2038 elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) 2039 oldywave = WaveToRescale 2040 ywave = WaveToRescale + "_RA" 2041 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2042 xwave = "smeared_qvals_RA" 2043 replacewave/X/W=$topGraph trace=$ywave, $xwave 2044 elseif(stringmatch(WaveToRescale,"ywave*")) 2045 oldywave = WaveToRescale 2046 ywave = WaveToRescale + "_RA" 2047 xwave = ReplaceString("ywave",ywave,"xwave") 2048 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2049 replacewave/X/W=$topGraph trace=$ywave, $xwave 2050 elseif(stringmatch(WaveToRescale, "*FitYw*")) 2051 oldywave = WaveToRescale 2052 ywave = WaveToRescale+"_RA" 2053 for (k=1; k < numpnts(WaveString); k+=1) 2054 if (stringmatch(Wavestring[k], "*_q")) 2055 xwave = Wavestring[k]+"_RA" 2056 endif 2057 endfor 2058 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 2059 replacewave/X/W=$topGraph trace=$ywave, $xwave 2060 endif 2061 SetDataFolder root:Packages:NIST:RescaleAxis 2062 DoUpdate 2063 endfor 2064 endfor 2065 KillWaves/A/Z 2066 2067 string ylabel, xlabel 2068 ControlInfo/W=RescaleAxisPanel yModel 2069 ystr = S_Value 2070 ControlInfo/W=RescaleAxisPanel xModel 2071 xstr = S_Value 2072 2073 if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) 2074 modifygraph log=1 2075 else 2076 modifygraph log=0 2077 endif 2078 2079 Variable pow_a,pow_b,pow_c 2080 ControlInfo/W=RescaleAxisPanel expa 2081 pow_a = V_value 2082 ControlInfo/W=RescaleAxisPanel expb 2083 pow_b = V_value 2084 ControlInfo/W=RescaleAxisPanel expc 2085 pow_c = V_value 2086 2087 If (cmpstr("I",ystr) == 0) 2088 ylabel = "I(q)" 2089 elseif (cmpstr("ln(I)",ystr) == 0) 2090 ylabel = "ln(I)" 2091 elseif (cmpstr("log(I)",ystr) == 0) 2092 ylabel = "log(I)" 2093 elseif (cmpstr("1/I",ystr) == 0) 2094 ylabel = "1/I" 2095 elseif (cmpstr("I^a",ystr) == 0) 2096 ylabel = "I\S"+num2str(pow_a)+"\M" 2097 elseif (cmpstr("Iq^a",ystr) == 0) 2098 ylabel = "Iq\S"+num2str(pow_a)+"\M" 2099 elseif (cmpstr("I^a q^b",ystr) == 0) 2100 ylabel = "I\S"+num2str(pow_a)+"\Mq\S"+num2str(pow_b)+"\M" 2101 elseif (cmpstr("1/sqrt(I)",ystr) == 0) 2102 ylabel = "1/sqrt(I)" 2103 elseif (cmpstr("ln(Iq)",ystr) == 0) 2104 ylabel = "ln(Iq)" 2105 elseif (cmpstr("ln(Iq^2)",ystr) == 0) 2106 ylabel = "ln(Iq\S2\M)" 2107 endif 2108 2109 If (cmpstr("q",xstr) == 0) 2110 xlabel = "q (A\S-1\M)" 2111 elseif (cmpstr("q^2",xstr) == 0) 2112 xlabel = "q\S2\M" 2113 elseif (cmpstr("log(q)",xstr) == 0) 2114 xlabel = "log(q)" 2115 elseif (cmpstr("q^c",xstr) == 0) 2116 xlabel = "q\S"+num2str(pow_c)+"\M" 2117 endif 2118 2119 SetAxis/A 2120 Label left ylabel 2121 Label bottom xlabel 2122 2123 SetDataFolder root: 2124 End 2125 2126 Function YRescale(ywave, xwave) 2127 String ywave,xwave 2128 2129 Wave yw = $ywave 2130 Wave xw = $xwave 2131 2132 //Scaling exponents and background value 2133 Variable pow_a,pow_b,pow_c 2134 ControlInfo/W=RescaleAxisPanel expa 2135 pow_a = V_value 2136 ControlInfo/W=RescaleAxisPanel expb 2137 pow_b = V_value 2138 ControlInfo/W=RescaleAxisPanel expc 2139 pow_c = V_value 2140 2141 //check for physical limits on exponent values 2142 // if bad values found, alert, and reset to good values so the rescaling can continue 2143 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 2144 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 2145 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 2146 if((pow_a < -2) || (pow_a > 10)) 2147 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 2148 gA = 1 2149 endif 2150 if((pow_b < 0) || (pow_b > 10)) 2151 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 2152 gB = 1 2153 endif 2154 //if q^c is the x-scaling, c must be be within limits and also non-zero 2155 ControlInfo/W=RescaleAxisPanel xModel 2156 If (cmpstr("q^c",S_Value) == 0) 2157 if(pow_c == 0) 2158 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 2159 gC = 1 2160 endif 2161 if((pow_c < -10) || (pow_c > 10)) 2162 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 2163 gC = 1 2164 endif 2165 endif 2166 2167 //variables set for each model to control look of graph 2168 String ystr, yAxis 2169 //check for proper y-scaling selection, make the necessary waves 2170 // Wave yAxisWave 2171 2172 ControlInfo/W=RescaleAxisPanel yModel 2173 ystr = S_Value 2174 2175 do 2176 If (cmpstr("I",S_Value) == 0) 2177 yAxis = ywave+"_RA" 2178 if (exists(yAxis)== 0) 2179 Duplicate yw $yAxis 2180 endif 2181 SetScale d 0,0,"1/cm",$yAxis 2182 wave yAxisWave = $yAxis 2183 yAxisWave = yw 2184 break 2185 endif 2186 If (cmpstr("ln(I)",S_Value) == 0) 2187 yAxis = ywave+"_RA" 2188 if (exists(yAxis)== 0) 2189 Duplicate yw $yAxis 2190 endif 2191 SetScale d 0,0,"",$yAxis 2192 wave yAxisWave = $yAxis 2193 yAxisWave = ln(yw) 2194 break 2195 endif 2196 If (cmpstr("log(I)",S_Value) == 0) 2197 yAxis = ywave+"_RA" 2198 if (exists(yAxis)== 0) 2199 Duplicate yw $yAxis 2200 endif 2201 SetScale d 0,0,"",$yAxis 2202 wave yAxisWave = $yAxis 2203 yAxisWave = log(yw) 2204 break 2205 endif 2206 If (cmpstr("1/I",S_Value) == 0) 2207 yAxis = ywave+"_RA" 2208 if (exists(yAxis)== 0) 2209 Duplicate yw $yAxis 2210 endif 2211 SetScale d 0,0,"",$yAxis 2212 wave yAxisWave = $yAxis 2213 yAxisWave = 1/(yw) 2214 break 2215 endif 2216 If (cmpstr("I^a",S_Value) == 0) 2217 yAxis = ywave+"_RA" 2218 if (exists(yAxis)== 0) 2219 Duplicate yw $yAxis 2220 endif 2221 SetScale d 0,0,"",$yAxis 2222 wave yAxisWave = $yAxis 2223 yAxisWave = yw^pow_a 2224 break 2225 endif 2226 If (cmpstr("Iq^a",S_Value) == 0) 2227 yAxis = ywave+"_RA" 2228 if (exists(yAxis)== 0) 2229 Duplicate yw $yAxis 2230 endif 2231 SetScale d 0,0,"",$yAxis 2232 wave yAxisWave = $yAxis 2233 yAxisWave = yw*xw^pow_a 2234 break 2235 endif 2236 If (cmpstr("I^a q^b",S_Value) == 0) 2237 yAxis = ywave+"_RA" 2238 if (exists(yAxis)== 0) 2239 Duplicate yw $yAxis 2240 endif 2241 SetScale d 0,0,"",$yAxis 2242 wave yAxisWave = $yAxis 2243 yAxisWave = yw^pow_a*xw^pow_b 2244 break 2245 endif 2246 If (cmpstr("1/sqrt(I)",S_Value) == 0) 2247 yAxis = ywave+"_RA" 2248 if (exists(yAxis)== 0) 2249 Duplicate yw $yAxis 2250 endif 2251 SetScale d 0,0,"",$yAxis 2252 wave yAxisWave = $yAxis 2253 yAxisWave = 1/sqrt(yw) 2254 break 2255 endif 2256 If (cmpstr("ln(Iq)",S_Value) == 0) 2257 yAxis = ywave+"_RA" 2258 if (exists(yAxis)== 0) 2259 Duplicate yw $yAxis 2260 endif 2261 SetScale d 0,0,"",$yAxis 2262 wave yAxisWave = $yAxis 2263 yAxisWave = ln(xw*yw) 2264 break 2265 endif 2266 If (cmpstr("ln(Iq^2)",S_Value) == 0) 2267 yAxis = ywave+"_RA" 2268 if (exists(yAxis)== 0) 2269 Duplicate yw $yAxis 2270 endif 2271 SetScale d 0,0,"",$yAxis 2272 wave yAxisWave = $yAxis 2273 yAxisWave = ln(xw*xw*yw) 2274 break 2275 endif 2276 //more ifs for each case 2277 2278 // if selection not found, abort 2279 DoAlert 0,"Y-axis scaling incorrect. Aborting" 2280 Abort 2281 while(0) 2282 End 2283 2284 Function XRescale(xwave) 2285 String xwave 2286 2287 Wave xw = $xwave 2288 2289 //Scaling exponents and background value 2290 Variable pow_a,pow_b,pow_c 2291 ControlInfo/W=RescaleAxisPanel expa 2292 pow_a = V_value 2293 ControlInfo/W=RescaleAxisPanel expb 2294 pow_b = V_value 2295 ControlInfo/W=RescaleAxisPanel expc 2296 pow_c = V_value 2297 2298 //check for physical limits on exponent values 2299 // if bad values found, alert, and reset to good values so the rescaling can continue 2300 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 2301 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 2302 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 2303 if((pow_a < -2) || (pow_a > 10)) 2304 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 2305 gA = 1 2306 endif 2307 if((pow_b < 0) || (pow_b > 10)) 2308 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 2309 gB = 1 2310 endif 2311 //if q^c is the x-scaling, c must be be within limits and also non-zero 2312 ControlInfo/W=RescaleAxisPanel xModel 2313 If (cmpstr("q^c",S_Value) == 0) 2314 if(pow_c == 0) 2315 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 2316 gC = 1 2317 endif 2318 if((pow_c < -10) || (pow_c > 10)) 2319 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 2320 gC = 1 2321 endif 2322 endif 2323 2324 //variables set for each model to control look of graph 2325 String xstr, xAxis 2326 //check for proper y-scaling selection, make the necessary waves 2327 // Wave xAxisWave 2328 2329 ControlInfo/W=RescaleAxisPanel xModel 2330 xstr = S_Value 2331 do 2332 // make the new yaxis wave 2333 If (cmpstr("q",S_Value) == 0) 2334 xAxis = xwave+"_RA" 2335 if (exists(xAxis)== 0) 2336 Duplicate xw $xAxis 2337 endif 2338 SetScale d 0,0,"A^-1",$xAxis 2339 wave xAxisWave = $xAxis 2340 xAxisWave = xw 2341 break 2342 endif 2343 If (cmpstr("q^2",S_Value) == 0) 2344 xAxis = xwave+"_RA" 2345 if (exists(xAxis)== 0) 2346 Duplicate xw $xAxis 2347 endif 2348 SetScale d 0,0,"A^-2",$xAxis 2349 wave xAxisWave = $xAxis 2350 xAxisWave = xw*xw 2351 break 2352 endif 2353 If (cmpstr("log(q)",S_Value) == 0) 2354 xAxis = xwave+"_RA" 2355 if (exists(xAxis)== 0) 2356 Duplicate xw $xAxis 2357 endif 2358 SetScale d 0,0,"",$xAxis 2359 wave xAxisWave = $xAxis 2360 xAxisWave = log(xw) 2361 break 2362 endif 2363 If (cmpstr("q^c",S_Value) == 0) 2364 xAxis = xwave+"_RA" 2365 if (exists(xAxis)== 0) 2366 Duplicate xw $xAxis 2367 endif 2368 SetScale d 0,0,"", $xAxis 2369 wave xAxisWave = $xAxis 2370 xAxisWave = xw^pow_c 2371 break 2372 endif 2373 2374 //more ifs for each case 2375 // if selection not found, abort 2376 DoAlert 0,"X-axis scaling incorrect. Aborting" 2377 Abort 2378 while(0) //end of "case" statement for x-axis scaling 2379 End 2380 2381 Function ERescale(swave, ywave, xwave) 2382 String swave, ywave, xwave 2383 2384 Wave ew = $swave 2385 Wave yw = $ywave 2386 Wave xw = $xwave 2387 2388 //Scaling exponents and background value 2389 Variable pow_a,pow_b,pow_c 2390 ControlInfo/W=RescaleAxisPanel expa 2391 pow_a = V_value 2392 ControlInfo/W=RescaleAxisPanel expb 2393 pow_b = V_value 2394 ControlInfo/W=RescaleAxisPanel expc 2395 pow_c = V_value 2396 2397 //check for physical limits on exponent values 2398 // if bad values found, alert, and reset to good values so the rescaling can continue 2399 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 2400 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 2401 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 2402 if((pow_a < -2) || (pow_a > 10)) 2403 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 2404 gA = 1 2405 endif 2406 if((pow_b < 0) || (pow_b > 10)) 2407 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 2408 gB = 1 2409 endif 2410 //if q^c is the x-scaling, c must be be within limits and also non-zero 2411 ControlInfo/W=RescaleAxisPanel xModel 2412 If (cmpstr("q^c",S_Value) == 0) 2413 if(pow_c == 0) 2414 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 2415 gC = 1 2416 endif 2417 if((pow_c < -10) || (pow_c > 10)) 2418 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 2419 gC = 1 2420 endif 2421 endif 2422 2423 //variables set for each model to control look of graph 2424 String ystr, eWave 2425 //check for proper y-scaling selection, make the necessary waves 2426 // Wave yErrWave 2427 2428 ControlInfo/W=RescaleAxisPanel yModel 2429 ystr = S_Value 2430 do 2431 2432 If (cmpstr("I",S_Value) == 0) 2433 eWave = swave+"_RA" 2434 if (exists(eWave) == 0) 2435 Duplicate ew $eWave 2436 endif 2437 wave yErrWave = $eWave 2438 yErrWave = ew 2439 break 2440 endif 2441 If (cmpstr("ln(I)",S_Value) == 0) 2442 eWave = swave+"_RA" 2443 if (exists(eWave) == 0) 2444 Duplicate ew $eWave 2445 endif 2446 wave yErrWave = $eWave 2447 yErrWave = ew/yw 2448 break 2449 endif 2450 If (cmpstr("log(I)",S_Value) == 0) 2451 eWave = swave+"_RA" 2452 if (exists(eWave) == 0) 2453 Duplicate ew $eWave 2454 endif 2455 wave yErrWave = $eWave 2456 yErrWave = ew/(2.30*yw) 2457 break 2458 endif 2459 If (cmpstr("1/I",S_Value) == 0) 2460 eWave = swave+"_RA" 2461 if (exists(eWave) == 0) 2462 Duplicate ew $eWave 2463 endif 2464 wave yErrWave = $eWave 2465 yErrWave = ew/(yw^2) 2466 break 2467 endif 2468 If (cmpstr("I^a",S_Value) == 0) 2469 eWave = swave+"_RA" 2470 if (exists(eWave) == 0) 2471 Duplicate ew $eWave 2472 endif 2473 wave yErrWave = $eWave 2474 yErrWave = ew*abs(pow_a*(yw^(pow_a-1))) 2475 break 2476 endif 2477 If (cmpstr("Iq^a",S_Value) == 0) 2478 eWave = swave+"_RA" 2479 if (exists(eWave) == 0) 2480 Duplicate ew $eWave 2481 endif 2482 wave yErrWave = $eWave 2483 yErrWave = ew*xw^pow_a 2484 break 2485 endif 2486 If (cmpstr("I^a q^b",S_Value) == 0) 2487 eWave = swave+"_RA" 2488 if (exists(eWave) == 0) 2489 Duplicate ew $eWave 2490 endif 2491 wave yErrWave = $eWave 2492 yErrWave = ew*abs(pow_a*(yw^(pow_a-1)))*xw^pow_b 2493 break 2494 endif 2495 If (cmpstr("1/sqrt(I)",S_Value) == 0) 2496 eWave = swave+"_RA" 2497 if (exists(eWave) == 0) 2498 Duplicate ew $eWave 2499 endif 2500 wave yErrWave = $eWave 2501 yErrWave = 0.5*ew*yw^(-1.5) 2502 break 2503 endif 2504 If (cmpstr("ln(Iq)",S_Value) == 0) 2505 eWave = swave+"_RA" 2506 if (exists(eWave) == 0) 2507 Duplicate ew $eWave 2508 endif 2509 wave yErrWave = $eWave 2510 yErrWave =ew/yw 2511 break 2512 endif 2513 If (cmpstr("ln(Iq^2)",S_Value) == 0) 2514 eWave = swave+"_RA" 2515 if (exists(eWave) == 0) 2516 Duplicate ew $eWave 2517 endif 2518 wave yErrWave = $eWave 2519 yErrWave = ew/yw 2520 break 2521 endif 2522 //more ifs for each case 2523 2524 // if selection not found, abort 2525 DoAlert 0,"Y-axis scaling incorrect. Aborting" 2526 Abort 2527 while(0) //end of "case" statement for y-axis scaling 2528 2529 End 2530 2531 /////////////////////////// 2532 2170 2171 cw[whichparam] = originalvalue 2172 2173 2174 WaveStats/Q chi2_map 2175 minIndex = V_minRowLoc 2176 // Print "minimum at: ", minIndex,chi2_map[minIndex] 2177 2178 killwaves/z theoretical_data, chi2_data 2179 return(minIndex) 2180 End 2181 2182 ////////////////////////// -
sans/Dev/trunk/NCNR_User_Procedures/Analysis/SA_includes_v410.ipf
r884 r941 43 43 "Show Correlation Matrix",DisplayCovariance() 44 44 "Map Chi-Squared",MapChiSquared() 45 "Manually Optimize Parameters",OpenManualFitPanel() 45 46 end 46 47 "-" -
sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf
r916 r941 1563 1563 End 1564 1564 1565 1566 //////////////////////////////////// 1567 // Modification from Matt Wasbrough to allow rescaling of the 1568 // axes while plotting and fitting. allows export of the rescaled 1569 // data and of the rescaled model 1570 // Nov 2012 1571 /// 1572 1573 Function UseRescaleAxisCheckProc(cba) : CheckBoxControl 1574 STRUCT WMCheckboxAction &cba 1575 1576 switch( cba.eventCode ) 1577 case 2: // mouse up 1578 Variable checked = cba.checked 1579 if(checked) 1580 Execute "OpenAxisPanel()" 1581 else 1582 if(exists("RescaleAxisPanel") !=0) 1583 DoWindow/K RescaleAxisPanel 1584 endif 1585 endif 1586 break 1587 endswitch 1588 1589 return 0 1590 End 1591 1592 Proc OpenAxisPanel() 1593 If(WinType("RescaleAxisPanel") == 0) 1594 //create the necessary data folder 1595 NewDataFolder/O root:Packages 1596 NewDataFolder/O root:Packages:NIST 1597 NewDataFolder/O root:Packages:NIST:RescaleAxis 1598 //initialize the values 1599 Variable/G root:Packages:NIST:RescaleAxis:gRAExpA = 1 1600 Variable/G root:Packages:NIST:RescaleAxis:gRAExpB = 1 1601 Variable/G root:Packages:NIST:RescaleAxis:gRAExpC = 1 1602 RescaleAxisPanel() 1603 else 1604 //window already exists, just bring to front for update 1605 DoWindow/F RescaleAxisPanel 1606 endif 1607 End 1608 1609 Window RescaleAxisPanel() 1610 PauseUpdate; Silent 1 // building window... 1611 NewPanel /W=(461,46,735,195)/K=1 1612 ModifyPanel cbRGB=(49360,30954,64507), fixedSize=1 1613 SetDrawLayer UserBack 1614 PopupMenu ymodel,pos={20,10},size={76,19},title="y-axis" 1615 PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"} 1616 PopupMenu ymodel,mode=1,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\"" 1617 Button GoRescale,pos={50,80},size={70,20},proc=RescalePlot,title="Rescale" 1618 Button GoRescale,help={"This button will rescale the axis using the selections in this panel"} 1619 Button DoneButton,pos={170,80},size={70,20},proc=RADoneButton,title="Done" 1620 Button DoneButton,help={"This button will close the panel"} 1621 Button ExportData, pos={100,110}, size={90,20}, proc=ExportData, title="Export Data" 1622 Button ExportData, help={"This button will export data from the top graph"} 1623 SetVariable expa,pos={13,45},size={80,17},title="pow \"a\"" 1624 SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"} 1625 SetVariable expa,limits={-2,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpA 1626 SetVariable expb,pos={98,45},size={80,17},title="pow \"b\"" 1627 SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"} 1628 SetVariable expb,limits={0,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpB 1629 PopupMenu xmodel,pos={155,10},size={79,19},title="x-axis" 1630 PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"} 1631 PopupMenu xmodel,mode=1,value= #"\"q;log(q);q^2;q^c\"" 1632 SetVariable expc,pos={182,45},size={80,17},title="pow \"c\"" 1633 SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"} 1634 SetVariable expc,limits={-10,10,0},value= root:Packages:NIST:RescaleAxis:gRAExpC 1635 Button RAHelp, pos={220,110}, size={20,20}, proc=RAHelpButtonProc, title="?" 1636 EndMacro 1637 1638 Proc RADoneButton(ctrlName): ButtonControl 1639 String ctrlName 1640 DoWindow/K RescaleAxisPanel 1641 DoWindow/F WrapperPanel 1642 CheckBox check_8 value=0 1643 end 1644 1645 Function RAHelpButtonProc(ba) : ButtonControl 1646 STRUCT WMButtonAction &ba 1647 1648 switch( ba.eventCode ) 1649 case 2: // mouse up 1650 // click code here 1651 DisplayHelpTopic/Z/K=1 "Rescaled Axis" 1652 if(V_flag !=0) 1653 DoAlert 0,"The Rescaled Axis Help file could not be found" 1654 endif 1655 break 1656 endswitch 1657 1658 return 0 1659 End 1660 1661 Proc ExportData(ctrlName): ButtonControl 1662 string ctrlName 1663 WriteRescaledData() 1664 End 1665 1666 1667 Function RescalePlot (ctrlName): ButtonControl 1668 String ctrlName 1669 SetDataFolder root: 1670 String topGraph= WinName(0,1) //this is the topmost graph 1671 if(strlen(topGraph)==0) 1672 Abort "There is no graph" 1673 endif 1674 1675 DoWindow/F $topGraph 1676 GetWindow/Z $topGraph, wavelist 1677 wave/t W_Wavelist 1678 SetDataFolder root:Packages:NIST:RescaleAxis 1679 if (exists("W_WaveList")==1) 1680 KillWaves/Z root:Packages:NIST:RescaleAxis:W_WaveList 1681 endif 1682 MoveWave root:W_WaveList, root:Packages:NIST:RescaleAxis:W_WaveList 1683 SetDataFolder root:Packages:NIST:RescaleAxis 1684 variable i,j,k 1685 string DF,DF1,temp, temp2, t1 1686 for (i=0; i < numpnts(W_WaveList)/3; i+=1) 1687 temp = W_WaveList[i][1] 1688 if (stringmatch(temp, "*_i") || stringmatch(temp, "*_i_RA")) 1689 temp = W_WaveList[i][0] 1690 if(stringmatch(temp, "*_i")) 1691 temp = removeending(temp, "_i") 1692 elseif(stringmatch(temp, "*_i_RA")) 1693 temp = removeending(temp, "_i_RA") 1694 endif 1695 Make/T/O $temp/Wave=tempWave 1696 DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") 1697 if (strlen(DF) ==0) 1698 DF = ":" 1699 endif 1700 DF1 = "root"+DF 1701 tempWave[0] = DF1 1702 k = 1 1703 for(j=0;j<numpnts(W_WaveList)/3; j+=1) 1704 if (stringmatch(W_WaveList[j][1], "*"+temp+"*")) 1705 tempWave[k] = W_WaveList[j][0] 1706 k = k+1 1707 endif 1708 endfor 1709 redimension/N=(k) tempWave 1710 elseif(stringmatch(temp, "*ywave*")) 1711 temp = W_WaveList[i][0] 1712 if(stringmatch(temp, "*_RA")) 1713 temp = removeending(temp, "_RA") 1714 endif 1715 Make/T/O $temp/Wave=tempWave 1716 DF = ReplaceString(W_Wavelist[i][0],W_Wavelist[i][1],"") 1717 if (strlen(DF) ==0) 1718 DF = ":" 1719 endif 1720 DF1 = "root"+DF 1721 tempWave[0] = DF1 1722 temp2 = replacestring("ywave", temp, "") 1723 k = 1 1724 for(j=0;j<numpnts(W_WaveList)/3; j+=1) 1725 t1 = W_Wavelist[j][1] 1726 if (stringmatch(W_WaveList[j][1], "*wave"+temp2+"*")) 1727 tempWave[k] = W_WaveList[j][1] 1728 k = k+1 1729 endif 1730 endfor 1731 redimension/N=(k) tempWave 1732 endif 1733 endfor 1734 KillWaves/Z W_Wavelist 1735 string listWave = Wavelist("*", ";", "TEXT:1") 1736 string WaveToRescale, WaveDataFolder,xwave, ywave, swave 1737 1738 for (i = 0; i < ItemsInList(listWave,";"); i+=1) 1739 temp = StringFromList(i,listWave,";") 1740 Wave/T WaveString = $temp 1741 for (j=1; j < numpnts(WaveString); j+=1) 1742 WaveToRescale = Wavestring[j] 1743 if (stringmatch(WaveToRescale, "*_RA")) 1744 WaveToRescale = RemoveEnding(WaveToRescale, "_RA") 1745 endif 1746 WaveDataFolder = WaveString[0] 1747 SetDataFolder $WaveDataFolder 1748 if (stringmatch(WaveToRescale, "*_q")) 1749 xwave = WaveToRescale 1750 XRescale(xwave) 1751 elseif (stringmatch(WaveToRescale, "*_i")) 1752 ywave = WaveToRescale 1753 xwave = RemoveEnding(WaveToRescale, "_i")+"_q" 1754 YRescale(ywave, xwave) 1755 elseif (stringmatch(WaveToRescale, "*_s")) 1756 swave = WaveToRescale 1757 ywave = RemoveEnding(WaveToRescale, "_s")+"_i" 1758 xwave = RemoveEnding(WaveToRescale, "_s")+"_q" 1759 ERescale(swave, ywave, xwave) 1760 elseif (stringmatch(WaveToRescale, "xwave_*")) 1761 xwave=WaveToRescale 1762 XRescale(xwave) 1763 elseif (stringmatch(WaveToRescale, "ywave_*")) 1764 ywave = WaveToRescale 1765 xwave= ReplaceString("ywave", WaveToRescale, "xwave") 1766 YRescale(ywave, xwave) 1767 elseif(stringmatch(WaveToRescale, "*_qvals")) 1768 xwave = WaveToRescale 1769 XRescale(xwave) 1770 elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) 1771 ywave = WaveToRescale 1772 for (k=1; k < numpnts(WaveString); k+=1) 1773 if (stringmatch(Wavestring[k], "*_qvals")) 1774 xwave = Wavestring[k] 1775 endif 1776 endfor 1777 YRescale(ywave, xwave) 1778 else 1779 ywave = WaveToRescale 1780 for (k=1; k < numpnts(WaveString); k+=1) 1781 if (stringmatch(Wavestring[k], "*_q")) 1782 xwave = Wavestring[k] 1783 endif 1784 endfor 1785 YRescale(ywave,xwave) 1786 string yAxis = ywave+"_RA" 1787 wave yAxisWave = $yAxis 1788 SetFormula yAxisWave, "YRescale(ywave,xwave)" 1789 endif 1790 SetDataFolder root:Packages:NIST:RescaleAxis 1791 endfor 1792 endfor 1793 1794 string oldywave, xstr, ystr 1795 for (i = 0; i < ItemsInList(listWave,";"); i+=1) 1796 temp = StringFromList(i,listWave,";") 1797 Wave/T WaveString = $temp 1798 for (j=1; j < numpnts(WaveString); j+=1) 1799 WaveToRescale = Wavestring[j] 1800 WaveDataFolder = WaveString[0] 1801 SetDataFolder $WaveDataFolder 1802 ControlInfo/W=RescaleAxisPanel yModel 1803 ystr = S_Value 1804 ControlInfo/W=RescaleAxisPanel xModel 1805 xstr = S_Value 1806 if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) 1807 if(stringmatch(WaveToRescale, "*_i_RA")) 1808 oldywave = WaveToRescale 1809 ywave = RemoveEnding(WaveToRescale,"_RA") 1810 xwave = RemoveEnding(WaveToRescale, "_i_RA")+"_q" 1811 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1812 replacewave/X/W=$topGraph trace=$ywave, $xwave 1813 swave = RemoveEnding(WaveToRescale, "_i_RA")+"_s" 1814 if(exists(swave)==1) 1815 ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) 1816 endif 1817 elseif (stringmatch(WaveToRescale, "smeared*")) 1818 if(stringmatch(WaveToRescale,"*_RA") && stringmatch(WaveToRescale,"!*_qvals*") ) 1819 oldywave = WaveToRescale 1820 ywave = RemoveEnding(WaveToRescale,"_RA") 1821 xwave = "smeared_qvals" 1822 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1823 replacewave/X/W=$topGraph trace=$ywave, $xwave 1824 endif 1825 elseif(stringmatch(WaveToRescale,"ywave*") && stringmatch(WaveToRescale,"*_RA")) 1826 oldywave = WaveToRescale 1827 ywave = RemoveEnding(WaveToRescale,"_RA") 1828 xwave = ReplaceString("ywave",ywave,"xwave") 1829 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1830 replacewave/X/W=$topGraph trace=$ywave, $xwave 1831 elseif(stringmatch(WaveToRescale, "*FitYw*") && stringmatch(WaveToRescale, "*_RA")) 1832 oldywave = WaveToRescale 1833 ywave = RemoveEnding(WaveToRescale,"_RA") 1834 for (k=1; k < numpnts(WaveString); k+=1) 1835 if (stringmatch(Wavestring[k], "*_q")) 1836 xwave = Wavestring[k] 1837 endif 1838 endfor 1839 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1840 replacewave/X/W=$topGraph trace=$ywave, $xwave 1841 endif 1842 elseif(stringmatch(WaveToRescale, "*_RA")) 1843 elseif (stringmatch(WaveToRescale, "*_i")) 1844 DoWindow/F topGraph 1845 oldywave = WaveToRescale 1846 xwave = RemoveEnding(WaveToRescale, "_i")+"_q_RA" 1847 ywave = WaveToRescale + "_RA" 1848 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1849 replacewave/X/W=$topGraph trace=$ywave, $xwave 1850 ModifyGraph log=0 1851 swave = RemoveEnding(WaveToRescale, "_i")+"_s_RA" 1852 if(exists(swave)==1) 1853 ErrorBars/T=0/W=$topGraph $ywave, Y wave=($swave,$swave) 1854 endif 1855 DoUpdate 1856 elseif(stringmatch(WaveToRescale, "smeared*") && stringmatch(WaveToRescale, "!*_qvals")) 1857 oldywave = WaveToRescale 1858 ywave = WaveToRescale + "_RA" 1859 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1860 xwave = "smeared_qvals_RA" 1861 replacewave/X/W=$topGraph trace=$ywave, $xwave 1862 elseif(stringmatch(WaveToRescale,"ywave*")) 1863 oldywave = WaveToRescale 1864 ywave = WaveToRescale + "_RA" 1865 xwave = ReplaceString("ywave",ywave,"xwave") 1866 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1867 replacewave/X/W=$topGraph trace=$ywave, $xwave 1868 elseif(stringmatch(WaveToRescale, "*FitYw*")) 1869 oldywave = WaveToRescale 1870 ywave = WaveToRescale+"_RA" 1871 for (k=1; k < numpnts(WaveString); k+=1) 1872 if (stringmatch(Wavestring[k], "*_q")) 1873 xwave = Wavestring[k]+"_RA" 1874 endif 1875 endfor 1876 replacewave/Y/W=$topGraph trace=$oldywave, $ywave 1877 replacewave/X/W=$topGraph trace=$ywave, $xwave 1878 endif 1879 SetDataFolder root:Packages:NIST:RescaleAxis 1880 DoUpdate 1881 endfor 1882 endfor 1883 KillWaves/A/Z 1884 1885 string ylabel, xlabel 1886 ControlInfo/W=RescaleAxisPanel yModel 1887 ystr = S_Value 1888 ControlInfo/W=RescaleAxisPanel xModel 1889 xstr = S_Value 1890 1891 if(cmpstr("I",ystr)==0 && cmpstr("q",xstr)==0) 1892 modifygraph log=1 1893 else 1894 modifygraph log=0 1895 endif 1896 1897 Variable pow_a,pow_b,pow_c 1898 ControlInfo/W=RescaleAxisPanel expa 1899 pow_a = V_value 1900 ControlInfo/W=RescaleAxisPanel expb 1901 pow_b = V_value 1902 ControlInfo/W=RescaleAxisPanel expc 1903 pow_c = V_value 1904 1905 If (cmpstr("I",ystr) == 0) 1906 ylabel = "I(q)" 1907 elseif (cmpstr("ln(I)",ystr) == 0) 1908 ylabel = "ln(I)" 1909 elseif (cmpstr("log(I)",ystr) == 0) 1910 ylabel = "log(I)" 1911 elseif (cmpstr("1/I",ystr) == 0) 1912 ylabel = "1/I" 1913 elseif (cmpstr("I^a",ystr) == 0) 1914 ylabel = "I\S"+num2str(pow_a)+"\M" 1915 elseif (cmpstr("Iq^a",ystr) == 0) 1916 ylabel = "Iq\S"+num2str(pow_a)+"\M" 1917 elseif (cmpstr("I^a q^b",ystr) == 0) 1918 ylabel = "I\S"+num2str(pow_a)+"\Mq\S"+num2str(pow_b)+"\M" 1919 elseif (cmpstr("1/sqrt(I)",ystr) == 0) 1920 ylabel = "1/sqrt(I)" 1921 elseif (cmpstr("ln(Iq)",ystr) == 0) 1922 ylabel = "ln(Iq)" 1923 elseif (cmpstr("ln(Iq^2)",ystr) == 0) 1924 ylabel = "ln(Iq\S2\M)" 1925 endif 1926 1927 If (cmpstr("q",xstr) == 0) 1928 xlabel = "q (A\S-1\M)" 1929 elseif (cmpstr("q^2",xstr) == 0) 1930 xlabel = "q\S2\M" 1931 elseif (cmpstr("log(q)",xstr) == 0) 1932 xlabel = "log(q)" 1933 elseif (cmpstr("q^c",xstr) == 0) 1934 xlabel = "q\S"+num2str(pow_c)+"\M" 1935 endif 1936 1937 SetAxis/A 1938 Label left ylabel 1939 Label bottom xlabel 1940 1941 SetDataFolder root: 1942 End 1943 1944 Function YRescale(ywave, xwave) 1945 String ywave,xwave 1946 1947 Wave yw = $ywave 1948 Wave xw = $xwave 1949 1950 //Scaling exponents and background value 1951 Variable pow_a,pow_b,pow_c 1952 ControlInfo/W=RescaleAxisPanel expa 1953 pow_a = V_value 1954 ControlInfo/W=RescaleAxisPanel expb 1955 pow_b = V_value 1956 ControlInfo/W=RescaleAxisPanel expc 1957 pow_c = V_value 1958 1959 //check for physical limits on exponent values 1960 // if bad values found, alert, and reset to good values so the rescaling can continue 1961 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 1962 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 1963 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 1964 if((pow_a < -2) || (pow_a > 10)) 1965 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 1966 gA = 1 1967 endif 1968 if((pow_b < 0) || (pow_b > 10)) 1969 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 1970 gB = 1 1971 endif 1972 //if q^c is the x-scaling, c must be be within limits and also non-zero 1973 ControlInfo/W=RescaleAxisPanel xModel 1974 If (cmpstr("q^c",S_Value) == 0) 1975 if(pow_c == 0) 1976 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 1977 gC = 1 1978 endif 1979 if((pow_c < -10) || (pow_c > 10)) 1980 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 1981 gC = 1 1982 endif 1983 endif 1984 1985 //variables set for each model to control look of graph 1986 String ystr, yAxis 1987 //check for proper y-scaling selection, make the necessary waves 1988 // Wave yAxisWave 1989 1990 ControlInfo/W=RescaleAxisPanel yModel 1991 ystr = S_Value 1992 1993 do 1994 If (cmpstr("I",S_Value) == 0) 1995 yAxis = ywave+"_RA" 1996 if (exists(yAxis)== 0) 1997 Duplicate yw $yAxis 1998 endif 1999 SetScale d 0,0,"1/cm",$yAxis 2000 wave yAxisWave = $yAxis 2001 yAxisWave = yw 2002 break 2003 endif 2004 If (cmpstr("ln(I)",S_Value) == 0) 2005 yAxis = ywave+"_RA" 2006 if (exists(yAxis)== 0) 2007 Duplicate yw $yAxis 2008 endif 2009 SetScale d 0,0,"",$yAxis 2010 wave yAxisWave = $yAxis 2011 yAxisWave = ln(yw) 2012 break 2013 endif 2014 If (cmpstr("log(I)",S_Value) == 0) 2015 yAxis = ywave+"_RA" 2016 if (exists(yAxis)== 0) 2017 Duplicate yw $yAxis 2018 endif 2019 SetScale d 0,0,"",$yAxis 2020 wave yAxisWave = $yAxis 2021 yAxisWave = log(yw) 2022 break 2023 endif 2024 If (cmpstr("1/I",S_Value) == 0) 2025 yAxis = ywave+"_RA" 2026 if (exists(yAxis)== 0) 2027 Duplicate yw $yAxis 2028 endif 2029 SetScale d 0,0,"",$yAxis 2030 wave yAxisWave = $yAxis 2031 yAxisWave = 1/(yw) 2032 break 2033 endif 2034 If (cmpstr("I^a",S_Value) == 0) 2035 yAxis = ywave+"_RA" 2036 if (exists(yAxis)== 0) 2037 Duplicate yw $yAxis 2038 endif 2039 SetScale d 0,0,"",$yAxis 2040 wave yAxisWave = $yAxis 2041 yAxisWave = yw^pow_a 2042 break 2043 endif 2044 If (cmpstr("Iq^a",S_Value) == 0) 2045 yAxis = ywave+"_RA" 2046 if (exists(yAxis)== 0) 2047 Duplicate yw $yAxis 2048 endif 2049 SetScale d 0,0,"",$yAxis 2050 wave yAxisWave = $yAxis 2051 yAxisWave = yw*xw^pow_a 2052 break 2053 endif 2054 If (cmpstr("I^a q^b",S_Value) == 0) 2055 yAxis = ywave+"_RA" 2056 if (exists(yAxis)== 0) 2057 Duplicate yw $yAxis 2058 endif 2059 SetScale d 0,0,"",$yAxis 2060 wave yAxisWave = $yAxis 2061 yAxisWave = yw^pow_a*xw^pow_b 2062 break 2063 endif 2064 If (cmpstr("1/sqrt(I)",S_Value) == 0) 2065 yAxis = ywave+"_RA" 2066 if (exists(yAxis)== 0) 2067 Duplicate yw $yAxis 2068 endif 2069 SetScale d 0,0,"",$yAxis 2070 wave yAxisWave = $yAxis 2071 yAxisWave = 1/sqrt(yw) 2072 break 2073 endif 2074 If (cmpstr("ln(Iq)",S_Value) == 0) 2075 yAxis = ywave+"_RA" 2076 if (exists(yAxis)== 0) 2077 Duplicate yw $yAxis 2078 endif 2079 SetScale d 0,0,"",$yAxis 2080 wave yAxisWave = $yAxis 2081 yAxisWave = ln(xw*yw) 2082 break 2083 endif 2084 If (cmpstr("ln(Iq^2)",S_Value) == 0) 2085 yAxis = ywave+"_RA" 2086 if (exists(yAxis)== 0) 2087 Duplicate yw $yAxis 2088 endif 2089 SetScale d 0,0,"",$yAxis 2090 wave yAxisWave = $yAxis 2091 yAxisWave = ln(xw*xw*yw) 2092 break 2093 endif 2094 //more ifs for each case 2095 2096 // if selection not found, abort 2097 DoAlert 0,"Y-axis scaling incorrect. Aborting" 2098 Abort 2099 while(0) 2100 End 2101 2102 Function XRescale(xwave) 2103 String xwave 2104 2105 Wave xw = $xwave 2106 2107 //Scaling exponents and background value 2108 Variable pow_a,pow_b,pow_c 2109 ControlInfo/W=RescaleAxisPanel expa 2110 pow_a = V_value 2111 ControlInfo/W=RescaleAxisPanel expb 2112 pow_b = V_value 2113 ControlInfo/W=RescaleAxisPanel expc 2114 pow_c = V_value 2115 2116 //check for physical limits on exponent values 2117 // if bad values found, alert, and reset to good values so the rescaling can continue 2118 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 2119 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 2120 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 2121 if((pow_a < -2) || (pow_a > 10)) 2122 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 2123 gA = 1 2124 endif 2125 if((pow_b < 0) || (pow_b > 10)) 2126 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 2127 gB = 1 2128 endif 2129 //if q^c is the x-scaling, c must be be within limits and also non-zero 2130 ControlInfo/W=RescaleAxisPanel xModel 2131 If (cmpstr("q^c",S_Value) == 0) 2132 if(pow_c == 0) 2133 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 2134 gC = 1 2135 endif 2136 if((pow_c < -10) || (pow_c > 10)) 2137 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 2138 gC = 1 2139 endif 2140 endif 2141 2142 //variables set for each model to control look of graph 2143 String xstr, xAxis 2144 //check for proper y-scaling selection, make the necessary waves 2145 // Wave xAxisWave 2146 2147 ControlInfo/W=RescaleAxisPanel xModel 2148 xstr = S_Value 2149 do 2150 // make the new yaxis wave 2151 If (cmpstr("q",S_Value) == 0) 2152 xAxis = xwave+"_RA" 2153 if (exists(xAxis)== 0) 2154 Duplicate xw $xAxis 2155 endif 2156 SetScale d 0,0,"A^-1",$xAxis 2157 wave xAxisWave = $xAxis 2158 xAxisWave = xw 2159 break 2160 endif 2161 If (cmpstr("q^2",S_Value) == 0) 2162 xAxis = xwave+"_RA" 2163 if (exists(xAxis)== 0) 2164 Duplicate xw $xAxis 2165 endif 2166 SetScale d 0,0,"A^-2",$xAxis 2167 wave xAxisWave = $xAxis 2168 xAxisWave = xw*xw 2169 break 2170 endif 2171 If (cmpstr("log(q)",S_Value) == 0) 2172 xAxis = xwave+"_RA" 2173 if (exists(xAxis)== 0) 2174 Duplicate xw $xAxis 2175 endif 2176 SetScale d 0,0,"",$xAxis 2177 wave xAxisWave = $xAxis 2178 xAxisWave = log(xw) 2179 break 2180 endif 2181 If (cmpstr("q^c",S_Value) == 0) 2182 xAxis = xwave+"_RA" 2183 if (exists(xAxis)== 0) 2184 Duplicate xw $xAxis 2185 endif 2186 SetScale d 0,0,"", $xAxis 2187 wave xAxisWave = $xAxis 2188 xAxisWave = xw^pow_c 2189 break 2190 endif 2191 2192 //more ifs for each case 2193 // if selection not found, abort 2194 DoAlert 0,"X-axis scaling incorrect. Aborting" 2195 Abort 2196 while(0) //end of "case" statement for x-axis scaling 2197 End 2198 2199 Function ERescale(swave, ywave, xwave) 2200 String swave, ywave, xwave 2201 2202 Wave ew = $swave 2203 Wave yw = $ywave 2204 Wave xw = $xwave 2205 2206 //Scaling exponents and background value 2207 Variable pow_a,pow_b,pow_c 2208 ControlInfo/W=RescaleAxisPanel expa 2209 pow_a = V_value 2210 ControlInfo/W=RescaleAxisPanel expb 2211 pow_b = V_value 2212 ControlInfo/W=RescaleAxisPanel expc 2213 pow_c = V_value 2214 2215 //check for physical limits on exponent values 2216 // if bad values found, alert, and reset to good values so the rescaling can continue 2217 NVAR gA = root:Packages:NIST:RescaleAxis:gRAExpA 2218 NVAR gB = root:Packages:NIST:RescaleAxis:gRAExpB 2219 NVAR gC = root:Packages:NIST:RescaleAxis:gRAExpC 2220 if((pow_a < -2) || (pow_a > 10)) 2221 DoAlert 0,"Exponent a must be in the range (-2,10) - the exponent a has been reset to 1" 2222 gA = 1 2223 endif 2224 if((pow_b < 0) || (pow_b > 10)) 2225 DoAlert 0,"Exponent b must be in the range (0,10) - the exponent b has been reset to 1" 2226 gB = 1 2227 endif 2228 //if q^c is the x-scaling, c must be be within limits and also non-zero 2229 ControlInfo/W=RescaleAxisPanel xModel 2230 If (cmpstr("q^c",S_Value) == 0) 2231 if(pow_c == 0) 2232 DoAlert 0,"Exponent c must be non-zero, c has been reset to 1" 2233 gC = 1 2234 endif 2235 if((pow_c < -10) || (pow_c > 10)) 2236 DoAlert 0,"Exponent c must be in the range (-10,10), c has been reset to 1" 2237 gC = 1 2238 endif 2239 endif 2240 2241 //variables set for each model to control look of graph 2242 String ystr, eWave 2243 //check for proper y-scaling selection, make the necessary waves 2244 // Wave yErrWave 2245 2246 ControlInfo/W=RescaleAxisPanel yModel 2247 ystr = S_Value 2248 do 2249 2250 If (cmpstr("I",S_Value) == 0) 2251 eWave = swave+"_RA" 2252 if (exists(eWave) == 0) 2253 Duplicate ew $eWave 2254 endif 2255 wave yErrWave = $eWave 2256 yErrWave = ew 2257 break 2258 endif 2259 If (cmpstr("ln(I)",S_Value) == 0) 2260 eWave = swave+"_RA" 2261 if (exists(eWave) == 0) 2262 Duplicate ew $eWave 2263 endif 2264 wave yErrWave = $eWave 2265 yErrWave = ew/yw 2266 break 2267 endif 2268 If (cmpstr("log(I)",S_Value) == 0) 2269 eWave = swave+"_RA" 2270 if (exists(eWave) == 0) 2271 Duplicate ew $eWave 2272 endif 2273 wave yErrWave = $eWave 2274 yErrWave = ew/(2.30*yw) 2275 break 2276 endif 2277 If (cmpstr("1/I",S_Value) == 0) 2278 eWave = swave+"_RA" 2279 if (exists(eWave) == 0) 2280 Duplicate ew $eWave 2281 endif 2282 wave yErrWave = $eWave 2283 yErrWave = ew/(yw^2) 2284 break 2285 endif 2286 If (cmpstr("I^a",S_Value) == 0) 2287 eWave = swave+"_RA" 2288 if (exists(eWave) == 0) 2289 Duplicate ew $eWave 2290 endif 2291 wave yErrWave = $eWave 2292 yErrWave = ew*abs(pow_a*(yw^(pow_a-1))) 2293 break 2294 endif 2295 If (cmpstr("Iq^a",S_Value) == 0) 2296 eWave = swave+"_RA" 2297 if (exists(eWave) == 0) 2298 Duplicate ew $eWave 2299 endif 2300 wave yErrWave = $eWave 2301 yErrWave = ew*xw^pow_a 2302 break 2303 endif 2304 If (cmpstr("I^a q^b",S_Value) == 0) 2305 eWave = swave+"_RA" 2306 if (exists(eWave) == 0) 2307 Duplicate ew $eWave 2308 endif 2309 wave yErrWave = $eWave 2310 yErrWave = ew*abs(pow_a*(yw^(pow_a-1)))*xw^pow_b 2311 break 2312 endif 2313 If (cmpstr("1/sqrt(I)",S_Value) == 0) 2314 eWave = swave+"_RA" 2315 if (exists(eWave) == 0) 2316 Duplicate ew $eWave 2317 endif 2318 wave yErrWave = $eWave 2319 yErrWave = 0.5*ew*yw^(-1.5) 2320 break 2321 endif 2322 If (cmpstr("ln(Iq)",S_Value) == 0) 2323 eWave = swave+"_RA" 2324 if (exists(eWave) == 0) 2325 Duplicate ew $eWave 2326 endif 2327 wave yErrWave = $eWave 2328 yErrWave =ew/yw 2329 break 2330 endif 2331 If (cmpstr("ln(Iq^2)",S_Value) == 0) 2332 eWave = swave+"_RA" 2333 if (exists(eWave) == 0) 2334 Duplicate ew $eWave 2335 endif 2336 wave yErrWave = $eWave 2337 yErrWave = ew/yw 2338 break 2339 endif 2340 //more ifs for each case 2341 2342 // if selection not found, abort 2343 DoAlert 0,"Y-axis scaling incorrect. Aborting" 2344 Abort 2345 while(0) //end of "case" statement for y-axis scaling 2346 2347 End 2348 2349 /////////////////////////// 2350 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/EventModeProcessing.ipf
r934 r941 37 37 // points. Maybe not kosher, but would clean things up. 38 38 // 39 /////////////////////////////// 40 // 41 // NOTE -- to be able to show the T0 and PP event locations/times, force the loader to use the Igor code rather than 42 // the XOP. Then there will be waves generated with their locations: T0Time and T0EventNum, PPTime and PPEventNum. Edit these waves 43 // and (1) delete the zero points at the end of the waves and (2) multiply the Time wave * 1e-7 to convert to seconds. 44 // Then the waves can be plotted on top of the event data, so it can be seen where these events were identified. 39 45 // 40 46 /////////////// SWITCHES /////////////////
Note: See TracChangeset
for help on using the changeset viewer.