Changeset 941 for sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf
- Timestamp:
- Jun 4, 2014 4:01:26 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.