Changeset 050c2c8 in sasmodels


Ignore:
Timestamp:
Sep 27, 2016 3:23:51 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:
340428e
Parents:
f1a8811
Message:

sasview compare with alternate polydispersity functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    ra557a99 r050c2c8  
    3838from . import core 
    3939from . import kerneldll 
     40from . import weights 
    4041from .data import plot_theory, empty_data1D, empty_data2D 
    4142from .direct_model import DirectModel 
     
    390391    from sas.models.qsmearing import smear_selection 
    391392    from sas.models.MultiplicationModel import MultiplicationModel 
     393    from sas.models.dispersion_models import models as dispersers 
    392394 
    393395    def get_model_class(name): 
     
    422424        ModelClass = get_model_class(old_name) 
    423425        model = [ModelClass()] 
     426    model[0].disperser_handles = {} 
    424427 
    425428    # build a smearer with which to call the model, if necessary 
     
    458461            model[0] = ModelClass(control) 
    459462        # paying for parameter conversion each time to keep life simple, if not fast 
     463        for k, v in oldpars.items(): 
     464            if k.endswith('.type'): 
     465                par = k[:-5] 
     466                cls = dispersers[v if v != 'rectangle' else 'rectangula'] 
     467                handle = cls() 
     468                model[0].disperser_handles[par] = handle 
     469                model[0].set_dispersion(par, handle) 
     470 
    460471        #print("sasview pars",oldpars) 
    461472        for k, v in oldpars.items(): 
    462473            name_attr = k.split('.')  # polydispersity components 
    463474            if len(name_attr) == 2: 
    464                 model[0].dispersion[name_attr[0]][name_attr[1]] = v 
     475                par, disp_par = name_attr 
     476                model[0].dispersion[par][disp_par] = v 
    465477            else: 
    466478                model[0].setParam(k, v) 
Note: See TracChangeset for help on using the changeset viewer.