Changeset 3c24ccd in sasmodels for sasmodels/direct_model.py
- Timestamp:
- Oct 18, 2017 10:03:43 AM (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:
- ef8e68c
- Parents:
- fbb9397
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/direct_model.py
r32f87a5 r3c24ccd 55 55 *mono* is True if polydispersity should be set to none on all parameters. 56 56 """ 57 parameters = calculator.info.parameters 58 if mono: 59 active = lambda name: False 60 elif calculator.dim == '1d': 61 active = lambda name: name in parameters.pd_1d 62 elif calculator.dim == '2d': 63 active = lambda name: name in parameters.pd_2d 64 else: 65 active = lambda name: True 66 67 #print("pars",[p.id for p in parameters.call_parameters]) 68 mesh = [get_weights(p, pars, active(p.name)) 69 for p in parameters.call_parameters] 70 57 mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 71 58 call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 72 59 #print("values:", values) 73 60 return calculator(call_details, values, cutoff, is_magnetic) 74 75 61 76 62 def call_ER(model_info, pars): … … 128 114 return x, y, model_info.profile_axes 129 115 130 131 def get_weights(parameter, values, active=True): 132 # type: (Parameter, Dict[str, float]) -> Tuple[np.ndarray, np.ndarray] 116 def get_mesh(model_info, values, dim='1d', mono=False): 117 # type: (ModelInfo, Dict[str, float], str, bool) -> List[Tuple[float, np.ndarray, np.ndarry]] 118 """ 119 Retrieve the dispersity mesh described by the parameter set. 120 121 Returns a list of *(value, dispersity, weights)* with one tuple for each 122 parameter in the model call parameters. Inactive parameters return the 123 default value with a weight of 1.0. 124 """ 125 parameters = model_info.parameters 126 if mono: 127 active = lambda name: False 128 elif dim == '1d': 129 active = lambda name: name in parameters.pd_1d 130 elif dim == '2d': 131 active = lambda name: name in parameters.pd_2d 132 else: 133 active = lambda name: True 134 135 #print("pars",[p.id for p in parameters.call_parameters]) 136 mesh = [_get_par_weights(p, values, active(p.name)) 137 for p in parameters.call_parameters] 138 return mesh 139 140 141 def _get_par_weights(parameter, values, active=True): 142 # type: (Parameter, Dict[str, float]) -> Tuple[float, np.ndarray, np.ndarray] 133 143 """ 134 144 Generate the distribution for parameter *name* given the parameter values
Note: See TracChangeset
for help on using the changeset viewer.