Changeset 298621b in sasmodels
- Timestamp:
- Dec 6, 2016 10:51:34 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:
- 16fd9e5
- Parents:
- 4b4eee1
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/conversion_table.py
r4b4eee1 r298621b 5 5 names for each parameter in sasmodels. This is used by :mod:`convert` to 6 6 determine the equivalent parameter set when comparing a sasmodels model to 7 the models defined in SasView 3.1. 7 the models defined in previous versions of SasView and sasmodels. This is now 8 versioned based on the version number of SasView. 9 10 When any sasmodels parameter or model name is changed, this must be modified to 11 account for that. 12 13 Usage: 14 <old_Sasview_version> : { 15 <new_model_name> : [ 16 <old_model_name> , 17 { 18 <new_param_name_1> : <old_param_name_1>, 19 ... 20 <new_param_name_n> : <old_param_name_n> 21 } 22 ] 23 } 24 25 Any future parameter and model name changes can and should be given in this 26 table for future compatibility. 8 27 """ 9 28 10 29 CONVERSION_TABLE = { 11 "4. 1.0" : {},12 " 4.0.1" : {30 "4.0.1" : {}, 31 "3.1.2" : { 13 32 "adsorbed_layer": [ 14 33 "Core2ndMomentModel", -
sasmodels/convert.py
r4b4eee1 r298621b 153 153 two variants in sasview. 154 154 """ 155 for sasmodels_name, [sasview_name, _] in CONVERSION_TABLE.get(version).items(): 155 for sasmodels_name, [sasview_name, _] in \ 156 CONVERSION_TABLE.get(version).items(): 156 157 if sasview_name == model_name: 157 158 return sasmodels_name 158 159 return None 159 160 160 161 def _hand_convert(name, oldpars, version='4.0.1'): 162 if name == 'core_shell_parallelepiped' and version == '4.0.1':161 def _hand_convert(name, oldpars, version='3.1.2'): 162 base_version = '3.1.2' 163 if name == 'core_shell_parallelepiped' and version == base_version: 163 164 # Make sure pd on rim parameters defaults to zero 164 165 # ... probably not necessary. … … 166 167 oldpars['rimB.width'] = 0.0 167 168 oldpars['rimC.width'] = 0.0 168 elif name == 'core_shell_ellipsoid:1' and version == '4.0.1':169 elif name == 'core_shell_ellipsoid:1' and version == base_version: 169 170 # Reverse translation (from new to old), from core_shell_ellipsoid.c 170 171 # equat_shell = equat_core + thick_shell … … 185 186 oldpars['polar_core'] = polar_core / equat_core 186 187 oldpars['polar_shell'] = (polar_shell-polar_core)/(equat_shell-equat_core) 187 elif name == 'hollow_cylinder' and version == '4.0.1':188 elif name == 'hollow_cylinder' and version == base_version: 188 189 # now uses radius and thickness 189 190 thickness = oldpars['radius'] - oldpars['core_radius'] … … 192 193 pd = oldpars['radius.width']*oldpars['radius']/thickness 193 194 oldpars['radius.width'] = pd 194 elif name == 'multilayer_vesicle' and version == '4.0.1':195 elif name == 'multilayer_vesicle' and version == base_version: 195 196 if 'scale' in oldpars: 196 197 oldpars['volfraction'] = oldpars['scale'] … … 206 207 if 'scale.units' in oldpars: 207 208 oldpars['volfraction.units'] = oldpars['scale.units'] 208 elif name == 'pearl_necklace' and version == '4.0.1':209 elif name == 'pearl_necklace' and version == base_version: 209 210 pass 210 211 #_remove_pd(oldpars, 'num_pearls', name) 211 212 #_remove_pd(oldpars, 'thick_string', name) 212 elif name == 'polymer_micelle' and version == '4.0.1':213 elif name == 'polymer_micelle' and version == base_version: 213 214 if 'ndensity' in oldpars: 214 215 oldpars['ndensity'] /= 1e15 … … 226 227 if p + ".upper" in oldpars: 227 228 oldpars[p + ".upper"] /= 1e-13 228 elif name == 'spherical_sld' and version == '4.0.1':229 elif name == 'spherical_sld' and version == base_version: 229 230 oldpars["CONTROL"] = 0 230 231 i = 0 … … 232 233 oldpars["CONTROL"] += 1 233 234 i += 1 234 elif name == 'teubner_strey' and version == '4.0.1':235 elif name == 'teubner_strey' and version == base_version: 235 236 # basically undoing the entire Teubner-Strey calculations here. 236 237 # drho = (sld_a - sld_b) … … 288 289 if ':' in newname: # core_shell_ellipsoid:1 289 290 model_info = load_model_info(newname[:-2]) 290 # Know th at the table exists and isn't multiplicity so grab it directly291 # Know the table exists and isn't multiplicity so grab it directly 291 292 # Can't use _get_translation_table since that will return the 'bare' 292 293 # version. … … 305 306 name = newname 306 307 return newname, newpars 307 308 308 309 309 # ========= BACKWARD CONVERSION sasmodels => sasview 3.x ===========
Note: See TracChangeset
for help on using the changeset viewer.