Changeset 261658d in sasmodels
- Timestamp:
- Feb 19, 2015 4:43:07 PM (10 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 29f5536
- Parents:
- 9cb1415 (diff), fd1c792 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 5 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
example/sesansfit.py
r0ac3db5 r9c117a2 4 4 from sasmodels import bumps_model as sas 5 5 kernel = sas.load_model('sphere', dtype='single') 6 #kernel = sas.load_model('triaxial_ellipsoid', dtype='single') 6 7 7 8 … … 11 12 loader=Loader() 12 13 data=loader.load('testsasview1.ses') 14 data.x /=10 13 15 14 16 # data = load_sesans('mydatfile.pz') … … 20 22 err_data = np.ones_like(SElength)*0.03 21 23 24 class Sample: 25 zacceptance = 0.1 # [A^-1] 26 thickness = 0.2 # [cm] 27 22 28 class SESANSData1D: 23 29 #q_zmax = 0.23 # [A^-1] 24 zacceptance = 0.1 # [A^-1] 25 lam = 2e-10 # [m] 26 thickness = 0.2 # [cm] 30 lam = 0.2 # [nm] 27 31 x = SElength 28 32 y = data 29 33 dy = err_data 30 data = SesansData()31 print dir(data)34 sample = Sample() 35 data = SESANSData1D() 32 36 33 37 radius = 1000 34 38 data.Rmax = 3*radius # [A] 35 39 40 ## Sphere parameters 41 36 42 phi = Parameter(0.1, name="phi") 37 43 model = sas.BumpsModel(data, kernel, 38 44 scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) 39 phi.pmp(10) 40 model.radius.pmp(40) 41 model.sld.pm(2) 42 model.background.range(0,5) 43 45 phi.range(0.001,0.90) 46 #model.radius.pmp(40) 47 model.radius.range(100,10000) 48 #model.sld.pmp(5) 49 #model.background 50 #model.radius_pd=0 51 #model.radius_pd_n=0 44 52 45 53 if False: # have sans data … … 49 57 problem = FitProblem(model) 50 58 59 60 ### Tri-Axial Ellipsoid 61 # 62 #phi = Parameter(0.1, name='phi') 63 #model = sas.BumpsModel(data, kernel, 64 # scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) 65 #phi.range(0.001,0.90) 66 ##model.radius.pmp(40) 67 #model.radius.range(100,10000) 68 ##model.sld.pmp(5) 69 ##model.background 70 ##model.radius_pd=0 71 ##model.radius_pd_n=0 72 # 73 #if False: # have sans data 74 # sansmodel = sas.BumpsModel(sans_data, kernel, **model.parameters()) 75 # problem = FitProblem([model, sansmodel]) 76 #else: 77 # problem = FitProblem(model) -
sasmodels/bumps_model.py
r62b3cb2 r8632a35 354 354 #self._theory[:] = self._fn.eval(pars, pd_pars) 355 355 if self.data_type == 'sesans': 356 P = sesans.hankel(self.data.x, self.data.lam ,356 P = sesans.hankel(self.data.x, self.data.lam*1e-9, 357 357 self.data.sample.thickness/10, self._fn_inputs[0], 358 358 self._theory) -
sasmodels/convert.py
ra503bfd rfd1c792 13 13 for variant in ("", "_pd", "_pd_n", "_pd_nsigma", "_pd_type"): 14 14 if old+variant in newpars: 15 newpars[new+variant] = pars[old+variant] 15 if new is not None: 16 newpars[new+variant] = pars[old+variant] 16 17 del newpars[old+variant] 17 18 # Sasview style parameter names 18 19 for variant in (".width", ".nsigmas", ".type", ".npts"): 19 20 if old+variant in newpars: 20 newpars[new+variant] = pars[old+variant] 21 if new is not None: 22 newpars[new+variant] = pars[old+variant] 21 23 del newpars[old+variant] 22 24 return newpars -
sasmodels/generate.py
rff58110 rae7b97b 731 731 info['limits'] = dict((p[0],p[3]) for p in info['parameters']) 732 732 info['partype'] = categorize_parameters(info['parameters']) 733 info['defaults'] = dict((p[0],p[2]) for p in info['parameters']) 733 734 734 735 source = make_model(info) -
sasmodels/kernelpy.py
rf786ff3 r6edb74a 87 87 self.pd_pars = pd_pars 88 88 89 def __call__(self, fixed, pd, cutoff ):89 def __call__(self, fixed, pd, cutoff=1e-5): 90 90 #print "fixed",fixed 91 91 #print "pd", pd … … 144 144 ########################################################## 145 145 146 # weight vector, to be populated by polydispersity loops147 146 weight = np.empty(len(pd), 'd') 148 149 # identify which pd parameters are volume parameters 150 vol_weight_index = np.array([(index in vol_index) for index in pd_index]) 151 152 # Sort parameters in decreasing order of pd length 153 Npd = np.array([len(pdi[0]) for pdi in pd], 'i') 154 order = np.argsort(Npd)[::-1] 155 stride = np.cumprod(Npd[order]) 156 pd = [pd[index] for index in order] 157 pd_index = pd_index[order] 158 vol_weight_index = vol_weight_index[order] 159 160 fast_value = pd[0][0] 161 fast_weight = pd[0][1] 147 if weight.size > 0: 148 # weight vector, to be populated by polydispersity loops 149 150 # identify which pd parameters are volume parameters 151 vol_weight_index = np.array([(index in vol_index) for index in pd_index]) 152 153 # Sort parameters in decreasing order of pd length 154 Npd = np.array([len(pdi[0]) for pdi in pd], 'i') 155 order = np.argsort(Npd)[::-1] 156 stride = np.cumprod(Npd[order]) 157 pd = [pd[index] for index in order] 158 pd_index = pd_index[order] 159 vol_weight_index = vol_weight_index[order] 160 161 fast_value = pd[0][0] 162 fast_weight = pd[0][1] 163 else: 164 stride = np.array([1]) 165 vol_weight_index = slice(None, None) 162 166 163 167 ret = np.zeros_like(args[0]) … … 169 173 fast_index = k%stride[0] 170 174 if fast_index == 0: # bottom loop complete ... check all other loops 171 for i,index, in enumerate(k%stride): 172 args[pd_index[i]] = pd[i][0][index] 173 weight[i] = pd[i][1][index] 175 if weight.size > 0: 176 for i,index, in enumerate(k%stride): 177 args[pd_index[i]] = pd[i][0][index] 178 weight[i] = pd[i][1][index] 174 179 else: 175 180 args[pd_index[0]] = fast_value[fast_index] -
sasmodels/models/broad_peak.py
r636adb6 rfd1c792 51 51 52 52 import numpy as np 53 from numpy import pi, inf, sin, cos, sqrt, exp, log 53 from numpy import pi, inf, sin, cos, sqrt, exp, log, fabs 54 54 55 55 name = "broad_peak" … … 92 92 def Iq(q, porod_scale, porod_exp, lorentz_scale, lorentz_length, peak_pos, lorentz_exp): 93 93 inten = porod_scale/pow(q,porod_exp) + lorentz_scale/(1.0 \ 94 + pow(( math.fabs(q-peak_pos)*lorentz_length),lorentz_exp))94 + pow((fabs(q-peak_pos)*lorentz_length),lorentz_exp)) 95 95 return inten 96 96 … … 113 113 oldpars = dict(porod_scale='scale_p', porod_exp='exponent_p', 114 114 lorentz_scale='scale_l', lorentz_length='length_l', peak_pos='q_peak', 115 lorentz_exp='exponent_l' )115 lorentz_exp='exponent_l', scale=None)
Note: See TracChangeset
for help on using the changeset viewer.