Changeset 0b040de in sasmodels
- Timestamp:
- Oct 17, 2016 10:06:32 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b6f10d8
- Parents:
- 73e08ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r248561a r0b040de 73 73 -preset*/-random[=seed] preset or random parameters 74 74 -mono/-poly* force monodisperse/polydisperse 75 -magnetic/-nonmagnetic* suppress magnetism 75 76 -cutoff=1e-5* cutoff value for including a point in polydispersity 76 77 -pars/-nopars* prints the parameter set or not … … 349 350 lines = [] 350 351 parameters = model_info.parameters 352 magnetic = False 351 353 for p in parameters.user_parameters(pars, is2d): 354 if any(p.id.startswith(x) for x in ('M0:', 'mtheta:', 'mphi:')): 355 continue 356 if p.id.startswith('up:') and not magnetic: 357 continue 352 358 fields = dict( 353 359 value=pars.get(p.id, p.default), … … 357 363 pdtype=pars.get(p.id+"_pd_type", 'gaussian'), 358 364 relative_pd=p.relative_pd, 365 M0=pars.get('M0:'+p.id, 0.), 366 mphi=pars.get('mphi:'+p.id, 0.), 367 mtheta=pars.get('mtheta:'+p.id, 0.), 359 368 ) 360 369 lines.append(_format_par(p.name, **fields)) 370 magnetic = magnetic or fields['M0'] != 0. 361 371 return "\n".join(lines) 362 372 … … 364 374 365 375 def _format_par(name, value=0., pd=0., n=0, nsigma=3., pdtype='gaussian', 366 relative_pd=False ):376 relative_pd=False, M0=0., mphi=0., mtheta=0.): 367 377 # type: (str, float, float, int, float, str) -> str 368 378 line = "%s: %g"%(name, value) … … 372 382 line += " +/- %g (%d points in [-%g,%g] sigma %s)"\ 373 383 % (pd, n, nsigma, nsigma, pdtype) 384 if M0 != 0.: 385 line += " M0:%.3f mphi:%.1f mtheta:%.1f" % (M0, mphi, mtheta) 374 386 return line 375 387 … … 385 397 for p in pars: 386 398 if p.endswith("_pd_n"): pars[p] = 0 399 return pars 400 401 def suppress_magnetism(pars): 402 # type: (ParameterSet) -> ParameterSet 403 """ 404 Suppress theta_pd for now until the normalization is resolved. 405 406 May also suppress complete polydispersity of the model to test 407 models more quickly. 408 """ 409 pars = pars.copy() 410 for p in pars: 411 if p.startswith("M0:"): pars[p] = 0 387 412 return pars 388 413 … … 687 712 #cbar_title = "log I" 688 713 if n_comp > 0 and n_base > 0: 714 if not opts['is2d']: 715 plot_theory(data, base_value, view=view, use_data=False, limits=limits) 689 716 plt.subplot(133) 690 717 if not opts['rel_err']: … … 750 777 'preset', 'random', 751 778 'poly', 'mono', 779 'magnetic', 'nonmagnetic', 752 780 'nopars', 'pars', 753 781 'rel', 'abs', … … 857 885 'seed' : -1, # default to preset 858 886 'mono' : False, 887 # Default to magnetic a magnetic moment is set on the command line 888 'magnetic' : any(v.startswith('M0:') for v in values), 859 889 'show_pars' : False, 860 890 'show_hist' : False, … … 890 920 elif arg == '-mono': opts['mono'] = True 891 921 elif arg == '-poly': opts['mono'] = False 922 elif arg == '-magnetic': opts['magnetic'] = True 923 elif arg == '-nonmagnetic': opts['magnetic'] = False 892 924 elif arg == '-pars': opts['show_pars'] = True 893 925 elif arg == '-nopars': opts['show_pars'] = False … … 975 1007 constrain_pars(model_info, pars) 976 1008 constrain_pars(model_info2, pars2) 1009 if not opts['magnetic']: 1010 pars = suppress_magnetism(pars) 1011 pars2 = suppress_magnetism(pars2) 977 1012 978 1013 same_model = name == name2 and pars == pars
Note: See TracChangeset
for help on using the changeset viewer.