Changeset 60eab2a in sasmodels
- Timestamp:
- Mar 24, 2016 8:12:07 AM (9 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:
- 380e8c9
- Parents:
- e69b36f
- Location:
- sasmodels
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r69aa451 r60eab2a 222 222 elif kernel.dim == '2d': 223 223 pars_2d = set(p.name for p in kernel.info['parameters'].type['2d']) 224 active = lambda name: name in pars_ 1d224 active = lambda name: name in pars_2d 225 225 else: 226 226 active = lambda name: True -
sasmodels/direct_model.py
r48fbd50 r60eab2a 78 78 q_mono = sesans.make_all_q(data) 79 79 elif self.data_type == 'Iqxy': 80 partype = model.info['par_type'] 81 if not partype['orientation'] and not partype['magnetic']: 82 raise ValueError("not 2D without orientation or magnetic parameters") 80 #if not model.info['parameters'].has_2d: 81 # raise ValueError("not 2D without orientation or magnetic parameters") 83 82 q = np.sqrt(data.qx_data**2 + data.qy_data**2) 84 83 qmin = getattr(data, 'qmin', 1e-16) -
sasmodels/generate.py
r76a9ffe r60eab2a 415 415 } 416 416 """ 417 par_decl = ', '.join(p.as_ argument() for p in pars) if pars else 'void'417 par_decl = ', '.join(p.as_function_argument() for p in pars) if pars else 'void' 418 418 return _FN_TEMPLATE % {'name': name, 'body': body, 'pars': par_decl} 419 419 … … 661 661 performs a similar role for Iq written in C. 662 662 """ 663 if model_info['Iq'] is not Noneand model_info['Iqxy'] is None:663 if callable(model_info['Iq']) and model_info['Iqxy'] is None: 664 664 partable = model_info['parameters'] 665 665 if partable.type['1d'] != partable.type['2d']: … … 730 730 filename=abspath(kernel_module.__file__), 731 731 name=name, 732 title= kernel_module.title,733 description= kernel_module.description,732 title=getattr(kernel_module, 'title', name+" model"), 733 description=getattr(kernel_module, 'description', 'no description'), 734 734 parameters=parameters, 735 735 composition=None, -
sasmodels/kernel_iq.c
r69aa451 r60eab2a 16 16 17 17 typedef struct { 18 #if MAX_PD > 0 18 19 int32_t pd_par[MAX_PD]; // id of the nth polydispersity variable 19 20 int32_t pd_length[MAX_PD]; // length of the nth polydispersity weight vector … … 21 22 int32_t pd_stride[MAX_PD]; // stride to move to the next index at this level 22 23 int32_t pd_isvol[MAX_PD]; // True if parameter is a volume weighting parameter 24 #endif // MAX_PD > 0 23 25 int32_t par_offset[NPARS]; // offset of par values in the value & weight vector 24 26 int32_t par_coord[NPARS]; // polydispersity coordination bitvector … … 52 54 double *pvec = (double *)(&local_values); // Alias named parameters with a vector 53 55 54 local int offset[NPARS]; // NPARS excludes scale/background 55 56 #if 0 // defined(USE_SHORTCUT_OPTIMIZATION) 56 #if MAX_PD > 0 57 57 if (problem->pd_length[0] == 1) { 58 #endif // MAX_PD > 0 58 59 // Shouldn't need to copy!! 59 60 60 for (int k=0; k < NPARS; k++) { 61 61 pvec[k] = values[k+2]; // skip scale and background … … 67 67 #endif 68 68 for (int i=0; i < nq; i++) { 69 const double scattering = CALL_IQ(q, i, local_values); 70 result[i] = values[0]*scattering/volume + values[1]; 69 double scattering = CALL_IQ(q, i, local_values); 70 if (volume != 0.0) scattering /= volume; 71 result[i] = values[0]*scattering + values[1]; 71 72 } 72 73 return; 73 } 74 printf("falling through\n"); 75 #endif 74 #if MAX_PD > 0 75 } 76 77 // polydispersity loop index positions 78 local int offset[NPARS]; // NPARS excludes scale/background 76 79 77 80 printf("Entering polydispersity\n"); … … 177 180 } 178 181 } 179 printf("rad len %f %f\n",local_values.radius, local_values.length);180 182 #ifdef INVALID 181 183 if (INVALID(local_values)) continue; … … 199 201 } 200 202 201 //Makes a normalization av ialable for the next round203 //Makes a normalization available for the next round 202 204 result[nq] = norm; 203 205 result[nq+1] = vol; … … 216 218 } 217 219 } 220 #endif // MAX_PD > 0 218 221 } -
sasmodels/modelinfo.py
r69aa451 r60eab2a 30 30 processed.append(parse_parameter(*p)) 31 31 partable = ParameterTable(processed) 32 set_vector_length_from_reference(partable)33 32 return partable 34 35 def set_vector_length_from_reference(partable):36 # Sort out the length of the vector parameters such as thickness[n]37 for p in partable:38 if p.length_control:39 ref = partable[p.length_control]40 low, high = ref.limits41 if int(low) != low or int(high) != high or low<0 or high>20:42 raise ValueError("expected limits on %s to be within [0, 20]"%ref.name)43 p.length = low44 33 45 34 def parse_parameter(name, units='', default=None, … … 172 161 def __init__(self, name, units='', default=None, limits=(-np.inf, np.inf), 173 162 type='', description=''): 174 self.id = name 163 self.id = name.split('[')[0].strip() 175 164 self.name = name 176 165 self.default = default … … 235 224 self._name_table= dict((p.name, p) for p in parameters) 236 225 self._categorize_parameters() 226 227 self._set_vector_lengths() 228 self._set_defaults() 229 230 def _set_vector_lengths(self): 231 # Sort out the length of the vector parameters such as thickness[n] 232 for p in self.parameters: 233 if p.length_control: 234 ref = self._name_table[p.length_control] 235 low, high = ref.limits 236 if int(low) != low or int(high) != high or low<0 or high>20: 237 raise ValueError("expected limits on %s to be within [0, 20]"%ref.name) 238 p.length = low 239 240 def _set_defaults(self): 241 # Construct default values, including vector defaults 242 defaults = {} 243 for p in self.parameters: 244 if p.length == 1: 245 defaults[p.id] = p.default 246 else: 247 for k in range(p.length): 248 defaults["%s[%d]"%(p.id, k)] = p.default 249 self.defaults = defaults 237 250 238 251 def __getitem__(self, k): … … 289 302 par_type['1d'] = [p for p in pars if p.type not in ('orientation', 'magnetic')] 290 303 par_type['2d'] = [p for p in pars if p.type != 'magnetic'] 291 par_type['magnetic'] = [p for p in pars]292 304 par_type['pd'] = [p for p in pars if p.polydisperse] 293 305 par_type['pd_relative'] = [p for p in pars if p.relative_pd] … … 304 316 305 317 @property 306 def defaults(self):307 return dict((p.name, p.default) for p in self.parameters)308 309 @property310 318 def num_pd(self): 311 319 """ … … 313 321 shape dimensions and orientational distributions). 314 322 """ 315 return len(self.type['pd'])323 return sum(p.length for p in self.type['pd']) 316 324 317 325 @property
Note: See TracChangeset
for help on using the changeset viewer.