Changeset 4fe4394 in sasview for DataLoader/qsmearing.py
- Timestamp:
- Oct 10, 2008 4:47:33 PM (16 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ae60f86
- Parents:
- 2139c3f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/qsmearing.py
rd00f8ff r4fe4394 8 8 copyright 2008, University of Tennessee 9 9 """ 10 11 #TODO: improvement: allow for varying dQ as a function of Q 12 10 13 import numpy 11 14 import math … … 15 18 """ 16 19 Creates the right type of smearer according 17 to the data 18 """ 19 pass 20 to the data. 21 22 The canSAS format has a rule that either 23 slit smearing data OR resolution smearing data 24 is available. 25 26 For the present purpose, we choose the one that 27 has none-zero data. If both slit and resolution 28 smearing arrays are filled with good data 29 (which should not happen), then we choose the 30 resolution smearing data. 31 32 @param data1D: Data1D object 33 """ 34 # Sanity check. If we are not dealing with a SANS Data1D 35 # object, just return None 36 if data1D.__class__.__name__ != 'Data1D' \ 37 or not hasattr(data1D, "dxl") or not hasattr(data1D, "dxw"): 38 return None 39 40 # Look for resolution smearing data 41 _found_resolution = False 42 if data1D.dx is not None and len(data1D.dx)==len(data1D.x): 43 44 # Check that we have non-zero data 45 if data1D.dx[0]>0.0: 46 _found_resolution = True 47 48 # If we found resolution smearing data, return a QSmearer 49 if _found_resolution == True: 50 return QSmearer(data1D) 51 52 # Look for slit smearing data 53 _found_slit = False 54 if data1D.dxl is not None and len(data1D.dxl)==len(data1D.x) \ 55 and data1D.dxw is not None and len(data1D.dxw)==len(data1D.x): 56 57 # Check that we have non-zero data 58 if data1D.dxl[0]>0.0 or data1D.dxw[0]>0.0: 59 _found_slit = True 60 61 # Sanity check: all data should be the same as a function of Q 62 for item in data1D.dxl: 63 if data1D.dxl[0] != item: 64 _found_resolution = False 65 break 66 67 for item in data1D.dxw: 68 if data1D.dxw[0] != item: 69 _found_resolution = False 70 break 71 72 # If we found slit smearing data, return a slit smearer 73 if _found_slit == True: 74 return SlitSmearer(data1D) 75 76 return None 77 20 78 21 79 class _BaseSmearer(object): … … 213 271 # Compute the fraction of the Gaussian contributing 214 272 # to the q bin between q_min and q_max 215 value = scipy.special.erf( (q_max-q_j)/(math.sqrt(2.0)*self.width ) )216 value -=scipy.special.erf( (q_min-q_j)/(math.sqrt(2.0)*self.width ) )273 value = scipy.special.erf( (q_max-q_j)/(math.sqrt(2.0)*self.width[j]) ) 274 value -=scipy.special.erf( (q_min-q_j)/(math.sqrt(2.0)*self.width[j]) ) 217 275 218 276 weights[i][j] += value … … 235 293 236 294 ## Slit width 237 self.width = 0295 self.width = numpy.zeros(len(data1D.x)) 238 296 if data1D.dx is not None and len(data1D.dx)==len(data1D.x): 239 self.width = data1D.dx[0] 240 # Sanity check 241 for value in data1D.dx: 242 if value != self.width: 243 raise RuntimeError, "dQ must be the same for all data" 297 self.width = data1D.dx 244 298 245 299 ## Number of Q bins
Note: See TracChangeset
for help on using the changeset viewer.