Changeset e1ea6b5 in sasmodels


Ignore:
Timestamp:
Dec 2, 2016 2:51:09 PM (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:
9eb5eca
Parents:
077666e
Message:

Streamlined code and have Unified Power Rg and Lamellar PC models loading properly.

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/conversion_table.py

    r077666e re1ea6b5  
    88""" 
    99 
     10# TODO: May need to version this for future versions of sasview when 
     11# TODO: models are reparameterized 
    1012 
    1113CONVERSION_TABLE = { 
     
    825827    "unified_power_Rg": [ 
    826828        "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               }) 
    829839    ], 
    830840    "vesicle": [ 
  • sasmodels/convert.py

    r077666e re1ea6b5  
    5353    ("_pd_nsigma", ".nsigmas"), 
    5454    ("_pd_type", ".type"), 
     55    (".lower", ".lower"), 
     56    (".upper", ".upper"), 
     57    (".fittable", ".fittable"), 
     58    (".std", ".std"), 
     59    (".units", ".units"), 
     60    ("", "") 
    5561    ] 
    5662 
     
    117123def _pd_to_underscores(pars): 
    118124    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 names 
    123     :param conv_dict: conversion dictionary mapping new name : old name 
    124     :param pars: parameters to convert 
    125     :return: 
    126     """ 
    127     new_pars = {} 
    128     i = 0 
    129     j = 0 
    130     for key_par, value_par in pars.iteritems(): 
    131         j += 1 
    132         for key_conv, value_conv in conv_dict.iteritems(): 
    133             if value_conv is None: 
    134                 pass 
    135             elif "background" == key_par or "scale" == key_par: 
    136                 new_pars[key_par] = value_par 
    137                 i += 1 
    138                 break 
    139             elif re.search(value_conv, key_par): 
    140                 new_pars[key_par.replace(value_conv, key_conv)] = value_par 
    141                 i += 1 
    142                 break 
    143         if i != j: 
    144             new_pars[key_par] = value_par 
    145             i += 1 
    146     return new_pars 
    147125 
    148126def _convert_pars(pars, mapping): 
     
    166144                    del newpars[source] 
    167145    return newpars 
    168  
    169146 
    170147def _conversion_target(model_name): 
     
    215192            pd = oldpars['radius.width']*oldpars['radius']/thickness 
    216193            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.0 
    221         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'] 
    231194    elif name == 'multilayer_vesicle': 
    232195        if 'scale' in oldpars: 
     
    330293        translation = _get_translation_table(model_info) 
    331294    newpars = _hand_convert(newname, pars.copy()) 
    332     newpars = _convert_name(translation, newpars) 
    333295    newpars = _convert_pars(newpars, translation) 
    334296    if not model_info.structure_factor: 
Note: See TracChangeset for help on using the changeset viewer.