Changeset 88fafac in sasmodels
- Timestamp:
- Nov 15, 2016 10:32:25 AM (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:
- 8d06779
- Parents:
- 8c65a33
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
r037aa3d r88fafac 54 54 ("_pd_type", ".type"), 55 55 ] 56 57 CONVERT_OLD =[ 58 "fittable", 59 "std", 60 "upper", 61 "lower", 62 "units" 63 ] 56 64 57 65 def _rescale(par, scale): … … 117 125 def _pd_to_underscores(pars): 118 126 return dict((_dot_pd_to_underscore_pd(k), v) for k, v in pars.items()) 127 128 def _convert_name(conv_dict, pars): 129 """ 130 Renames parameter values (upper, lower, etc) to v4.0 names 131 :param conv_dict: conversion dictionary mapping new name : old name 132 :param pars: parameters to convert 133 :return: 134 """ 135 import re 136 new_pars = {} 137 for key_par, value_par in pars.iteritems(): 138 for key_conv, value_conv in conv_dict.iteritems(): 139 if re.search(value_conv, key_par): 140 new_pars[key_par.replace(value_conv, key_conv)] = value_par 141 break 142 elif re.search("background", key_par) or re.search("scale", key_par): 143 new_pars[key_par] = value_par 144 break 145 return new_pars 119 146 120 147 def _convert_pars(pars, mapping): … … 193 220 if 'ndensity' in oldpars: 194 221 oldpars['ndensity'] /= 1e15 222 oldpars['ndensity.lower'] /= 1e15 223 oldpars['ndensity.upper'] /= 1e15 195 224 elif name == 'rpa': 196 225 # convert scattering lengths from femtometers to centimeters 197 226 for p in "L1", "L2", "L3", "L4": 198 if p in oldpars: oldpars[p] /= 1e-13 227 if p in oldpars: 228 oldpars[p] /= 1e-13 229 oldpars[p + ".lower"] /= 1e-13 230 oldpars[p + ".upper"] /= 1e-13 199 231 elif name == 'spherical_sld': 200 232 oldpars["CONTROL"] += 1 … … 256 288 model_info = load_model_info(newname) 257 289 translation = _get_translation_table(model_info) 258 newpars = _hand_convert(newname, pars.copy()) 290 newpars = _convert_name(translation, pars.copy()) 291 newpars = _hand_convert(newname, newpars) 259 292 newpars = _convert_pars(newpars, translation) 260 293 newpars = _rescale_sld(model_info, newpars, 1e6)
Note: See TracChangeset
for help on using the changeset viewer.