Changeset 32f87a5 in sasmodels


Ignore:
Timestamp:
Oct 18, 2017 12:08:54 AM (5 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:
fbb9397
Parents:
8698a0d
Message:

update sasview wrapper with new way of handling orientation dispersity

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/direct_model.py

    r8698a0d r32f87a5  
    141141    npts = values.get(parameter.name+'_pd_n', 0) 
    142142    width = values.get(parameter.name+'_pd', 0.0) 
     143    relative = parameter.relative_pd 
    143144    if npts == 0 or width == 0 or not active: 
    144145        # Note: orientation parameters have the viewing angle as the parameter 
    145146        # value and the jitter in the distribution, so be sure to set the 
    146147        # empty pd for orientation parameters to 0. 
    147         pd = [value if parameter.type != 'orientation' else 0.0], [1.0] 
    148     else: 
    149         relative = parameter.relative_pd 
     148        pd = [value if relative else 0.0], [1.0] 
     149    else: 
    150150        limits = parameter.limits 
    151151        disperser = values.get(parameter.name+'_pd_type', 'gaussian') 
  • sasmodels/sasview_model.py

    r9f8ade1 r32f87a5  
    759759        if par.name not in self.params: 
    760760            if par.name == self.multiplicity_info.control: 
    761                 return [self.multiplicity], [1.0] 
     761                return self.multiplicity, [self.multiplicity], [1.0] 
    762762            else: 
    763763                # For hidden parameters use the default value. 
    764                 value = self._model_info.parameters.defaults.get(par.name, np.NaN) 
    765                 return [value], [1.0] 
     764                default = self._model_info.parameters.defaults.get(par.name, np.NaN) 
     765                return [default], [1.0] 
    766766        elif par.polydisperse: 
     767            value = self.params[par.name] 
    767768            dis = self.dispersion[par.name] 
    768769            if dis['type'] == 'array': 
    769                 value, weight = dis['values'], dis['weights'] 
     770                dispersity, weight = dis['values'], dis['weights'] 
    770771            else: 
    771                 value, weight = weights.get_weights( 
     772                dispersity, weight = weights.get_weights( 
    772773                    dis['type'], dis['npts'], dis['width'], dis['nsigmas'], 
    773                     self.params[par.name], par.limits, par.relative_pd) 
    774             return value, weight / np.sum(weight) 
    775         else: 
    776             return [self.params[par.name]], [1.0] 
     774                    value, par.limits, par.relative_pd) 
     775            return value, dispersity, weight 
     776        else: 
     777            value = self.params[par.name] 
     778            return value, [value if par.relative_pd else 0.0], [1.0] 
    777779 
    778780def test_cylinder(): 
Note: See TracChangeset for help on using the changeset viewer.