Changeset e1ea6b5 in sasmodels
- Timestamp:
- Dec 2, 2016 12:51:09 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:
- 9eb5eca
- Parents:
- 077666e
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/conversion_table.py
r077666e 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 = { … … 825 827 "unified_power_Rg": [ 826 828 "UnifiedPowerRg", 827 { 828 } 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
r077666e 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 … … 117 123 def _pd_to_underscores(pars): 118 124 return dict((_dot_pd_to_underscore_pd(k), v) for k, v in pars.items()) 119 120 def _convert_name(conv_dict, pars):121 """122 Renames parameter values (upper, lower, etc) to v4.0 names123 :param conv_dict: conversion dictionary mapping new name : old name124 :param pars: parameters to convert125 :return:126 """127 new_pars = {}128 i = 0129 j = 0130 for key_par, value_par in pars.iteritems():131 j += 1132 for key_conv, value_conv in conv_dict.iteritems():133 if value_conv is None:134 pass135 elif "background" == key_par or "scale" == key_par:136 new_pars[key_par] = value_par137 i += 1138 break139 elif re.search(value_conv, key_par):140 new_pars[key_par.replace(value_conv, key_conv)] = 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 217 elif name == 'mono_gauss_coil':218 if 'scale' in oldpars:219 oldpars['i_zero'] = oldpars['scale']220 oldpars['scale'] = 1.0221 if 'scale.lower' in oldpars:222 oldpars['i_zero.lower'] = oldpars['scale.lower']223 if 'scale.upper' in oldpars:224 oldpars['i_zero.upper'] = oldpars['scale.upper']225 if 'scale.fittable' in oldpars:226 oldpars['i_zero.fittable'] = oldpars['scale.fittable']227 if 'scale.std' in oldpars:228 oldpars['i_zero.std'] = oldpars['scale.std']229 if 'scale.units' in oldpars:230 oldpars['i_zero.units'] = oldpars['scale.units']231 194 elif name == 'multilayer_vesicle': 232 195 if 'scale' in oldpars: … … 330 293 translation = _get_translation_table(model_info) 331 294 newpars = _hand_convert(newname, pars.copy()) 332 newpars = _convert_name(translation, newpars)333 295 newpars = _convert_pars(newpars, translation) 334 296 if not model_info.structure_factor:
Note: See TracChangeset
for help on using the changeset viewer.