Changeset 77bfb5f in sasmodels


Ignore:
Timestamp:
Apr 13, 2017 9:52:23 AM (8 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:
eaa4458
Parents:
597878a
Message:

fix calculation of cos-weighted theta values so tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/details.py

    rd4c33d6 r77bfb5f  
    232232    nvalues = kernel.info.parameters.nvalues 
    233233    scalars = [(v[0] if len(v) else np.NaN) for v, w in pairs] 
     234    # skipping scale and background when building values and weights 
    234235    values, weights = zip(*pairs[2:npars+2]) if npars else ((), ()) 
    235236    weights = correct_theta_weights(kernel.info.parameters, values, weights) 
     
    253254    evaluation strictly at the pole, which would otherwise send the weight to 
    254255    zero. 
    255     """ 
     256 
     257    Note: values and weights do not include scale and background 
     258    """ 
     259    # TODO: document code, explaining why scale and background are skipped 
     260    # given that we don't have scale and background in the list, we 
     261    # should be calling the variables something other than values and weights 
     262    # Apparently the parameters.theta_offset similarly skips scale and 
     263    # and background, so the indexing works out. 
    256264    if parameters.theta_offset >= 0: 
    257         index = parameters.theta_offset+len(parameters.COMMON) 
     265        index = parameters.theta_offset 
    258266        theta = values[index] 
    259267        theta_weight = np.minimum(cos(radians(theta)), 1e-6) 
    260268        # copy the weights list so we can update it 
    261269        weights = list(weights) 
    262         weights[index] = theta_weight*weights[index] 
     270        weights[index] = theta_weight*np.asarray(weights[index]) 
    263271        weights = tuple(weights) 
    264272    return weights 
Note: See TracChangeset for help on using the changeset viewer.