Changeset 24f6f4a in sasview for src/sas/sascalc
- Timestamp:
- Oct 8, 2016 12:12:46 PM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f7bc948
- Parents:
- 87b9447 (diff), e28f34d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sascalc
- Files:
-
- 12 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
r45d7662 r1b1a1c1 881 881 raise ValueError, msg 882 882 # Here we could also extrapolate between data points 883 ZERO = 1.0e-12883 TOLERANCE = 0.01 884 884 for i in range(len(self.x)): 885 if math.fabs( self.x[i] - other.x[i]) > ZERO:885 if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 886 886 msg = "Incompatible data sets: x-values do not match" 887 887 raise ValueError, msg … … 1093 1093 """ 1094 1094 err_other = None 1095 TOLERANCE = 0.01 1095 1096 if isinstance(other, Data2D): 1096 1097 # Check that data lengths are the same … … 1101 1102 raise ValueError, msg 1102 1103 for ind in range(len(self.data)): 1103 if self.qx_data[ind] != other.qx_data[ind]:1104 msg = "Incompatible data sets: qx-values do not match "1104 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 1105 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1105 1106 raise ValueError, msg 1106 if self.qy_data[ind] != other.qy_data[ind]:1107 msg = "Incompatible data sets: qy-values do not match "1107 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 1108 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1108 1109 raise ValueError, msg 1109 1110 -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r654e8e0 r0639476 1177 1177 written = written | self.write_node(pix, "z", item.pixel_size.z, 1178 1178 {"unit": item.pixel_size_unit}) 1179 written = written | self.write_node(det, "slit_length",1180 item.slit_length,1181 {"unit": item.slit_length_unit})1182 1179 if written == True: 1183 1180 self.append(pix, det) 1181 self.write_node(det, "slit_length", item.slit_length, 1182 {"unit": item.slit_length_unit}) 1183 1184 1184 1185 1185 def _write_process_notes(self, datainfo, entry_node): -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r479799c r5e906207 23 23 24 24 Any number of SASdata sets may be present in a SASentry and the data within can be either 1D I(Q) or 2D I(Qx, Qy). 25 26 Also supports reading NXcanSAS formatted HDF5 files 25 27 26 28 :Dependencies: … … 76 78 ## Add the last data set to the list of outputs 77 79 self.add_data_set() 80 ## Close the data file 81 self.raw_data.close() 78 82 ## Return data set(s) 79 83 return self.output … … 183 187 elif key == u'run': 184 188 self.current_datainfo.run.append(data_point) 189 try: 190 run_name = value.attrs['name'] 191 run_dict = {data_point: run_name} 192 self.current_datainfo.run_name = run_dict 193 except: 194 pass 185 195 elif key == u'title': 186 196 self.current_datainfo.title = data_point … … 189 199 190 200 ## Sample Information 191 elif key == u'Title' and self.parent_class == u'SASsample': 201 elif key == u'Title' and self.parent_class == u'SASsample': # CanSAS 2.0 format 202 self.current_datainfo.sample.name = data_point 203 elif key == u'ID' and self.parent_class == u'SASsample': # NXcanSAS format 192 204 self.current_datainfo.sample.name = data_point 193 205 elif key == u'thickness' and self.parent_class == u'SASsample': … … 195 207 elif key == u'temperature' and self.parent_class == u'SASsample': 196 208 self.current_datainfo.sample.temperature = data_point 209 elif key == u'transmission' and self.parent_class == u'SASsample': 210 self.current_datainfo.sample.transmission = data_point 211 elif key == u'x_position' and self.parent_class == u'SASsample': 212 self.current_datainfo.sample.position.x = data_point 213 elif key == u'y_position' and self.parent_class == u'SASsample': 214 self.current_datainfo.sample.position.y = data_point 215 elif key == u'polar_angle' and self.parent_class == u'SASsample': 216 self.current_datainfo.sample.orientation.x = data_point 217 elif key == u'azimuthal_angle' and self.parent_class == u'SASsample': 218 self.current_datainfo.sample.orientation.z = data_point 219 elif key == u'details' and self.parent_class == u'SASsample': 220 self.current_datainfo.sample.details.append(data_point) 197 221 198 222 ## Instrumental Information … … 204 228 self.detector.distance = float(data_point) 205 229 self.detector.distance_unit = unit 230 elif key == u'slit_length' and self.parent_class == u'SASdetector': 231 self.detector.slit_length = float(data_point) 232 self.detector.slit_length_unit = unit 233 elif key == u'x_position' and self.parent_class == u'SASdetector': 234 self.detector.offset.x = float(data_point) 235 self.detector.offset_unit = unit 236 elif key == u'y_position' and self.parent_class == u'SASdetector': 237 self.detector.offset.y = float(data_point) 238 self.detector.offset_unit = unit 239 elif key == u'polar_angle' and self.parent_class == u'SASdetector': 240 self.detector.orientation.x = float(data_point) 241 self.detector.orientation_unit = unit 242 elif key == u'azimuthal_angle' and self.parent_class == u'SASdetector': 243 self.detector.orientation.z = float(data_point) 244 self.detector.orientation_unit = unit 245 elif key == u'beam_center_x' and self.parent_class == u'SASdetector': 246 self.detector.beam_center.x = float(data_point) 247 self.detector.beam_center_unit = unit 248 elif key == u'beam_center_y' and self.parent_class == u'SASdetector': 249 self.detector.beam_center.y = float(data_point) 250 self.detector.beam_center_unit = unit 251 elif key == u'x_pixel_size' and self.parent_class == u'SASdetector': 252 self.detector.pixel_size.x = float(data_point) 253 self.detector.pixel_size_unit = unit 254 elif key == u'y_pixel_size' and self.parent_class == u'SASdetector': 255 self.detector.pixel_size.y = float(data_point) 256 self.detector.pixel_size_unit = unit 206 257 elif key == u'SSD' and self.parent_class == u'SAScollimation': 207 258 self.collimation.length = data_point … … 213 264 elif key == u'name' and self.parent_class == u'SASprocess': 214 265 self.process.name = data_point 215 elif key == u'Title' and self.parent_class == u'SASprocess': 266 elif key == u'Title' and self.parent_class == u'SASprocess': # CanSAS 2.0 format 267 self.process.name = data_point 268 elif key == u'name' and self.parent_class == u'SASprocess': # NXcanSAS format 216 269 self.process.name = data_point 217 270 elif key == u'description' and self.parent_class == u'SASprocess': … … 230 283 self.trans_spectrum.wavelength.append(data_point) 231 284 232 ## Other Information285 ## Source 233 286 elif key == u'wavelength' and self.parent_class == u'SASdata': 234 287 self.current_datainfo.source.wavelength = data_point 235 self.current_datainfo.source.wavelength.unit = unit 288 self.current_datainfo.source.wavelength_unit = unit 289 elif key == u'incident_wavelength' and self.parent_class == u'SASsource': 290 self.current_datainfo.source.wavelength = data_point 291 self.current_datainfo.source.wavelength_unit = unit 292 elif key == u'wavelength_max' and self.parent_class == u'SASsource': 293 self.current_datainfo.source.wavelength_max = data_point 294 self.current_datainfo.source.wavelength_max_unit = unit 295 elif key == u'wavelength_min' and self.parent_class == u'SASsource': 296 self.current_datainfo.source.wavelength_min = data_point 297 self.current_datainfo.source.wavelength_min_unit = unit 298 elif key == u'wavelength_spread' and self.parent_class == u'SASsource': 299 self.current_datainfo.source.wavelength_spread = data_point 300 self.current_datainfo.source.wavelength_spread_unit = unit 301 elif key == u'beam_size_x' and self.parent_class == u'SASsource': 302 self.current_datainfo.source.beam_size.x = data_point 303 self.current_datainfo.source.beam_size_unit = unit 304 elif key == u'beam_size_y' and self.parent_class == u'SASsource': 305 self.current_datainfo.source.beam_size.y = data_point 306 self.current_datainfo.source.beam_size_unit = unit 307 elif key == u'beam_shape' and self.parent_class == u'SASsource': 308 self.current_datainfo.source.beam_shape = data_point 236 309 elif key == u'radiation' and self.parent_class == u'SASsource': 237 310 self.current_datainfo.source.radiation = data_point … … 376 449 self.current_datainfo = DataInfo() 377 450 451 378 452 def _initialize_new_data_set(self, parent_list = None): 379 453 """ -
src/sas/sascalc/data_util/qsmearing.py
rf8aa738 r87b9447 5 5 #This software was developed by the University of Tennessee as part of the 6 6 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 7 #project funded by the US National Science Foundation. 7 #project funded by the US National Science Foundation. 8 8 #See the license text in license.txt 9 9 #copyright 2008, University of Tennessee … … 16 16 from sasmodels.resolution import Slit1D, Pinhole1D 17 17 from sasmodels.resolution2d import Pinhole2D 18 from sasmodels import sesans 18 19 19 20 def smear_selection(data, model = None): … … 46 47 and not hasattr(data, "dxw"): 47 48 return None 49 50 # Look for sesans 51 _found_sesans = False 52 if hasattr(data,'lam') : 53 _found_sesans = True 54 logging.info("Found SESANS data!!") 55 56 # If we found sesans data, do the necessary jiggery pokery 57 if _found_sesans == True: 58 return sesans_smear(data, model) 48 59 49 60 # Look for resolution smearing data … … 82 93 if _found_slit == True: 83 94 return slit_smear(data, model) 95 84 96 return None 97 98 def sesans_smear(data, model=None): 99 q = sesans.make_q(data.sample.zacceptance, data.Rmax) 100 index = slice(None, None) 101 res = None 102 if data.y is not None: 103 Iq, dIq = data.y, data.dy 104 else: 105 Iq, dIq = None, None 106 #self._theory = np.zeros_like(q) 107 q_vectors = [q] 108 q_mono = sesans.make_all_q(data) 109 Iq = model.evalDistribution(q_mono) 110 111 return sesans.transform(data, q, Iq, 0, 0) 85 112 86 113
Note: See TracChangeset
for help on using the changeset viewer.