Changeset 40a87fa in sasmodels for sasmodels/kernelpy.py
- Timestamp:
- Aug 8, 2016 9:24:11 AM (8 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:
- 2472141
- Parents:
- 2d65d51
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernelpy.py
r32e3c9b r40a87fa 143 143 if q_input.is_2d: 144 144 form = model_info.Iqxy 145 qx, qy = q_input.q[:, 0], q_input.q[:,1]145 qx, qy = q_input.q[:, 0], q_input.q[:, 1] 146 146 self._form = lambda: form(qx, qy, *kernel_args) 147 147 else: … … 168 168 self.q_input = None 169 169 170 def _loops(parameters, form, form_volume, nq, details, 171 values, cutoff): 170 def _loops(parameters, form, form_volume, nq, call_details, values, cutoff): 172 171 # type: (np.ndarray, Callable[[], np.ndarray], Callable[[], float], int, details.CallDetails, np.ndarray, np.ndarray, float) -> None 173 172 ################################################################ … … 180 179 # # 181 180 ################################################################ 182 NPARS= len(parameters)183 parameters[:] = values[2: NPARS+2]181 n_pars = len(parameters) 182 parameters[:] = values[2:n_pars+2] 184 183 scale, background = values[0], values[1] 185 if details.num_active == 0:184 if call_details.num_active == 0: 186 185 norm = float(form_volume()) 187 186 if norm > 0.0: … … 190 189 return np.ones(nq, 'd')*background 191 190 192 pd_value = values[2+ NPARS:2+NPARS+details.pd_sum]193 pd_weight = values[2+ NPARS+details.pd_sum:]191 pd_value = values[2+n_pars:2+n_pars + call_details.pd_sum] 192 pd_weight = values[2+n_pars + call_details.pd_sum:] 194 193 195 194 pd_norm = 0.0 196 195 spherical_correction = 1.0 197 196 partial_weight = np.NaN 198 weight = np.NaN199 200 p0_par = details.pd_par[0]201 p0_is_theta = (p0_par == details.theta_par)202 p0_length = details.pd_length[0]197 weight = np.NaN 198 199 p0_par = call_details.pd_par[0] 200 p0_is_theta = (p0_par == call_details.theta_par) 201 p0_length = call_details.pd_length[0] 203 202 p0_index = p0_length 204 p0_offset = details.pd_offset[0]205 206 pd_par = details.pd_par[:details.num_active]207 pd_offset = details.pd_offset[:details.num_active]208 pd_stride = details.pd_stride[:details.num_active]209 pd_length = details.pd_length[:details.num_active]203 p0_offset = call_details.pd_offset[0] 204 205 pd_par = call_details.pd_par[:call_details.num_active] 206 pd_offset = call_details.pd_offset[:call_details.num_active] 207 pd_stride = call_details.pd_stride[:call_details.num_active] 208 pd_length = call_details.pd_length[:call_details.num_active] 210 209 211 210 total = np.zeros(nq, 'd') 212 for loop_index in range( details.pd_prod):211 for loop_index in range(call_details.pd_prod): 213 212 # update polydispersity parameter values 214 213 if p0_index == p0_length: … … 216 215 parameters[pd_par] = pd_value[pd_offset+pd_index] 217 216 partial_weight = np.prod(pd_weight[pd_offset+pd_index][1:]) 218 if details.theta_par >= 0: 219 spherical_correction = max(abs(cos(pi/180 * parameters[details.theta_par])), 1e-6) 217 if call_details.theta_par >= 0: 218 cor = cos(pi / 180 * parameters[call_details.theta_par]) 219 spherical_correction = max(abs(cor), 1e-6) 220 220 p0_index = loop_index%p0_length 221 221 … … 223 223 parameters[p0_par] = pd_value[p0_offset + p0_index] 224 224 if p0_is_theta: 225 spherical_correction = max(abs(cos(pi/180 * parameters[p0_par])), 1e-6) 225 cor = cos(pi/180 * parameters[p0_par]) 226 spherical_correction = max(abs(cor), 1e-6) 226 227 p0_index += 1 227 228 if weight > cutoff: … … 230 231 # exclude all q for that NaN. Even better would be to have an 231 232 # INVALID expression like the C models, but that is too expensive. 232 I = form()233 if np.isnan(I ).any(): continue233 Iq = form() 234 if np.isnan(Iq).any(): continue 234 235 235 236 # update value and norm 236 237 weight *= spherical_correction 237 total += weight * I 238 total += weight * Iq 238 239 pd_norm += weight * form_volume() 239 240
Note: See TracChangeset
for help on using the changeset viewer.