- Timestamp:
- Nov 16, 2017 10:57:32 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Attenuation.ipf
r1071 r1073 3 3 4 4 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 // 5 25 // functions to calculate attenuator values from the tables 6 26 // … … 9 29 // 10 30 // interpolate if necessary 11 31 // 12 32 13 33 // … … 15 35 // 16 36 // 17 // 18 19 20 // attenuator tables are currently /N=(8,17) 37 // attenuator tables are currently /N=(n,17) 21 38 22 39 … … 54 71 Proc V_WriteCSVAttenTable(lo,hi,atten_values) 55 72 Variable lo,hi 56 String atten_values 73 String atten_values="atten_values" 57 74 58 75 V_fPatchAttenValueTable(lo,hi,$atten_values) … … 61 78 Proc V_WriteCSVAttenErrTable(lo,hi,atten_err) 62 79 Variable lo,hi 63 String atten_err 80 String atten_err="atten_err" 64 81 65 82 V_fPatchAttenErrTable(lo,hi,$atten_err) … … 78 95 String fname 79 96 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 endif97 // // 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 84 101 85 102 //loop over all files … … 107 124 String fname 108 125 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 endif126 // // 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 113 130 114 131 //loop over all files … … 132 149 // 133 150 // fill in a "dummy" wavelength for White Beam and graphite 134 // == 100for White Beam135 // == 1000for graphite151 // *= 1e3 for White Beam 152 // *= 1e6 for graphite 136 153 // use these dummy values just for the lookup table 137 154 // 138 155 // TODO -- need the enumerated values for the monochromator type 139 156 // 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) 141 160 // 142 161 Function V_CalculateAttenuationFactor(fname) … … 162 181 break // exit from switch 163 182 case "white_beam": // execute if case matches expression 164 lambda = 100183 lambda *= 1e3 165 184 break 166 185 case "crystal": 167 lambda = 1000186 lambda *= 1e6 168 187 break 169 188 default: // optional default expression executed … … 172 191 173 192 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 176 196 177 197 tmpVal = w[p][numAtt+1] // offset by one, 1st column is wavelength 178 198 tmpLam = w[p][0] 179 199 val = interp(lambda, tmpLam, tmpVal ) 200 Print "Calculated Atten = ",val 180 201 181 202 //killwaves/Z tmpVal,tmpLam … … 189 210 // 190 211 // fill in a "dummy" wavelength for White Beam and graphite 191 // == 100for White Beam192 // == 1000for graphite212 // *= 1e3 for White Beam 213 // *= 1e6 for graphite 193 214 // use these dummy values just for the lookup table 194 215 // … … 196 217 // TODO -- V_getMonochromatorType(fname) is NOT written correctly by NICE 197 218 // 219 // 198 220 Function V_CalculateAttenuationError(fname) 199 221 String fname … … 206 228 207 229 // TODO -- need to switch on "type" 208 // == velocity_selector || ?? for white beam || graphite230 // == velocity_selector || ?? for white beam || crystal 209 231 // monoType = V_getMonochromatorType(fname) 210 232 … … 217 239 break // exit from switch 218 240 case "white_beam": // execute if case matches expression 219 lambda = 100241 lambda *= 1e3 220 242 break 221 243 case "crystal": 222 lambda = 1000244 lambda *= 1e6 223 245 break 224 246 default: // optional default expression executed … … 226 248 endswitch 227 249 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 230 253 231 254 tmpVal = w[p][numAtt+1] // offset by one, 1st column is wavelength
Note: See TracChangeset
for help on using the changeset viewer.