Changes in / [ccd5f01:9eb5eca] in sasmodels
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/conversion_table.py
rfa6d6fc re1ea6b5 8 8 """ 9 9 10 # TODO: May need to version this for future versions of sasview when 11 # TODO: models are reparameterized 10 12 11 13 CONVERSION_TABLE = { … … 211 213 ], 212 214 "correlation_length": [ 213 "CorrLength Model",215 "CorrLength", 214 216 { 215 217 "porod_scale": "scale_p", … … 299 301 ], 300 302 "fractal_core_shell": [ 301 "FractalCoreShell Model",303 "FractalCoreShell", 302 304 { 303 305 "sld_core": "core_sld", … … 321 323 ], 322 324 "gauss_lorentz_gel": [ 323 "GaussLorentzGel Model",325 "GaussLorentzGel", 324 326 { 325 327 "gauss_scale": "scale_g", … … 331 333 ], 332 334 "gaussian_peak": [ 333 "Peak GaussModel",335 "Peak Gauss Model", 334 336 { 335 337 "peak_pos": "q0", … … 343 345 "lorentz_scale": "lScale", 344 346 "guinier_scale": "gScale", 345 "fractal_dim": " scale",347 "fractal_dim": "FractalExp", 346 348 "cor_length": "zeta", 347 349 } 348 350 ], 349 351 "guinier": [ 350 "Guinier Model",352 "Guinier", 351 353 { 352 354 "rg": "rg" … … 354 356 ], 355 357 "guinier_porod": [ 356 "GuinierPorod Model",358 "GuinierPorod", 357 359 { 358 360 "s": "dim", … … 454 456 "d_spacing": "spacing", 455 457 "Caille_parameter": "caille", 456 "Nlayers": " N_plates",458 "Nlayers": "n_plates", 457 459 } 458 460 ], … … 486 488 ], 487 489 "lorentz": [ 488 "Lorentz Model",490 "Lorentz", 489 491 { 490 492 "cor_length": "length" … … 510 512 ], 511 513 "mono_gauss_coil": [ 512 "Debye Model",514 "Debye", 513 515 { 514 516 "rg": "rg", … … 564 566 ], 565 567 "peak_lorentz": [ 566 "Peak LorentzModel",568 "Peak Lorentz Model", 567 569 { 568 570 "peak_pos": "q0", … … 802 804 ], 803 805 "two_lorentzian": [ 804 "TwoLorentzian Model",806 "TwoLorentzian", 805 807 { 806 808 "lorentz_scale_1": "scale_1", … … 814 816 ], 815 817 "two_power_law": [ 816 "TwoPowerLaw Model",818 "TwoPowerLaw", 817 819 { 818 820 "coefficent_1": "coef_A", … … 824 826 ], 825 827 "unified_power_Rg": [ 826 "UnifiedPowerRgModel", 827 { 828 } 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 }) 829 839 ], 830 840 "vesicle": [ -
sasmodels/convert.py
rf80f334 re1ea6b5 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 ("", "") 55 61 ] 56 62 … … 64 70 if id.startswith('M0:'): 65 71 return True 66 if id.startswith('volfraction') or id.startswith('radius_effective'):67 return False68 72 if '_pd' in id or '.' in id: 69 73 return False … … 75 79 if p.id == id: 76 80 return p.type == 'sld' 77 r aise ValueError("unknown parameter %r in conversion"%id)81 return False 78 82 79 83 def _rescale_sld(model_info, pars, scale): … … 119 123 def _pd_to_underscores(pars): 120 124 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 names125 :param conv_dict: conversion dictionary mapping new name : old name126 :param pars: parameters to convert127 :return:128 """129 new_pars = {}130 i = 0131 j = 0132 for key_par, value_par in pars.iteritems():133 j += 1134 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_par137 i += 1138 break139 elif re.search("background", key_par) or re.search("scale", key_par):140 new_pars[key_par] = value_par141 i += 1142 break143 if i != j:144 new_pars[key_par] = value_par145 i += 1146 return new_pars147 125 148 126 def _convert_pars(pars, mapping): … … 166 144 del newpars[source] 167 145 return newpars 168 169 146 170 147 def _conversion_target(model_name): … … 215 192 pd = oldpars['radius.width']*oldpars['radius']/thickness 216 193 oldpars['radius.width'] = pd 194 elif name == 'multilayer_vesicle': 195 if 'scale' in oldpars: 196 oldpars['volfraction'] = oldpars['scale'] 197 oldpars['scale'] = 1.0 198 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'] 217 208 elif name == 'pearl_necklace': 218 209 pass … … 236 227 oldpars[p + ".upper"] /= 1e-13 237 228 elif name == 'spherical_sld': 238 oldpars["CONTROL"] += 1 229 oldpars["CONTROL"] = 0 230 i = 0 231 while "nu_inter" + str(i) in oldpars: 232 oldpars["CONTROL"] += 1 233 i += 1 239 234 elif name == 'teubner_strey': 240 235 # basically undoing the entire Teubner-Strey calculations here. … … 298 293 translation = _get_translation_table(model_info) 299 294 newpars = _hand_convert(newname, pars.copy()) 300 newpars = _convert_name(translation, newpars)301 295 newpars = _convert_pars(newpars, translation) 302 296 if not model_info.structure_factor:
Note: See TracChangeset
for help on using the changeset viewer.