Changeset 298621b in sasmodels


Ignore:
Timestamp:
Dec 6, 2016 8:51:34 AM (7 years ago)
Author:
krzywon
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
Message:

Documented versioning and modified how it works for better future compatibility.

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/conversion_table.py

    r4b4eee1 r298621b  
    55names for each parameter in sasmodels.  This is used by :mod:`convert` to 
    66determine the equivalent parameter set when comparing a sasmodels model to 
    7 the models defined in SasView 3.1. 
     7the models defined in previous versions of SasView and sasmodels. This is now 
     8versioned based on the version number of SasView. 
     9 
     10When any sasmodels parameter or model name is changed, this must be modified to 
     11account for that. 
     12 
     13Usage: 
     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 
     25Any future parameter and model name changes can and should be given in this 
     26table for future compatibility. 
    827""" 
    928 
    1029CONVERSION_TABLE = { 
    11     "4.1.0" : {}, 
    12     "4.0.1" : { 
     30    "4.0.1" : {}, 
     31    "3.1.2" : { 
    1332    "adsorbed_layer": [ 
    1433        "Core2ndMomentModel", 
  • sasmodels/convert.py

    r4b4eee1 r298621b  
    153153    two variants in sasview. 
    154154    """ 
    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(): 
    156157        if sasview_name == model_name: 
    157158            return sasmodels_name 
    158159    return None 
    159160 
    160  
    161 def _hand_convert(name, oldpars, version='4.0.1'): 
    162     if name == 'core_shell_parallelepiped' and version == '4.0.1': 
     161def _hand_convert(name, oldpars, version='3.1.2'): 
     162    base_version = '3.1.2' 
     163    if name == 'core_shell_parallelepiped' and version == base_version: 
    163164        # Make sure pd on rim parameters defaults to zero 
    164165        # ... probably not necessary. 
     
    166167        oldpars['rimB.width'] = 0.0 
    167168        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: 
    169170        # Reverse translation (from new to old), from core_shell_ellipsoid.c 
    170171        #    equat_shell = equat_core + thick_shell 
     
    185186        oldpars['polar_core'] = polar_core / equat_core 
    186187        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: 
    188189        # now uses radius and thickness 
    189190        thickness = oldpars['radius'] - oldpars['core_radius'] 
     
    192193            pd = oldpars['radius.width']*oldpars['radius']/thickness 
    193194            oldpars['radius.width'] = pd 
    194     elif name == 'multilayer_vesicle' and version == '4.0.1': 
     195    elif name == 'multilayer_vesicle' and version == base_version: 
    195196        if 'scale' in oldpars: 
    196197            oldpars['volfraction'] = oldpars['scale'] 
     
    206207        if 'scale.units' in oldpars: 
    207208            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: 
    209210        pass 
    210211        #_remove_pd(oldpars, 'num_pearls', name) 
    211212        #_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: 
    213214        if 'ndensity' in oldpars: 
    214215            oldpars['ndensity'] /= 1e15 
     
    226227            if p + ".upper" in oldpars: 
    227228                oldpars[p + ".upper"] /= 1e-13 
    228     elif name == 'spherical_sld' and version == '4.0.1': 
     229    elif name == 'spherical_sld' and version == base_version: 
    229230        oldpars["CONTROL"] = 0 
    230231        i = 0 
     
    232233            oldpars["CONTROL"] += 1 
    233234            i += 1 
    234     elif name == 'teubner_strey' and version == '4.0.1': 
     235    elif name == 'teubner_strey' and version == base_version: 
    235236        # basically undoing the entire Teubner-Strey calculations here. 
    236237        #    drho = (sld_a - sld_b) 
     
    288289        if ':' in newname:   # core_shell_ellipsoid:1 
    289290            model_info = load_model_info(newname[:-2]) 
    290             # Know that the table exists and isn't multiplicity so grab it directly 
     291            # Know the table exists and isn't multiplicity so grab it directly 
    291292            # Can't use _get_translation_table since that will return the 'bare' 
    292293            # version. 
     
    305306        name = newname 
    306307    return newname, newpars 
    307  
    308308 
    309309# ========= BACKWARD CONVERSION sasmodels => sasview 3.x =========== 
Note: See TracChangeset for help on using the changeset viewer.