Changeset fa79f5c in sasmodels for sasmodels/direct_model.py
- Timestamp:
- Nov 29, 2017 8:43:12 AM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- a839b22
- Parents:
- 32398dc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/direct_model.py
r9e771a3 rfa79f5c 177 177 178 178 179 def _make_sesans_transform(data): 180 from sas.sascalc.data_util.nxsunit import Converter 181 182 # Pre-compute the Hankel matrix (H) 183 SElength = Converter(data._xunit)(data.x, "A") 184 185 theta_max = Converter("radians")(data.sample.zacceptance)[0] 186 q_max = 2 * np.pi / np.max(data.source.wavelength) * np.sin(theta_max) 187 zaccept = Converter("1/A")(q_max, "1/" + data.source.wavelength_unit), 188 189 Rmax = 10000000 190 hankel = sesans.SesansTransform(data.x, SElength, 191 data.source.wavelength, 192 zaccept, Rmax) 193 return hankel 194 195 179 196 class DataMixin(object): 180 197 """ … … 216 233 217 234 if self.data_type == 'sesans': 218 q = sesans.make_q(data.sample.zacceptance, data.Rmax)235 res = _make_sesans_transform(data) 219 236 index = slice(None, None) 220 res = None221 237 if data.y is not None: 222 238 Iq, dIq = data.y, data.dy … … 224 240 Iq, dIq = None, None 225 241 #self._theory = np.zeros_like(q) 226 q_vectors = [q] 227 q_mono = sesans.make_all_q(data) 242 q_vectors = [res.q_calc] 228 243 elif self.data_type == 'Iqxy': 229 244 #if not model.info.parameters.has_2d: … … 244 259 #self._theory = np.zeros_like(self.Iq) 245 260 q_vectors = res.q_calc 246 q_mono = []247 261 elif self.data_type == 'Iq': 248 262 index = (data.x >= data.qmin) & (data.x <= data.qmax) … … 269 283 #self._theory = np.zeros_like(self.Iq) 270 284 q_vectors = [res.q_calc] 271 q_mono = []272 285 elif self.data_type == 'Iq-oriented': 273 286 index = (data.x >= data.qmin) & (data.x <= data.qmax) … … 286 299 qy_width=data.dxl[index]) 287 300 q_vectors = res.q_calc 288 q_mono = []289 301 else: 290 302 raise ValueError("Unknown data type") # never gets here … … 293 305 # so we can save/restore state 294 306 self._kernel_inputs = q_vectors 295 self._kernel_mono_inputs = q_mono296 307 self._kernel = None 297 308 self.Iq, self.dIq, self.index = Iq, dIq, index … … 331 342 if self._kernel is None: 332 343 self._kernel = self._model.make_kernel(self._kernel_inputs) 333 self._kernel_mono = (334 self._model.make_kernel(self._kernel_mono_inputs)335 if self._kernel_mono_inputs else None)336 344 337 345 Iq_calc = call_kernel(self._kernel, pars, cutoff=cutoff) … … 341 349 # TODO: refactor so we don't store the result in the model 342 350 self.Iq_calc = Iq_calc 343 if self.data_type == 'sesans': 344 Iq_mono = (call_kernel(self._kernel_mono, pars, mono=True) 345 if self._kernel_mono_inputs else None) 346 result = sesans.transform(self._data, 347 self._kernel_inputs[0], Iq_calc, 348 self._kernel_mono_inputs, Iq_mono) 349 else: 350 result = self.resolution.apply(Iq_calc) 351 if hasattr(self.resolution, 'nx'): 352 self.Iq_calc = ( 353 self.resolution.qx_calc, self.resolution.qy_calc, 354 np.reshape(Iq_calc, (self.resolution.ny, self.resolution.nx)) 355 ) 351 result = self.resolution.apply(Iq_calc) 352 if hasattr(self.resolution, 'nx'): 353 self.Iq_calc = ( 354 self.resolution.qx_calc, self.resolution.qy_calc, 355 np.reshape(Iq_calc, (self.resolution.ny, self.resolution.nx)) 356 ) 356 357 return result 357 358
Note: See TracChangeset
for help on using the changeset viewer.