Changeset 8bd7b77 in sasmodels
- Timestamp:
- Apr 7, 2016 2:00:23 PM (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:
- 6e7ff6d
- Parents:
- 4937980
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r21b116f r8bd7b77 209 209 Choose a parameter range based on parameter name and initial value. 210 210 """ 211 # process the polydispersity options 211 212 if p.endswith('_pd_n'): 212 213 return [0, 100] … … 221 222 else: 222 223 return [-180, 180] 224 elif p.endswith('_pd'): 225 return [0, 1] 223 226 elif 'sld' in p: 224 227 return [-0.5, 10] 225 elif p.endswith('_pd'):226 return [0, 1]227 228 elif p == 'background': 228 229 return [0, 10] 229 230 elif p == 'scale': 230 231 return [0, 1e3] 231 elif p == 'case_num':232 # RPA hack233 return [0, 10]234 232 elif v < 0: 235 # Kxy parameters in rpa model can be negative236 233 return [2*v, -2*v] 237 234 else: … … 239 236 240 237 241 def _randomize_one( p, v):238 def _randomize_one(model_info, p, v): 242 239 """ 243 240 Randomize a single parameter. … … 245 242 if any(p.endswith(s) for s in ('_pd_n', '_pd_nsigma', '_pd_type')): 246 243 return v 244 245 # Find the parameter definition 246 for par in model_info['parameters'].call_parameters: 247 if par.name == p: 248 break 247 249 else: 248 return np.random.uniform(*parameter_range(p, v)) 249 250 251 def randomize_pars(pars, seed=None): 250 raise ValueError("unknown parameter %r"%p) 251 252 if len(par.limits) > 2: # choice list 253 return np.random.randint(len(par.limits)) 254 255 limits = par.limits 256 if not np.isfinite(limits).all(): 257 low, high = parameter_range(p, v) 258 limits = (max(limits[0], low), min(limits[1], high)) 259 260 return np.random.uniform(*limits) 261 262 263 def randomize_pars(model_info, pars, seed=None): 252 264 """ 253 265 Generate random values for all of the parameters. … … 260 272 with push_seed(seed): 261 273 # Note: the sort guarantees order `of calls to random number generator 262 pars = dict((p, _randomize_one( p, v))274 pars = dict((p, _randomize_one(model_info, p, v)) 263 275 for p, v in sorted(pars.items())) 264 276 return pars … … 293 305 # Make sure phi sums to 1.0 294 306 if pars['case_num'] < 2: 295 pars['Phi a'] = 0.296 pars['Phi b'] = 0.307 pars['Phi1'] = 0. 308 pars['Phi2'] = 0. 297 309 elif pars['case_num'] < 5: 298 pars['Phi a'] = 0.299 total = sum(pars['Phi'+c] for c in ' abcd')300 for c in ' abcd':310 pars['Phi1'] = 0. 311 total = sum(pars['Phi'+c] for c in '1234') 312 for c in '1234': 301 313 pars['Phi'+c] /= total 302 314 … … 805 817 #pars.update(set_pars) # set value before random to control range 806 818 if opts['seed'] > -1: 807 pars = randomize_pars( pars, seed=opts['seed'])819 pars = randomize_pars(model_info, pars, seed=opts['seed']) 808 820 print("Randomize using -random=%i"%opts['seed']) 809 821 if opts['mono']: -
sasmodels/compare_many.py
ree8f734 r8bd7b77 108 108 109 109 if is_2d: 110 if not model_info[' has_2d']:110 if not model_info['parameters'].has_2d: 111 111 print(',"1-D only"') 112 112 return -
sasmodels/convert.json
rd2bb604 r8bd7b77 602 602 "RPAModel", 603 603 { 604 "N1": "Na", "N2": "Nb", "N3": "Nc", "N4": "Nd", 605 "L1": "La", "L2": "Lb", "L3": "Lc", "L4": "Ld", 606 "v1": "va", "v2": "vb", "v3": "vc", "v4": "vd", 607 "b1": "ba", "b2": "bb", "b3": "bc", "b4": "bd", 608 "Phi1": "Phia", "Phi2": "Phib", "Phi3": "Phic", "Phi4": "Phid", 604 609 "case_num": "lcase_n" 605 610 } -
sasmodels/convert.py
rf247314 r8bd7b77 206 206 elif name == 'rpa': 207 207 # convert scattering lengths from femtometers to centimeters 208 for p in "L a", "Lb", "Lc", "Ld":208 for p in "L1", "L2", "L3", "L4": 209 209 if p in oldpars: oldpars[p] *= 1e-13 210 210 elif name == 'core_shell_parallelepiped':
Note: See TracChangeset
for help on using the changeset viewer.