Changeset bd49c79 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
Aug 4, 2016 2:47:27 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:
54bcd4a
Parents:
e1d6983
Message:

improve handling of multiplicity in sasview comparison

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rf67f26c rbd49c79  
    348348            nsigma=pars.get(p.id+"_pd_nsgima", 3.), 
    349349            pdtype=pars.get(p.id+"_pd_type", 'gaussian'), 
     350            relative_pd=p.relative_pd, 
    350351        ) 
    351352        lines.append(_format_par(p.name, **fields)) 
     
    354355    #return "\n".join("%s: %s"%(p, v) for p, v in sorted(pars.items())) 
    355356 
    356 def _format_par(name, value=0., pd=0., n=0, nsigma=3., pdtype='gaussian'): 
     357def _format_par(name, value=0., pd=0., n=0, nsigma=3., pdtype='gaussian', 
     358                relative_pd=False): 
    357359    # type: (str, float, float, int, float, str) -> str 
    358360    line = "%s: %g"%(name, value) 
    359361    if pd != 0.  and n != 0: 
     362        if relative_pd: 
     363            pd *= value 
    360364        line += " +/- %g  (%d points in [-%g,%g] sigma %s)"\ 
    361365                % (pd, n, nsigma, nsigma, pdtype) 
     
    446450        Sasview calculator for model. 
    447451        """ 
    448         # For multiplicity models, recreate the model the first time the 
    449         if model_info.control: 
    450             model[0] = ModelClass(int(pars[model_info.control])) 
     452        oldpars = revert_pars(model_info, pars) 
     453        # For multiplicity models, create a model with the correct multiplicity 
     454        control = oldpars.pop("CONTROL", None) 
     455        if control is not None: 
     456            # sphericalSLD has one fewer multiplicity.  This update should 
     457            # happen in revert_pars, but it hasn't been called yet. 
     458            model[0] = ModelClass(control) 
    451459        # paying for parameter conversion each time to keep life simple, if not fast 
    452         oldpars = revert_pars(model_info, pars) 
    453460        #print("sasview pars",oldpars) 
    454461        for k, v in oldpars.items(): 
Note: See TracChangeset for help on using the changeset viewer.