Changes in / [ea7ffce:a006b63] in sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
example/sesansfit.py
re806077 r0ac3db5 6 6 7 7 8 radius = 1000 9 if False: # fix when data loader exists 10 from sasmodels.dataloader import load_sesans, load_sans 11 data = load_sesans('mydatfile.pz') 12 sans_data = load_sans('mysansfile.xml') 8 if True: # fix when data loader exists 9 # from sas.dataloader.readers\ 10 from sas.dataloader.loader import Loader 11 loader=Loader() 12 data=loader.load('testsasview1.ses') 13 14 # data = load_sesans('mydatfile.pz') 15 # sans_data = load_sans('mysansfile.xml') 16 13 17 else: 14 18 SElength = np.linspace(0, 2400, 61) # [A] … … 16 20 err_data = np.ones_like(SElength)*0.03 17 21 18 class S esansData:22 class SESANSData1D: 19 23 #q_zmax = 0.23 # [A^-1] 20 q_zmax = 0.1 # [A^-1] 21 SElength = np.linspace(0, 2400, 61) # [A] 22 Rmax = 3*radius # [A] 23 wavelength = 2e-10 # [m] 24 zacceptance = 0.1 # [A^-1] 25 lam = 2e-10 # [m] 24 26 thickness = 0.2 # [cm] 25 SElength= SElength26 data= data27 err_data= err_data27 x = SElength 28 y = data 29 dy = err_data 28 30 data = SesansData() 31 print dir(data) 32 33 radius = 1000 34 data.Rmax = 3*radius # [A] 29 35 30 36 phi = Parameter(0.1, name="phi") -
sasmodels/bumps_model.py
rc97724e r0ac3db5 217 217 def _plot_sesans(data, theory, view): 218 218 import matplotlib.pyplot as plt 219 resid = (theory - data. data)/data.err_data219 resid = (theory - data.y)/data.dy 220 220 plt.subplot(121) 221 plt.errorbar(data. SElength, data.data, yerr=data.err_data)222 plt.plot(data. SElength, theory, '-', hold=True)221 plt.errorbar(data.x, data.y, yerr=data.dy) 222 plt.plot(data.x, theory, '-', hold=True) 223 223 plt.xlabel('spin echo length (A)') 224 224 plt.ylabel('polarization') 225 225 plt.subplot(122) 226 plt.plot(data. SElength, resid, 'x')226 plt.plot(data.x, resid, 'x') 227 227 plt.xlabel('spin echo length (A)') 228 228 plt.ylabel('residuals') … … 267 267 self.model = model 268 268 self.cutoff = cutoff 269 if hasattr(data, 'SElength'): 269 # TODO if isinstance(data,SESANSData1D) 270 if hasattr(data, 'lam'): 270 271 self.data_type = 'sesans' 271 272 elif hasattr(data, 'qx_data'): … … 278 279 # interpret data 279 280 if self.data_type == 'sesans': 280 q = sesans.make_q(data. q_zmax, data.Rmax)281 q = sesans.make_q(data.sample.zacceptance, data.Rmax) 281 282 self.index = slice(None,None) 282 self.iq = data. data283 self.diq = data. err_data283 self.iq = data.y 284 self.diq = data.dy 284 285 self._theory = np.zeros_like(q) 285 286 q_vectors = [q] … … 353 354 #self._theory[:] = self._fn.eval(pars, pd_pars) 354 355 if self.data_type == 'sesans': 355 P = sesans.hankel(self.data. SElength, self.data.wavelength,356 self.data. thickness, self._fn_inputs[0],356 P = sesans.hankel(self.data.x, self.data.lam, 357 self.data.sample.thickness/10, self._fn_inputs[0], 357 358 self._theory) 358 359 self._cache['theory'] = P … … 401 402 self.data.data[self.index] = y 402 403 elif self.data_type == 'sesans': 403 self.data. data[self.index] = y404 self.data.y[self.index] = y 404 405 else: 405 406 raise ValueError("Unknown model")
Note: See TracChangeset
for help on using the changeset viewer.