Changeset 083afa1 in sasview
- Timestamp:
- Apr 11, 2017 6:11:14 AM (8 years ago)
- Children:
- 9c23f40
- Parents:
- 0741804
- git-author:
- Andrew Nelson <andyfaff@…> (04/07/17 07:53:49)
- git-committer:
- Andrew Nelson <andyfaff@…> (04/11/17 06:11:14)
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
r235f514 r083afa1 65 65 raise ValueError('one or more of your dx values are negative, please check the data file!') 66 66 67 if _found_sesans == True:67 if _found_sesans: 68 68 #Pre-compute the Hankel matrix (H) 69 69 qmax, qunits = data.sample.zacceptance … … 84 84 #print "data1D.dx[0]",data1D.dx[0],data1D.dxl[0] 85 85 # If we found resolution smearing data, return a QSmearer 86 if _found_resolution == True:86 if _found_resolution: 87 87 return pinhole_smear(data, model) 88 88 … … 107 107 break 108 108 # If we found slit smearing data, return a slit smearer 109 if _found_slit == True:109 if _found_slit: 110 110 return slit_smear(data, model) 111 111 return None -
src/sas/sascalc/dataloader/readers/abs_reader.py
r959eb01 r083afa1 69 69 data_conv_i = None 70 70 71 if has_converter == Trueand output.x_unit != '1/A':71 if has_converter and output.x_unit != '1/A': 72 72 data_conv_q = Converter('1/A') 73 73 # Test it 74 74 data_conv_q(1.0, output.x_unit) 75 75 76 if has_converter == Trueand output.y_unit != '1/cm':76 if has_converter and output.y_unit != '1/cm': 77 77 data_conv_i = Converter('1/cm') 78 78 # Test it … … 82 82 83 83 # Information line 1 84 if is_info == True:84 if is_info: 85 85 is_info = False 86 86 line_toks = line.split() … … 89 89 try: 90 90 value = float(line_toks[1]) 91 if has_converter == Trueand \91 if has_converter and \ 92 92 output.source.wavelength_unit != 'A': 93 93 conv = Converter('A') … … 104 104 try: 105 105 value = float(line_toks[3]) 106 if has_converter == Trueand \106 if has_converter and \ 107 107 detector.distance_unit != 'm': 108 108 conv = Converter('m') … … 125 125 try: 126 126 value = float(line_toks[5]) 127 if has_converter == Trueand \127 if has_converter and \ 128 128 output.sample.thickness_unit != 'cm': 129 129 conv = Converter('cm') … … 142 142 143 143 # Find center info line 144 if is_center == True:144 if is_center: 145 145 is_center = False 146 146 line_toks = line.split() … … 150 150 151 151 # Bin size 152 if has_converter == Trueand \152 if has_converter and \ 153 153 detector.pixel_size_unit != 'mm': 154 154 conv = Converter('mm') … … 163 163 # Store beam center in distance units 164 164 # Det 640 x 640 mm 165 if has_converter == Trueand \165 if has_converter and \ 166 166 detector.beam_center_unit != 'mm': 167 167 conv = Converter('mm') … … 187 187 188 188 # Parse the data 189 if is_data_started == True:189 if is_data_started: 190 190 toks = line.split() 191 191 -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r235f514 r083afa1 147 147 pass 148 148 149 if has_error_dy == True:149 if has_error_dy: 150 150 tdy = np.append(tdy, _dy) 151 if has_error_dx == True:151 if has_error_dx: 152 152 tdx = np.append(tdx, _dx) 153 153 tx = np.append(tx, _x) 154 154 ty = np.append(ty, _y) 155 155 156 # To remember the # of columns on the current line156 # To remember the # of columns on the current line 157 157 # for the next line of data 158 158 lentoks = new_lentoks … … 160 160 except ValueError: 161 161 # It is data and meet non - number, then stop reading 162 if is_data == True:162 if is_data: 163 163 break 164 164 lentoks = 2 … … 175 175 raise RuntimeError, msg 176 176 # Sanity check 177 if has_error_dy == Trueand not len(ty) == len(tdy):177 if has_error_dy and not len(ty) == len(tdy): 178 178 msg = "ascii_reader: y and dy have different length" 179 179 raise RuntimeError, msg 180 if has_error_dx == Trueand not len(tx) == len(tdx):180 if has_error_dx and not len(tx) == len(tdx): 181 181 msg = "ascii_reader: y and dy have different length" 182 182 raise RuntimeError, msg … … 199 199 x[i] = tx[ind[i]] 200 200 y[i] = ty[ind[i]] 201 if has_error_dy == True:201 if has_error_dy: 202 202 dy[i] = tdy[ind[i]] 203 if has_error_dx == True:203 if has_error_dx: 204 204 dx[i] = tdx[ind[i]] 205 205 # Zeros in dx, dy … … 211 211 output.x = x[x != 0] 212 212 output.y = y[x != 0] 213 output.dy = dy[x != 0] if has_error_dy == True\213 output.dy = dy[x != 0] if has_error_dy\ 214 214 else np.zeros(len(output.y)) 215 output.dx = dx[x != 0] if has_error_dx == True\215 output.dx = dx[x != 0] if has_error_dx\ 216 216 else np.zeros(len(output.x)) 217 217 … … 243 243 if len(toks) < 2: 244 244 toks = line.split() 245 245 246 return toks -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r7432acb r083afa1 774 774 if local_unit and default_unit and local_unit.lower() != default_unit.lower() \ 775 775 and local_unit.lower() != "none": 776 if HAS_CONVERTER == True:776 if HAS_CONVERTER: 777 777 # Check local units - bad units raise KeyError 778 778 data_conv_q = Converter(local_unit) … … 1170 1170 pos, "z", datainfo.sample.position.z, 1171 1171 {"unit": datainfo.sample.position_unit}) 1172 if written == True:1172 if written: 1173 1173 self.append(pos, sample) 1174 1174 … … 1183 1183 ori, "yaw", datainfo.sample.orientation.z, 1184 1184 {"unit": datainfo.sample.orientation_unit}) 1185 if written == True:1185 if written: 1186 1186 self.append(ori, sample) 1187 1187 … … 1230 1230 size, "z", datainfo.source.beam_size.z, 1231 1231 {"unit": datainfo.source.beam_size_unit}) 1232 if written == True:1232 if written: 1233 1233 self.append(size, source) 1234 1234 … … 1286 1286 size, "z", aperture.size.z, 1287 1287 {"unit": aperture.size_unit}) 1288 if written == True:1288 if written: 1289 1289 self.append(size, apert) 1290 1290 … … 1309 1309 written = written | self.write_node(det, "SDD", item.distance, 1310 1310 {"unit": item.distance_unit}) 1311 if written == True:1311 if written: 1312 1312 self.append(det, instr) 1313 1313 … … 1319 1319 written = written | self.write_node(off, "z", item.offset.z, 1320 1320 {"unit": item.offset_unit}) 1321 if written == True:1321 if written: 1322 1322 self.append(off, det) 1323 1323 … … 1331 1331 item.orientation.z, 1332 1332 {"unit": item.orientation_unit}) 1333 if written == True:1333 if written: 1334 1334 self.append(ori, det) 1335 1335 … … 1343 1343 item.beam_center.z, 1344 1344 {"unit": item.beam_center_unit}) 1345 if written == True:1345 if written: 1346 1346 self.append(center, det) 1347 1347 … … 1353 1353 written = written | self.write_node(pix, "z", item.pixel_size.z, 1354 1354 {"unit": item.pixel_size_unit}) 1355 if written == True:1355 if written: 1356 1356 self.append(pix, det) 1357 1357 self.write_node(det, "slit_length", item.slit_length, … … 1465 1465 exec "local_unit = storage.%s_unit" % toks[0] 1466 1466 if local_unit is not None and units.lower() != local_unit.lower(): 1467 if HAS_CONVERTER == True:1467 if HAS_CONVERTER: 1468 1468 try: 1469 1469 conv = Converter(units) -
src/sas/sascalc/dataloader/readers/danse_reader.py
r235f514 r083afa1 87 87 data_conv_i = None 88 88 89 if has_converter == Trueand output.Q_unit != '1/A':89 if has_converter and output.Q_unit != '1/A': 90 90 data_conv_q = Converter('1/A') 91 91 # Test it 92 92 data_conv_q(1.0, output.Q_unit) 93 93 94 if has_converter == Trueand output.I_unit != '1/cm':94 if has_converter and output.I_unit != '1/cm': 95 95 data_conv_i = Converter('1/cm') 96 96 # Test it … … 162 162 qx = 4.0 * math.pi / wavelength * math.sin(theta / 2.0) 163 163 164 if has_converter == Trueand output.Q_unit != '1/A':164 if has_converter and output.Q_unit != '1/A': 165 165 qx = data_conv_q(qx, units=output.Q_unit) 166 166 … … 177 177 qy = 4.0 * math.pi / wavelength * math.sin(theta/2.0) 178 178 179 if has_converter == Trueand output.Q_unit != '1/A':179 if has_converter and output.Q_unit != '1/A': 180 180 qy = data_conv_q(qy, units=output.Q_unit) 181 181 … … 213 213 # Store all data 214 214 # Store wavelength 215 if has_converter == Trueand output.source.wavelength_unit != 'A':215 if has_converter and output.source.wavelength_unit != 'A': 216 216 conv = Converter('A') 217 217 wavelength = conv(wavelength, … … 220 220 221 221 # Store distance 222 if has_converter == Trueand detector.distance_unit != 'm':222 if has_converter and detector.distance_unit != 'm': 223 223 conv = Converter('m') 224 224 distance = conv(distance, units=detector.distance_unit) … … 226 226 227 227 # Store pixel size 228 if has_converter == Trueand detector.pixel_size_unit != 'mm':228 if has_converter and detector.pixel_size_unit != 'mm': 229 229 conv = Converter('mm') 230 230 pixel = conv(pixel, units=detector.pixel_size_unit) … … 242 242 ymax = ymax + stepq / 2.0 243 243 244 if has_converter == Trueand output.Q_unit != '1/A':244 if has_converter and output.Q_unit != '1/A': 245 245 xmin = data_conv_q(xmin, units=output.Q_unit) 246 246 xmax = data_conv_q(xmax, units=output.Q_unit) … … 281 281 282 282 return None 283 -
src/sas/sascalc/dataloader/readers/hfir1d_reader.py
r959eb01 r083afa1 62 62 data_conv_i = None 63 63 64 if has_converter == Trueand output.x_unit != '1/A':64 if has_converter and output.x_unit != '1/A': 65 65 data_conv_q = Converter('1/A') 66 66 # Test it 67 67 data_conv_q(1.0, output.x_unit) 68 68 69 if has_converter == Trueand output.y_unit != '1/cm':69 if has_converter and output.y_unit != '1/cm': 70 70 data_conv_i = Converter('1/cm') 71 71 # Test it -
src/sas/sascalc/dataloader/readers/red2d_reader.py
r959eb01 r083afa1 107 107 108 108 # Set units: This is the unit assumed for Q and I in the data file. 109 if has_converter == Trueand output.Q_unit != '1/A':109 if has_converter and output.Q_unit != '1/A': 110 110 data_conv_q = Converter('1/A') 111 111 # Test it 112 112 data_conv_q(1.0, output.Q_unit) 113 113 114 if has_converter == Trueand output.I_unit != '1/cm':114 if has_converter and output.I_unit != '1/cm': 115 115 data_conv_i = Converter('1/cm') 116 116 # Test it … … 140 140 wavelength = float(line_toks[1]) 141 141 # Units 142 if has_converter == Trueand \142 if has_converter and \ 143 143 output.source.wavelength_unit != 'A': 144 144 conv = Converter('A') … … 152 152 distance = float(line_toks[3]) 153 153 # Units 154 if has_converter == Trueand detector.distance_unit != 'm':154 if has_converter and detector.distance_unit != 'm': 155 155 conv = Converter('m') 156 156 distance = conv(distance, units=detector.distance_unit) … … 189 189 190 190 ## Read and get data. 191 if dataStarted == True:191 if dataStarted: 192 192 line_toks = line.split() 193 193 if len(line_toks) == 0: … … 268 268 269 269 # units 270 if has_converter == Trueand output.Q_unit != '1/A':270 if has_converter and output.Q_unit != '1/A': 271 271 xmin = data_conv_q(xmin, units=output.Q_unit) 272 272 xmax = data_conv_q(xmax, units=output.Q_unit) -
src/sas/sascalc/dataloader/readers/sesans_reader.py
r9a5097c r083afa1 166 166 167 167 def _unit_conversion(self, value, value_unit, default_unit): 168 if has_converter == Trueand value_unit != default_unit:168 if has_converter and value_unit != default_unit: 169 169 data_conv_q = Converter(value_unit) 170 170 value = data_conv_q(value, units=default_unit)
Note: See TracChangeset
for help on using the changeset viewer.