Ignore:
Timestamp:
Nov 16, 2017 10:57:32 AM (5 years ago)
Author:
srkline
Message:

lots of changes here:
many little fixes to clean up TODO items and marke them DONE

changed the handling of the panel "gap" to split the gap evenly. Q-calculations have been re-verified with this change.

re-named the list of "bin Type" values, and added a few more choices. Streamlined how the averaging and plotting works with this list so that it can be more easily modified as different combinations of binning are envisioned. This resulted in a lot of excess code being cut out and replaced with cleaner logic. This change has also been verified to work as intended.

Attenuation is now always calculated from the table. The table also by (NEW) definition has values for the white beam (one waelength) and graphite (multiple possible wavelengths) where the wavelengths are artificially scaled (*1000) or *1e6) so that the interpolations can be done internally without the need for multiple attenuator tables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Attenuation.ipf

    r1071 r1073  
    33 
    44 
     5// 
     6// 7-NOV-2017 
     7//  
     8// The attenuator tables are more complex now - since there are more ways to select wavelength 
     9// - there is the standard velocity selector (no tilt) 
     10// - a white beam mode (with a non-symmetric distribution) 
     11// - a graphite monochromator, allowing wavelength selection 
     12// 
     13// To accomodate this, I have chosen to alter the table to allow all of the wavelength "modes" 
     14// to be in the same table for interpolation, by use of the "correct" input wavelength 
     15// velocity_selector lambda is input as is 
     16// white beam lambda = (lambda * 1e3) 
     17// graphite crystal lambda = (lambda * 1e6) 
     18// 
     19// in this way, the interpolation will work just fine. Otherwise, the only solution I could see was to  
     20// have separate tables stored in the header for each of the "modes". 
     21// 
     22// 
     23 
     24// 
    525// functions to calculate attenuator values from the tables 
    626// 
     
    929// 
    1030// interpolate if necessary 
    11  
     31// 
    1232 
    1333// 
     
    1535// 
    1636// 
    17 // 
    18  
    19  
    20 // attenuator tables are currently /N=(8,17) 
     37// attenuator tables are currently /N=(n,17) 
    2138 
    2239 
     
    5471Proc V_WriteCSVAttenTable(lo,hi,atten_values) 
    5572        Variable lo,hi 
    56         String atten_values 
     73        String atten_values="atten_values" 
    5774 
    5875        V_fPatchAttenValueTable(lo,hi,$atten_values) 
     
    6178Proc V_WriteCSVAttenErrTable(lo,hi,atten_err) 
    6279        Variable lo,hi 
    63         String atten_err 
     80        String atten_err="atten_err" 
    6481 
    6582        V_fPatchAttenErrTable(lo,hi,$atten_err) 
     
    7895        String fname 
    7996         
    80         // check the dimensions of the attenW (8,17) 
    81         if (DimSize(attenW, 0) != 8 || DimSize(attenW, 1) != 17 ) 
    82                 Abort "attenuator wave is not of proper dimension (8,17)" 
    83         endif 
     97//      // check the dimensions of the attenW (8,17) 
     98//      if (DimSize(attenW, 0) != 8 || DimSize(attenW, 1) != 17 ) 
     99//              Abort "attenuator wave is not of proper dimension (8,17)" 
     100//      endif 
    84101         
    85102        //loop over all files 
     
    107124        String fname 
    108125         
    109         // check the dimensions of the attenW (8,17) 
    110         if (DimSize(attenW, 0) != 8 || DimSize(attenW, 1) != 17 ) 
    111                 Abort "attenuator wave is not of proper dimension (8,17)" 
    112         endif 
     126//      // check the dimensions of the attenW (8,17) 
     127//      if (DimSize(attenW, 0) != 8 || DimSize(attenW, 1) != 17 ) 
     128//              Abort "attenuator wave is not of proper dimension (8,17)" 
     129//      endif 
    113130         
    114131        //loop over all files 
     
    132149// 
    133150// fill in a "dummy" wavelength for White Beam and graphite 
    134 // == 100 for White Beam 
    135 // == 1000 for graphite 
     151// *= 1e3 for White Beam 
     152// *= 1e6 for graphite 
    136153// use these dummy values just for the lookup table 
    137154// 
    138155// TODO -- need the enumerated values for the monochromator type 
    139156// TODO -- V_getMonochromatorType(fname) is NOT written correctly by NICE 
    140 // 
     157// TODO -- determine the dimensions of the wave, don't hard-wire 
     158// TODO -- update to use separate tables for each monochromator mode 
     159// TODO -- (same updates for the error table) 
    141160// 
    142161Function V_CalculateAttenuationFactor(fname) 
     
    162181                        break           // exit from switch 
    163182                case "white_beam":      // execute if case matches expression 
    164                         lambda = 100 
     183                        lambda *= 1e3 
    165184                        break 
    166185                case "crystal": 
    167                         lambda = 1000 
     186                        lambda *= 1e6 
    168187                        break 
    169188                default:                        // optional default expression executed 
     
    172191         
    173192         
    174         Wave w = V_getAttenIndex_table(fname)           // N=(8,17) 
    175         Make/O/D/N=8 tmpVal,tmpLam 
     193        Wave w = V_getAttenIndex_table(fname)           // N=(x,17) 
     194        Variable num = DimSize(w,0) 
     195        Make/O/D/N=(num) tmpVal,tmpLam                                           
    176196         
    177197        tmpVal = w[p][numAtt+1]         // offset by one, 1st column is wavelength 
    178198        tmpLam = w[p][0] 
    179199        val = interp(lambda, tmpLam, tmpVal ) 
     200        Print "Calculated Atten = ",val 
    180201         
    181202        //killwaves/Z tmpVal,tmpLam 
     
    189210// 
    190211// fill in a "dummy" wavelength for White Beam and graphite 
    191 // == 100 for White Beam 
    192 // == 1000 for graphite 
     212// *= 1e3 for White Beam 
     213// *= 1e6 for graphite 
    193214// use these dummy values just for the lookup table 
    194215// 
     
    196217// TODO -- V_getMonochromatorType(fname) is NOT written correctly by NICE 
    197218// 
     219// 
    198220Function V_CalculateAttenuationError(fname) 
    199221        String fname 
     
    206228         
    207229        // TODO -- need to switch on "type" 
    208         //  == velocity_selector || ?? for white beam || graphite 
     230        //  == velocity_selector || ?? for white beam || crystal 
    209231//      monoType = V_getMonochromatorType(fname) 
    210232         
     
    217239                        break           // exit from switch 
    218240                case "white_beam":      // execute if case matches expression 
    219                         lambda = 100 
     241                        lambda *= 1e3 
    220242                        break 
    221243                case "crystal": 
    222                         lambda = 1000 
     244                        lambda *= 1e6 
    223245                        break 
    224246                default:                        // optional default expression executed 
     
    226248        endswitch        
    227249         
    228         Wave w = V_getAttenIndex_error_table(fname)             // N=(8,17) 
    229         Make/O/D/N=8 tmpVal,tmpLam 
     250        Wave w = V_getAttenIndex_error_table(fname)             // N=(x,17) 
     251        Variable num = DimSize(w,0) 
     252        Make/O/D/N=(num) tmpVal,tmpLam 
    230253         
    231254        tmpVal = w[p][numAtt+1]         // offset by one, 1st column is wavelength 
Note: See TracChangeset for help on using the changeset viewer.