Changes in / [9eb5eca:ccd5f01] in sasmodels
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/conversion_table.py
re1ea6b5 rfa6d6fc 8 8 """ 9 9 10 # TODO: May need to version this for future versions of sasview when11 # TODO: models are reparameterized12 10 13 11 CONVERSION_TABLE = { … … 213 211 ], 214 212 "correlation_length": [ 215 "CorrLength ",213 "CorrLengthModel", 216 214 { 217 215 "porod_scale": "scale_p", … … 301 299 ], 302 300 "fractal_core_shell": [ 303 "FractalCoreShell ",301 "FractalCoreShellModel", 304 302 { 305 303 "sld_core": "core_sld", … … 323 321 ], 324 322 "gauss_lorentz_gel": [ 325 "GaussLorentzGel ",323 "GaussLorentzGelModel", 326 324 { 327 325 "gauss_scale": "scale_g", … … 333 331 ], 334 332 "gaussian_peak": [ 335 "Peak GaussModel",333 "PeakGaussModel", 336 334 { 337 335 "peak_pos": "q0", … … 345 343 "lorentz_scale": "lScale", 346 344 "guinier_scale": "gScale", 347 "fractal_dim": " FractalExp",345 "fractal_dim": "scale", 348 346 "cor_length": "zeta", 349 347 } 350 348 ], 351 349 "guinier": [ 352 "Guinier ",350 "GuinierModel", 353 351 { 354 352 "rg": "rg" … … 356 354 ], 357 355 "guinier_porod": [ 358 "GuinierPorod ",356 "GuinierPorodModel", 359 357 { 360 358 "s": "dim", … … 456 454 "d_spacing": "spacing", 457 455 "Caille_parameter": "caille", 458 "Nlayers": " n_plates",456 "Nlayers": "N_plates", 459 457 } 460 458 ], … … 488 486 ], 489 487 "lorentz": [ 490 "Lorentz ",488 "LorentzModel", 491 489 { 492 490 "cor_length": "length" … … 512 510 ], 513 511 "mono_gauss_coil": [ 514 "Debye ",512 "DebyeModel", 515 513 { 516 514 "rg": "rg", … … 566 564 ], 567 565 "peak_lorentz": [ 568 "Peak LorentzModel",566 "PeakLorentzModel", 569 567 { 570 568 "peak_pos": "q0", … … 804 802 ], 805 803 "two_lorentzian": [ 806 "TwoLorentzian ",804 "TwoLorentzianModel", 807 805 { 808 806 "lorentz_scale_1": "scale_1", … … 816 814 ], 817 815 "two_power_law": [ 818 "TwoPowerLaw ",816 "TwoPowerLawModel", 819 817 { 820 818 "coefficent_1": "coef_A", … … 826 824 ], 827 825 "unified_power_Rg": [ 828 "UnifiedPowerRg", 829 dict(((field_new+str(index), field_old+str(index)) 830 for field_new, field_old in [("rg", "Rg"), 831 ("power", "power"), 832 ("G", "G"), 833 ("B", "B"),] 834 for index in range(11)), 835 **{ 836 "background": "background", 837 "scale": "scale", 838 }) 826 "UnifiedPowerRgModel", 827 { 828 } 839 829 ], 840 830 "vesicle": [ -
sasmodels/convert.py
re1ea6b5 rf80f334 53 53 ("_pd_nsigma", ".nsigmas"), 54 54 ("_pd_type", ".type"), 55 (".lower", ".lower"),56 (".upper", ".upper"),57 (".fittable", ".fittable"),58 (".std", ".std"),59 (".units", ".units"),60 ("", "")61 55 ] 62 56 … … 70 64 if id.startswith('M0:'): 71 65 return True 66 if id.startswith('volfraction') or id.startswith('radius_effective'): 67 return False 72 68 if '_pd' in id or '.' in id: 73 69 return False … … 79 75 if p.id == id: 80 76 return p.type == 'sld' 81 r eturn False77 raise ValueError("unknown parameter %r in conversion"%id) 82 78 83 79 def _rescale_sld(model_info, pars, scale): … … 123 119 def _pd_to_underscores(pars): 124 120 return dict((_dot_pd_to_underscore_pd(k), v) for k, v in pars.items()) 121 122 def _convert_name(conv_dict, pars): 123 """ 124 Renames parameter values (upper, lower, etc) to v4.0 names 125 :param conv_dict: conversion dictionary mapping new name : old name 126 :param pars: parameters to convert 127 :return: 128 """ 129 new_pars = {} 130 i = 0 131 j = 0 132 for key_par, value_par in pars.iteritems(): 133 j += 1 134 for key_conv, value_conv in conv_dict.iteritems(): 135 if re.search(value_conv, key_par): 136 new_pars[key_par.replace(value_conv, key_conv)] = value_par 137 i += 1 138 break 139 elif re.search("background", key_par) or re.search("scale", key_par): 140 new_pars[key_par] = value_par 141 i += 1 142 break 143 if i != j: 144 new_pars[key_par] = value_par 145 i += 1 146 return new_pars 125 147 126 148 def _convert_pars(pars, mapping): … … 144 166 del newpars[source] 145 167 return newpars 168 146 169 147 170 def _conversion_target(model_name): … … 192 215 pd = oldpars['radius.width']*oldpars['radius']/thickness 193 216 oldpars['radius.width'] = pd 194 elif name == 'multilayer_vesicle':195 if 'scale' in oldpars:196 oldpars['volfraction'] = oldpars['scale']197 oldpars['scale'] = 1.0198 if 'scale.lower' in oldpars:199 oldpars['volfraction.lower'] = oldpars['scale.lower']200 if 'scale.upper' in oldpars:201 oldpars['volfraction.upper'] = oldpars['scale.upper']202 if 'scale.fittable' in oldpars:203 oldpars['volfraction.fittable'] = oldpars['scale.fittable']204 if 'scale.std' in oldpars:205 oldpars['volfraction.std'] = oldpars['scale.std']206 if 'scale.units' in oldpars:207 oldpars['volfraction.units'] = oldpars['scale.units']208 217 elif name == 'pearl_necklace': 209 218 pass … … 227 236 oldpars[p + ".upper"] /= 1e-13 228 237 elif name == 'spherical_sld': 229 oldpars["CONTROL"] = 0 230 i = 0 231 while "nu_inter" + str(i) in oldpars: 232 oldpars["CONTROL"] += 1 233 i += 1 238 oldpars["CONTROL"] += 1 234 239 elif name == 'teubner_strey': 235 240 # basically undoing the entire Teubner-Strey calculations here. … … 293 298 translation = _get_translation_table(model_info) 294 299 newpars = _hand_convert(newname, pars.copy()) 300 newpars = _convert_name(translation, newpars) 295 301 newpars = _convert_pars(newpars, translation) 296 302 if not model_info.structure_factor:
Note: See TracChangeset
for help on using the changeset viewer.