Changeset 9e771a3 in sasmodels
- Timestamp:
- Oct 18, 2017 10:51:08 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 94f4543
- Parents:
- 9b7b23f
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
ra85a569 r9e771a3 272 272 Possible types include 'half', 'single', 'double' and 'quad'. If the 273 273 type is 'fast', then this is equivalent to dtype 'single' but using 274 fast native functions rather than those with the precision level guaranteed 275 by the OpenCL standard. 274 fast native functions rather than those with the precision level 275 guaranteed by the OpenCL standard. 'default' will choose the appropriate 276 default for the model and platform. 276 277 277 278 Platform preference can be specfied ("ocl" vs "dll"), with the default -
sasmodels/details.py
r3c24ccd r9e771a3 234 234 # skipping scale and background when building values and weights 235 235 values, dispersity, weights = zip(*mesh[2:npars+2]) if npars else ((), (), ()) 236 weights = correct_theta_weights(kernel.info.parameters, values, weights)236 weights = correct_theta_weights(kernel.info.parameters, dispersity, weights) 237 237 length = np.array([len(w) for w in weights]) 238 238 offset = np.cumsum(np.hstack((0, length))) … … 247 247 return call_details, data, is_magnetic 248 248 249 def correct_theta_weights(parameters, values, weights):249 def correct_theta_weights(parameters, dispersity, weights): 250 250 # type: (ParameterTable, Sequence[np.ndarray], Sequence[np.ndarray]) -> Sequence[np.ndarray] 251 251 """ 252 252 If there is a theta parameter, update the weights of that parameter so that 253 the cosine weighting required for polar integration is preserved. Avoid 254 evaluation strictly at the pole, which would otherwise send the weight to 255 zero. 256 257 Note: values and weights do not include scale and background 258 """ 259 # TODO: document code, explaining why scale and background are skipped 260 # given that we don't have scale and background in the list, we 261 # should be calling the variables something other than values and weights 253 the cosine weighting required for polar integration is preserved. 254 255 Avoid evaluation strictly at the pole, which would otherwise send the 256 weight to zero. This is probably not a problem in practice (if dispersity 257 is +/- 90, then you probably should be using a 1-D model of the circular 258 average). 259 260 Note: scale and background parameters are not include in the tuples for 261 dispersity and weights, so index is parameters.theta_offset, not 262 parameters.theta_offset+2 263 264 Returns updated weights vectors 265 """ 266 # TODO: explain in a comment why scale and background are missing 262 267 # Apparently the parameters.theta_offset similarly skips scale and 263 # and background, so the indexing works out. 268 # and background, so the indexing works out, but they are still shipped 269 # to the kernel, so we need to add two there. 264 270 if parameters.theta_offset >= 0: 265 271 index = parameters.theta_offset 266 theta = values[index] 267 theta_weight = np.minimum(abs(cos(radians(theta))), 1e-6) 268 # copy the weights list so we can update it 269 weights = list(weights) 270 weights[index] = theta_weight*np.asarray(weights[index]) 271 weights = tuple(weights) 272 theta = dispersity[index] 273 # TODO: modify the dispersity vector to avoid the theta=-90,90,270,... 274 theta_weight = abs(cos(radians(theta))) 275 weights = tuple(theta_weight*v if k == index else v 276 for k, v in enumerate(weights)) 272 277 return weights 273 278 -
sasmodels/direct_model.py
r3c24ccd r9e771a3 56 56 """ 57 57 mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 58 #print("pars", list(zip(*mesh))[0]) 58 59 call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 59 60 #print("values:", values) … … 152 153 width = values.get(parameter.name+'_pd', 0.0) 153 154 relative = parameter.relative_pd 154 if npts == 0 or width == 0 or not active:155 if npts == 0 or width == 0.0 or not active: 155 156 # Note: orientation parameters have the viewing angle as the parameter 156 157 # value and the jitter in the distribution, so be sure to set the 157 158 # empty pd for orientation parameters to 0. 158 pd = [value if relative else 0.0], [1.0]159 pd = [value if relative or not parameter.polydisperse else 0.0], [1.0] 159 160 else: 160 161 limits = parameter.limits … … 166 167 167 168 168 def _vol_pars(model_info, pars):169 def _vol_pars(model_info, values): 169 170 # type: (ModelInfo, ParameterSet) -> Tuple[np.ndarray, np.ndarray] 170 vol_pars = [ get_weights(p, pars)171 vol_pars = [_get_par_weights(p, values) 171 172 for p in model_info.parameters.call_parameters 172 173 if p.type == 'volume'] 173 174 #import pylab; pylab.plot(vol_pars[0][0],vol_pars[0][1]); pylab.show() 174 value, weight = dispersion_mesh(model_info, vol_pars)175 return value, weight175 dispersity, weight = dispersion_mesh(model_info, vol_pars) 176 return dispersity, weight 176 177 177 178
Note: See TracChangeset
for help on using the changeset viewer.