Changeset 54fb5d8 in sasmodels


Ignore:
Timestamp:
Dec 19, 2016 7:59:01 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
86e8e66
Parents:
01ecc31
Message:

slightly cleaner handling of version specific hand-coded conversions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/convert.py

    r16fd9e5 r54fb5d8  
    160160 
    161161def _hand_convert(name, oldpars, version='3.1.2'): 
    162     base_version = '3.1.2' 
    163     if name == 'core_shell_parallelepiped' and version == base_version: 
     162    if version == '3.1.2': 
     163        oldpars = _hand_convert_3_1_2_to_4_1(name, oldpars) 
     164    return oldpars 
     165 
     166def _hand_convert_3_1_2_to_4_1(name, oldpars): 
     167    if name == 'core_shell_parallelepiped': 
    164168        # Make sure pd on rim parameters defaults to zero 
    165169        # ... probably not necessary. 
     
    167171        oldpars['rimB.width'] = 0.0 
    168172        oldpars['rimC.width'] = 0.0 
    169     elif name == 'core_shell_ellipsoid:1' and version == base_version: 
     173    elif name == 'core_shell_ellipsoid:1': 
    170174        # Reverse translation (from new to old), from core_shell_ellipsoid.c 
    171175        #    equat_shell = equat_core + thick_shell 
     
    186190        oldpars['polar_core'] = polar_core / equat_core 
    187191        oldpars['polar_shell'] = (polar_shell-polar_core)/(equat_shell-equat_core) 
    188     elif name == 'hollow_cylinder' and version == base_version: 
     192    elif name == 'hollow_cylinder': 
    189193        # now uses radius and thickness 
    190194        thickness = oldpars['radius'] - oldpars['core_radius'] 
     
    193197            pd = oldpars['radius.width']*oldpars['radius']/thickness 
    194198            oldpars['radius.width'] = pd 
    195     elif name == 'multilayer_vesicle' and version == base_version: 
     199    elif name == 'multilayer_vesicle': 
    196200        if 'scale' in oldpars: 
    197201            oldpars['volfraction'] = oldpars['scale'] 
     
    207211        if 'scale.units' in oldpars: 
    208212            oldpars['volfraction.units'] = oldpars['scale.units'] 
    209     elif name == 'pearl_necklace' and version == base_version: 
     213    elif name == 'pearl_necklace': 
    210214        pass 
    211215        #_remove_pd(oldpars, 'num_pearls', name) 
    212216        #_remove_pd(oldpars, 'thick_string', name) 
    213     elif name == 'polymer_micelle' and version == base_version: 
     217    elif name == 'polymer_micelle': 
    214218        if 'ndensity' in oldpars: 
    215219            oldpars['ndensity'] /= 1e15 
     
    218222        if 'ndensity.upper' in oldpars: 
    219223            oldpars['ndensity.upper'] /= 1e15 
    220     elif name == 'rpa' and version == base_version: 
     224    elif name == 'rpa': 
    221225        # convert scattering lengths from femtometers to centimeters 
    222226        for p in "L1", "L2", "L3", "L4": 
     
    227231            if p + ".upper" in oldpars: 
    228232                oldpars[p + ".upper"] /= 1e-13 
    229     elif name == 'spherical_sld' and version == base_version: 
     233    elif name == 'spherical_sld': 
    230234        j = 0 
    231235        while "func_inter" + str(j) in oldpars: 
     
    247251            oldpars['n_shells'] = str(j + 1) 
    248252            j += 1 
    249     elif name == 'teubner_strey' and version == base_version: 
     253    elif name == 'teubner_strey': 
    250254        # basically undoing the entire Teubner-Strey calculations here. 
    251255        #    drho = (sld_a - sld_b) 
Note: See TracChangeset for help on using the changeset viewer.