Changeset f1765a2 in sasmodels for sasmodels/convert.py


Ignore:
Timestamp:
Jul 24, 2016 2:20:08 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2c74c11
Parents:
7b7da6b
Message:

Support magnetism in sasmodels:sasview-3.1 comparison

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/convert.py

    r32e3c9b rf1765a2  
    3838] 
    3939 
     40MAGNETIC_SASVIEW_MODELS = [ 
     41    'core_shell', 
     42    'core_multi_shell', 
     43    'cylinder', 
     44    'parallelepiped', 
     45    'sphere', 
     46] 
     47 
    4048 
    4149# Convert new style names for polydispersity info to old style names 
     
    193201            warnings.warn("parameter background not used in sasview %s"%name) 
    194202 
     203    # Remove magnetic parameters from non-magnetic sasview models 
     204    if name not in MAGNETIC_SASVIEW_MODELS: 
     205        oldpars = dict((k,v) for k,v in oldpars.items() if ':' not in k) 
    195206 
    196207    # If it is a product model P*S, then check the individual forms for special 
     
    218229                _remove_pd(oldpars, 'thick_flat'+str(k), 'thick_flat') 
    219230                _remove_pd(oldpars, 'thick_inter'+str(k), 'thick_inter') 
     231        elif name == 'core_multi_shell': 
     232            # kill extra shells 
     233            for k in range(5, 11): 
     234                oldpars.pop('sld_shell'+str(k), 0) 
     235                oldpars.pop('thick_shell'+str(k), 0) 
     236                oldpars.pop('mtheta:sld'+str(k), 0) 
     237                oldpars.pop('mphi:sld'+str(k), 0) 
     238                oldpars.pop('M0:sld'+str(k), 0) 
     239                _remove_pd(oldpars, 'sld_shell'+str(k), 'sld') 
     240                _remove_pd(oldpars, 'thick_shell'+str(k), 'thickness') 
     241        elif name == 'core_shell_parallelepiped': 
     242            _remove_pd(oldpars, 'rimA', name) 
     243        elif name in ['mono_gauss_coil','poly_gauss_coil']: 
     244            del oldpars['i_zero'] 
     245        elif name == 'onion': 
     246            oldpars.pop('n_shells', None) 
    220247        elif name == 'rpa': 
    221248            # convert scattering lengths from femtometers to centimeters 
     
    234261                for k in "Kab,Kac,Kad".split(','): 
    235262                    oldpars.pop(k, None) 
    236         elif name == 'core_shell_parallelepiped': 
    237             _remove_pd(oldpars, 'rimA', name) 
    238         elif name in ['mono_gauss_coil','poly_gauss_coil']: 
    239             del oldpars['i_zero'] 
    240         elif name == 'onion': 
    241             oldpars.pop('n_shells', None) 
    242263 
    243264    return oldpars 
     
    256277    if '*' in name: 
    257278        pars['background'] = 0 
     279 
     280    # Shut off magnetism when comparing non-magnetic sasview models 
     281    if name not in MAGNETIC_SASVIEW_MODELS: 
     282        suppress_magnetism = False 
     283        for key in pars.keys(): 
     284            suppress_magnetism = suppress_magnetism or (pars[key] != 0) 
     285            if key.startswith("M0:"): 
     286                pars[key] = 0 
     287        if suppress_magnetism: 
     288            warnings.warn("suppressing magnetism for comparison with sasview") 
     289 
     290    # Shut off theta polydispersity since algorithm has changed 
     291    if 'theta_pd_n' in pars: 
     292        if pars['theta_pd_n'] != 0: 
     293            warnings.warn("suppressing theta polydispersity for comparison with sasview") 
     294        pars['theta_pd_n'] = 0 
    258295 
    259296    # If it is a product model P*S, then check the individual forms for special 
Note: See TracChangeset for help on using the changeset viewer.