Changeset bd49c79 in sasmodels


Ignore:
Timestamp:
Aug 4, 2016 4: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

Location:
sasmodels
Files:
2 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(): 
  • sasmodels/convert.py

    r0dd4199 rbd49c79  
    159159    # Remove control parameter from the result 
    160160    if model_info.control: 
    161         translation[model_info.control] = None 
     161        translation[model_info.control] = "CONTROL" 
    162162    return translation 
    163163 
     
    191191        oldpars = _trim_vectors(model_info, pars, oldpars) 
    192192 
     193    # Make sure the control parameter is an integer 
     194    if "CONTROL" in oldpars: 
     195        oldpars["CONTROL"] = int(oldpars["CONTROL"]) 
    193196 
    194197    # Note: update compare.constrain_pars to match 
Note: See TracChangeset for help on using the changeset viewer.