Changes in sasmodels/kerneldll.py [33969b6:01c8d9e] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r33969b6 r01c8d9e 258 258 # Note: if there is a syntax error then compile raises an error 259 259 # and the source file will not be deleted. 260 os.unlink(filename)261 #print("saving compiled file in %r"%filename)260 #os.unlink(filename) 261 print("saving compiled file in %r"%filename) 262 262 return dll 263 263 … … 371 371 def __init__(self, kernel, model_info, q_input): 372 372 # type: (Callable[[], np.ndarray], ModelInfo, PyInput) -> None 373 #,model_info,q_input) 373 374 self.kernel = kernel 374 375 self.info = model_info … … 376 377 self.dtype = q_input.dtype 377 378 self.dim = '2d' if q_input.is_2d else '1d' 378 self.result = np.empty( q_input.nq+1, q_input.dtype)379 self.result = np.empty(2*q_input.nq+2, q_input.dtype) 379 380 self.real = (np.float32 if self.q_input.dtype == generate.F32 380 381 else np.float64 if self.q_input.dtype == generate.F64 381 382 else np.float128) 382 383 383 def __call__(self, call_details, values, cutoff, magnetic):384 def Iq(self, call_details, values, cutoff, magnetic): 384 385 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 385 386 self._call_kernel(call_details, values, cutoff, magnetic) 387 #print("returned",self.q_input.q, self.result) 388 pd_norm = self.result[self.q_input.nq] 389 scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 390 background = values[1] 391 #print("scale",scale,background) 392 return scale*self.result[:self.q_input.nq] + background 393 __call__ = Iq 394 395 def beta(self, call_details, values, cutoff, magnetic): 396 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 397 self._call_kernel(call_details, values, cutoff, magnetic) 398 w_norm = self.result[2*self.q_input.nq + 1] 399 pd_norm = self.result[self.q_input.nq] 400 if w_norm == 0.: 401 w_norm = 1. 402 F2 = self.result[:self.q_input.nq]/w_norm 403 F1 = self.result[self.q_input.nq+1:2*self.q_input.nq+1]/w_norm 404 volume_avg = pd_norm/w_norm 405 return F1, F2, volume_avg 406 407 def _call_kernel(self, call_details, values, cutoff, magnetic): 386 408 kernel = self.kernel[1 if magnetic else 0] 387 409 args = [ … … 390 412 None, # pd_stop pd_stride[MAX_PD] 391 413 call_details.buffer.ctypes.data, # problem 392 values.ctypes.data, # pars393 self.q_input.q.ctypes.data, # q414 values.ctypes.data, # pars 415 self.q_input.q.ctypes.data, # q 394 416 self.result.ctypes.data, # results 395 417 self.real(cutoff), # cutoff 396 418 ] 397 #print("Calling DLL") 419 #print(self.beta_result.ctypes.data) 420 # print("Calling DLL line 397") 421 # print("values", values) 398 422 #call_details.show(values) 399 423 step = 100 … … 403 427 kernel(*args) # type: ignore 404 428 405 #print("returned",self.q_input.q, self.result)406 pd_norm = self.result[self.q_input.nq]407 scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0)408 background = values[1]409 #print("scale",scale,background)410 return scale*self.result[:self.q_input.nq] + background411 412 429 def release(self): 413 430 # type: () -> None
Note: See TracChangeset
for help on using the changeset viewer.