Changes in src/sas/sascalc/data_util/qsmearing.py [235f514:ba91f71] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
r235f514 rba91f71 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 10 10 ###################################################################### 11 import numpy 11 12 import math 12 13 import logging … … 17 18 18 19 from sasmodels.resolution import Slit1D, Pinhole1D 19 from sasmodels.sesans import SesansTransform 20 from sasmodels.sesans import SesansTransform, OrientedSesansTransform 20 21 from sasmodels.resolution2d import Pinhole2D 21 22 from .nxsunit import Converter … … 42 43 # This checks for 2D data (does not throw exception because fail is common) 43 44 if data.__class__.__name__ not in ['Data1D', 'Theory1D']: 44 if data isNone:45 if data == None: 45 46 return None 46 elif data.dqx_data is None or data.dqy_data isNone:47 elif data.dqx_data == None or data.dqy_data == None: 47 48 return None 48 49 return PySmear2D(data) … … 59 60 if data.dx is not None and data.isSesans: 60 61 #if data.dx[0] > 0.0: 61 if n p.size(data.dx[data.dx <= 0]) == 0:62 if numpy.size(data.dx[data.dx <= 0]) == 0: 62 63 _found_sesans = True 63 64 # if data.dx[0] <= 0.0: 64 if n p.size(data.dx[data.dx <= 0]) > 0:65 if numpy.size(data.dx[data.dx <= 0]) > 0: 65 66 raise ValueError('one or more of your dx values are negative, please check the data file!') 66 67 … … 71 72 zaccept = Converter(qunits)(qmax, "1/A"), 72 73 Rmax = 10000000 73 hankel = SesansTransform(data.x, SElength, zaccept, Rmax)74 # data must have the isoriented flag here! 74 75 # Then return the actual transform, as if it were a smearing function 75 return PySmear(hankel, model, offset=0) 76 if getattr(data, 'isoriented', False): 77 costransform = OrientedSesansTransform(data.x, SElength, zaccept, Rmax) 78 return PySmear(costransform, model, offset=0) 79 else: 80 hankel = SesansTransform(data.x, SElength, zaccept, Rmax) 81 return PySmear(hankel, model, offset=0) 76 82 77 83 _found_resolution = False … … 120 126 self.resolution = resolution 121 127 if offset is None: 122 offset = n p.searchsorted(self.resolution.q_calc, self.resolution.q[0])128 offset = numpy.searchsorted(self.resolution.q_calc, self.resolution.q[0]) 123 129 self.offset = offset 124 130 … … 133 139 first_bin:last_bin set to the resolution smeared values. 134 140 """ 135 if last_bin is None: last_bin = len(iq_in)136 start, end = first_bin + self.offset, last_bin + self.offset137 141 q_calc = self.resolution.q_calc 138 iq_calc = np.empty_like(q_calc) 139 if start > 0: 140 iq_calc[:start] = self.model.evalDistribution(q_calc[:start]) 141 if end+1 < len(q_calc): 142 iq_calc[end+1:] = self.model.evalDistribution(q_calc[end+1:]) 143 iq_calc[start:end+1] = iq_in[first_bin:last_bin+1] 142 if isinstance(q_calc, tuple): 143 # We are 2D -> 1D! 144 iq_calc = self.model.evalDistribution(q_calc) 145 else: 146 if last_bin is None: last_bin = len(iq_in) 147 start, end = first_bin + self.offset, last_bin + self.offset 148 iq_calc = numpy.empty_like(q_calc) 149 if start > 0: 150 iq_calc[:start] = self.model.evalDistribution(q_calc[:start]) 151 if end+1 < len(q_calc): 152 iq_calc[end+1:] = self.model.evalDistribution(q_calc[end+1:]) 153 iq_calc[start:end+1] = iq_in[first_bin:last_bin+1] 144 154 smeared = self.resolution.apply(iq_calc) 145 155 return smeared … … 156 166 """ 157 167 q = self.resolution.q 158 first = n p.searchsorted(q, q_min)159 last = n p.searchsorted(q, q_max)168 first = numpy.searchsorted(q, q_min) 169 last = numpy.searchsorted(q, q_max) 160 170 return first, min(last,len(q)-1) 161 171
Note: See TracChangeset
for help on using the changeset viewer.