Ignore:
Timestamp:
Mar 29, 2007 1:45:45 PM (16 years ago)
Author:
srkline
Message:

Initial file shuffling, partially done.
Created 3 new files:
SANS_Utilities
NCNR_Utils
NCNR_DataReadWrite

(SANS_Utilites may eventually become NCNR-specific, but I'm not sure)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Transmission.ipf

    r47 r69  
    18071807End 
    18081808 
    1809 //****************** 
    1810 //lookup tables for attenuator transmissions 
    1811 //NG3 and NG7 attenuators are physically different, so the transmissions are slightly different 
    1812 //NG1 - (8m SANS) is not supported 
    1813  
    1814 Proc MakeNG3AttenTable() 
    1815  
    1816         NewDataFolder/O root:myGlobals:Attenuators 
    1817         //do explicitly to avoid data folder problems, redundant, but it must work without fail 
    1818         Make/O/N=9 root:myGlobals:Attenuators:ng3att0 
    1819         Make/O/N=9 root:myGlobals:Attenuators:ng3att1 
    1820         Make/O/N=9 root:myGlobals:Attenuators:ng3att2 
    1821         Make/O/N=9 root:myGlobals:Attenuators:ng3att3 
    1822         Make/O/N=9 root:myGlobals:Attenuators:ng3att4 
    1823         Make/O/N=9 root:myGlobals:Attenuators:ng3att5 
    1824         Make/O/N=9 root:myGlobals:Attenuators:ng3att6 
    1825         Make/O/N=9 root:myGlobals:Attenuators:ng3att7 
    1826         Make/O/N=9 root:myGlobals:Attenuators:ng3att8 
    1827         Make/O/N=9 root:myGlobals:Attenuators:ng3att9 
    1828         Make/O/N=9 root:myGlobals:Attenuators:ng3att10 
    1829          
    1830         //each wave has 8 elements, the transmission of att# at the wavelengths  
    1831         //lambda = 5,6,7,8,10,12,14,17 
    1832         Make/O/N=9 root:myGlobals:Attenuators:ng3lambda={5,6,7,8,10,12,14,17,20} 
    1833         root:myGlobals:Attenuators:ng3att0 = {1, 1, 1, 1, 1, 1, 1, 1,1 } 
    1834         root:myGlobals:Attenuators:ng3att1 = {0.421, 0.394, 0.371, 0.349, 0.316, 0.293, 0.274, 0.245,0.220} 
    1835         root:myGlobals:Attenuators:ng3att2 = {0.187, 0.164, 0.145, 0.130, 0.106, 0.0916, 0.0808, 0.0651,0.0531} 
    1836         root:myGlobals:Attenuators:ng3att3 = {0.0777, 0.0636, 0.0534, 0.0446, 0.0330, 0.0262, 0.0217, 0.0157 ,0.0116} 
    1837         root:myGlobals:Attenuators:ng3att4 = {0.0328, 0.0252, 0.0195, 0.0156, 0.0104, 7.68e-3, 5.98e-3, 3.91e-3,0.00262} 
    1838         root:myGlobals:Attenuators:ng3att5 = {0.0139, 9.94e-3, 7.34e-3, 5.44e-3, 3.29e-3, 2.25e-3, 1.66e-3, 9.95e-4, 6.12e-4} 
    1839         root:myGlobals:Attenuators:ng3att6 = {5.95e-3, 3.97e-3, 2.77e-3, 1.95e-3, 1.06e-3, 6.81e-4, 4.71e-4, 2.59e-4 , 1.45e-4} 
    1840         root:myGlobals:Attenuators:ng3att7 = {1.07e-3, 6.24e-4, 3.90e-4, 2.44e-4, 1.14e-4, 6.55e-5, 4.10e-5, 1.64e-5 , 7.26e-6} 
    1841         root:myGlobals:Attenuators:ng3att8 = {1.90e-4, 9.84e-5, 5.60e-5, 3.25e-5, 1.55e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} 
    1842         root:myGlobals:Attenuators:ng3att9 = {3.61e-5, 1.74e-5, 9.90e-6, 6.45e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} 
    1843         root:myGlobals:Attenuators:ng3att10 = {7.60e-6, 3.99e-6, 2.96e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9 , 8.60e-10} 
    1844  
    1845 End 
    1846  
    1847 Proc MakeNG7AttenTable() 
    1848  
    1849         NewDataFolder/O root:myGlobals:Attenuators 
    1850          
    1851         Make/O/N=9 root:myGlobals:Attenuators:ng7att0 
    1852         Make/O/N=9 root:myGlobals:Attenuators:ng7att1 
    1853         Make/O/N=9 root:myGlobals:Attenuators:ng7att2 
    1854         Make/O/N=9 root:myGlobals:Attenuators:ng7att3 
    1855         Make/O/N=9 root:myGlobals:Attenuators:ng7att4 
    1856         Make/O/N=9 root:myGlobals:Attenuators:ng7att5 
    1857         Make/O/N=9 root:myGlobals:Attenuators:ng7att6 
    1858         Make/O/N=9 root:myGlobals:Attenuators:ng7att7 
    1859         Make/O/N=9 root:myGlobals:Attenuators:ng7att8 
    1860         Make/O/N=9 root:myGlobals:Attenuators:ng7att9 
    1861         Make/O/N=9 root:myGlobals:Attenuators:ng7att10 
    1862          
    1863         //each wave has 8 elements, the transmission of att# at the wavelengths  
    1864         //lambda = 5,6,7,8,10,12,14,17 
    1865         Make/O/N=9 root:myGlobals:Attenuators:ng7lambda={5,6,7,8,10,12,14,17,20} 
    1866         root:myGlobals:Attenuators:ng7att0 = {1, 1, 1, 1, 1, 1, 1, 1 ,1} 
    1867         root:myGlobals:Attenuators:ng7att1 = {0.418, 0.393, 0.369, 0.347, 0.313, 0.291, 0.271, 0.244, 0.219 } 
    1868         root:myGlobals:Attenuators:ng7att2 = {0.189, 0.167, 0.148, 0.132, 0.109, 0.0945, 0.0830, 0.0681, 0.0560} 
    1869         root:myGlobals:Attenuators:ng7att3 = {0.0784, 0.0651, 0.0541, 0.0456, 0.0340, 0.0273, 0.0223, 0.0164 , 0.0121} 
    1870         root:myGlobals:Attenuators:ng7att4 = {0.0328, 0.0256, 0.0200, 0.0159, 0.0107, 7.98e-3, 6.14e-3, 4.09e-3 , 0.00274} 
    1871         root:myGlobals:Attenuators:ng7att5 = {0.0139, 0.0101, 7.43e-3, 5.58e-3, 3.42e-3, 2.36e-3, 1.70e-3, 1.03e-3 , 6.27e-4} 
    1872         root:myGlobals:Attenuators:ng7att6 = {5.90e-3, 4.07e-3, 2.79e-3, 1.99e-3, 1.11e-3, 7.13e-4, 4.91e-4, 2.59e-4 , 1.42e-4} 
    1873         root:myGlobals:Attenuators:ng7att7 = {1.04e-3, 6.37e-4, 3.85e-4, 2.46e-4, 1.16e-4, 6.86e-5, 4.10e-5, 1.64e-5 ,7.02e-6} 
    1874         root:myGlobals:Attenuators:ng7att8 = {1.90e-4, 1.03e-4, 5.71e-5, 3.44e-5, 1.65e-5, 6.60e-6, 3.42e-6, 1.04e-6 , 3.48e-7} 
    1875         root:myGlobals:Attenuators:ng7att9 = {3.58e-5, 1.87e-5, 1.05e-5, 7.00e-6, 2.35e-6, 6.35e-7, 2.86e-7, 6.61e-8 , 1.73e-8} 
    1876         root:myGlobals:Attenuators:ng7att10 = {7.76e-6, 4.56e-6, 3.25e-6, 2.03e-6, 3.34e-7, 6.11e-8, 2.39e-8, 4.19e-9, 8.60e-10} 
    1877          
    1878 End 
    1879  
    1880 //returns the transmission of the attenuator (at NG3) given the attenuator number 
    1881 //which must be an integer(to select the wave) and given the wavelength. 
    1882 //the wavelength may be any value between 5 and 20 (A), and is interpolated 
    1883 //between calibrated wavelengths for a given attenuator 
    1884 Function LookupAttenNG3(lambda,attenNo) 
    1885         Variable lambda, attenNo 
    1886          
    1887         Variable trans 
    1888         String attStr="root:myGlobals:Attenuators:ng3att"+num2str(trunc(attenNo)) 
    1889         String lamStr = "root:myGlobals:Attenuators:ng3lambda" 
    1890          
    1891         if(attenNo == 0) 
    1892                 return (1)              //no attenuation, return trans == 1 
    1893         endif 
    1894          
    1895         if( (lambda < 5) || (lambda > 20 ) ) 
    1896                 Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" 
    1897         Endif 
    1898          
    1899         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 
    1900                 Execute "MakeNG3AttenTable()" 
    1901         Endif 
    1902         //just in case creating the tables fails.... 
    1903         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 
    1904                 Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" 
    1905         Endif 
    1906          
    1907         //lookup the value by interpolating the wavelength 
    1908         //the attenuator must always be an integer 
    1909         Wave att = $attStr 
    1910         Wave lam = $lamstr 
    1911         trans = interp(lambda,lam,att) 
    1912          
    1913 //      Print "trans = ",trans 
    1914          
    1915         return trans 
    1916 End 
    1917  
    1918 //returns the transmission of the attenuator (at NG7) given the attenuator number 
    1919 //which must be an integer(to select the wave) and given the wavelength. 
    1920 //the wavelength may be any value between 5 and 20 (A), and is interpolated 
    1921 //between calibrated wavelengths for a given attenuator 
    1922 // 
    1923 // this set of tables is also used for NG5 (NG1) SANS instrument - as the attenuator has yet to be calibrated 
    1924 Function LookupAttenNG7(lambda,attenNo) 
    1925         Variable lambda, attenNo 
    1926          
    1927         Variable trans 
    1928         String attStr="root:myGlobals:Attenuators:ng7att"+num2str(trunc(attenNo)) 
    1929         String lamStr = "root:myGlobals:Attenuators:ng7lambda" 
    1930          
    1931         if(attenNo == 0) 
    1932                 return (1)              //no attenuation, return trans == 1 
    1933         endif 
    1934          
    1935         if( (lambda < 5) || (lambda > 20 ) ) 
    1936                 Abort "Wavelength out of calibration range (5,20). You must manually enter the absolute parameters" 
    1937         Endif 
    1938          
    1939         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 
    1940                 Execute "MakeNG7AttenTable()" 
    1941         Endif 
    1942         //just in case creating the tables fails.... 
    1943         if(!(WaveExists($attStr)) || !(WaveExists($lamStr)) ) 
    1944                 Abort "Attenuator lookup waves could not be found. You must manually enter the absolute parameters" 
    1945         Endif 
    1946          
    1947         //lookup the value by interpolating the wavelength 
    1948         //the attenuator must always be an integer 
    1949         Wave att = $attStr 
    1950         Wave lam = $lamstr 
    1951         trans = interp(lambda,lam,att) 
    1952          
    1953         //Print "trans = ",trans 
    1954          
    1955         return trans 
    1956  
    1957 End 
    1958  
    1959 //returns the proper attenuation factor based on the instrument (NG3, NG5, or NG7) 
    1960 //NG5 values are taken from the NG7 tables (there is very little difference in the 
    1961 //values, and NG5 attenuators have not been calibrated (as of 8/01) 
    1962 //filestr as passed is textread[3], the default directory 
    1963 Function AttenuationFactor(fileStr,lam,attenNo) 
    1964         String fileStr 
    1965         Variable lam,attenNo 
    1966          
    1967         Variable attenFactor=1,loc 
    1968         String instr=fileStr[1,3]       //filestr is "[NGnSANSn] " or "[NGnSANSnn]" (11 characters total) 
    1969          
    1970         strswitch(instr) 
    1971                 case "NG3": 
    1972                         attenFactor = LookupAttenNG3(lam,attenNo) 
    1973                         break 
    1974                 case "NG5": 
    1975                         //using NG7 lookup Table 
    1976                         attenFactor = LookupAttenNG7(lam,attenNo) 
    1977                         break 
    1978                 case "NG7": 
    1979                         attenFactor = LookupAttenNG7(lam,attenNo) 
    1980                         break 
    1981                 default:                                                         
    1982                         //return error? 
    1983                         attenFactor=1 
    1984         endswitch 
    1985 //      print "instr, lambda, attenNo,attenFactor = ",instr,lam,attenNo,attenFactor 
    1986         return(attenFactor) 
    1987 End 
     1809 
    19881810 
    19891811//******************* 
Note: See TracChangeset for help on using the changeset viewer.