Changeset 6edb74a in sasmodels
- Timestamp:
- Feb 19, 2015 3:59:14 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:
- 3a45c2c, fd1c792
- Parents:
- 16bc3fc
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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 r6edb74a 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
Note: See TracChangeset
for help on using the changeset viewer.