Changeset b6dab59 in sasmodels


Ignore:
Timestamp:
Sep 11, 2018 12:40:07 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
1e420e6
Parents:
2c12061
Message:

set structure factor background default to 0.0

Location:
sasmodels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    rbd7630d rb6dab59  
    11511151        'rel_err'   : True, 
    11521152        'explore'   : False, 
    1153         'use_demo'  : True, 
     1153        'use_demo'  : False, 
    11541154        'zero'      : False, 
    11551155        'html'      : False, 
  • sasmodels/generate.py

    r6e45516 rb6dab59  
    968968        pars = model_info.parameters.kernel_parameters 
    969969    else: 
    970         pars = model_info.parameters.COMMON + model_info.parameters.kernel_parameters 
     970        pars = (model_info.parameters.common_parameters 
     971                + model_info.parameters.kernel_parameters) 
    971972    partable = make_partable(pars) 
    972973    subst = dict(id=model_info.id.replace('_', '-'), 
  • sasmodels/modelinfo.py

    r7b9e4dd rb6dab59  
    405405      parameters counted as n individual parameters p1, p2, ... 
    406406 
     407    * *common_parameters* is the list of common parameters, with a unique 
     408      copy for each model so that structure factors can have a default 
     409      background of 0.0. 
     410 
    407411    * *call_parameters* is the complete list of parameters to the kernel, 
    408412      including scale and background, with vector parameters recorded as 
     
    417421    parameters don't use vector notation, and instead use p1, p2, ... 
    418422    """ 
    419     # scale and background are implicit parameters 
    420     COMMON = [Parameter(*p) for p in COMMON_PARAMETERS] 
    421  
    422423    def __init__(self, parameters): 
    423424        # type: (List[Parameter]) -> None 
     425 
     426        # scale and background are implicit parameters 
     427        # Need them to be unique to each model in case they have different 
     428        # properties, such as default=0.0 for structure factor backgrounds. 
     429        self.common_parameters = [Parameter(*p) for p in COMMON_PARAMETERS] 
     430 
    424431        self.kernel_parameters = parameters 
    425432        self._set_vector_lengths() 
     
    570577    def _get_call_parameters(self): 
    571578        # type: () -> List[Parameter] 
    572         full_list = self.COMMON[:] 
     579        full_list = self.common_parameters[:] 
    573580        for p in self.kernel_parameters: 
    574581            if p.length == 1: 
     
    673680 
    674681        # Gather the user parameters in order 
    675         result = control + self.COMMON 
     682        result = control + self.common_parameters 
    676683        for p in self.kernel_parameters: 
    677684            if not is2d and p.type in ('orientation', 'magnetic'): 
     
    772779        return kernel_module.model_info 
    773780    info = ModelInfo() 
     781 
     782    # Build the parameter table 
    774783    #print("make parameter table", kernel_module.parameters) 
    775784    parameters = make_parameter_table(getattr(kernel_module, 'parameters', [])) 
     785 
     786    # background defaults to zero for structure factor models 
     787    structure_factor = getattr(kernel_module, 'structure_factor', False) 
     788    if structure_factor: 
     789        # Make sure background is the second common parameter 
     790        assert COMMON_PARAMETERS[1][0] == "background" 
     791        parameters.common_parameters[1].default = 0.0 
     792 
     793    # TODO: remove demo parameters 
     794    # The plots in the docs are generated from the model default values. 
     795    # Sascomp set parameters from the command line, and so doesn't need 
     796    # demo values for testing. 
    776797    demo = expand_pars(parameters, getattr(kernel_module, 'demo', None)) 
     798 
    777799    filename = abspath(kernel_module.__file__).replace('.pyc', '.py') 
    778800    kernel_id = splitext(basename(filename))[0] 
     
    791813    info.docs = kernel_module.__doc__ 
    792814    info.category = getattr(kernel_module, 'category', None) 
    793     info.structure_factor = getattr(kernel_module, 'structure_factor', False) 
     815    info.structure_factor = structure_factor 
    794816    info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 
    795817    info.source = getattr(kernel_module, 'source', []) 
  • sasmodels/models/hardsphere.py

    r2d81cfe rb6dab59  
    171171# VR defaults to 1.0 
    172172 
    173 demo = dict(radius_effective=200, volfraction=0.2, 
    174             radius_effective_pd=0.1, radius_effective_pd_n=40) 
    175173# Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, 
    176174# assuming double precision sasview is correct 
Note: See TracChangeset for help on using the changeset viewer.