Changeset 49d1f8b8 in sasmodels


Ignore:
Timestamp:
Mar 5, 2018 6:33:00 PM (7 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:
bf94e6e
Parents:
bc248f8
Message:

move multiscat into sasmodels namespace to make it easier to run the example

Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • example/multiscatfit.py

    rbc248f8 r49d1f8b8  
    3434from sasmodels.data import load_data, set_beam_stop, set_top 
    3535 
    36 from multiscat import MultipleScattering 
     36from sasmodels.multiscat import MultipleScattering 
    3737 
    3838## Load the data 
    3939#data = load_data('DEC07267.DAT') 
    4040#set_beam_stop(data, 0.003, outer=0.025) 
    41 data = load_data('latex_smeared.xml', index=1) 
     41data = load_data('latex_smeared.xml', index=0) 
    4242 
    4343## Define the model 
     
    6666 
    6767# Mulitple scattering probability parameter 
    68 # HACK: the parameter is assigned to model.theta, which is otherwise unused 
    69 # since the dataset is 1D; this won't work for 2D data 
     68# HACK: the probability is stuffed in as an extra parameter to the experiment. 
    7069probability = Parameter(name="probability", value=0.0) 
    7170probability.range(0.0, 0.9) 
    72 model.phi = probability 
    7371 
    74 M = Experiment(data=data, model=model) 
     72M = Experiment(data=data, model=model, extra_pars={'probability': probability}) 
    7573 
    7674# Stack mulitple scattering on top of the existing resolution function. 
  • sasmodels/bumps_model.py

    r2d81cfe r49d1f8b8  
    137137    """ 
    138138    _cache = None # type: Dict[str, np.ndarray] 
    139     def __init__(self, data, model, cutoff=1e-5, name=None): 
     139    def __init__(self, data, model, cutoff=1e-5, name=None, extra_pars=None): 
    140140        # type: (Data, Model, float) -> None 
    141141        # remember inputs so we can inspect from outside 
     
    145145        self._interpret_data(data, model.sasmodel) 
    146146        self._cache = {} 
     147        self.extra_pars = extra_pars 
    147148 
    148149    def update(self): 
     
    166167        Return a dictionary of parameters 
    167168        """ 
    168         return self.model.parameters() 
     169        pars = self.model.parameters() 
     170        if self.extra_pars: 
     171            pars.update(self.extra_pars) 
     172        return pars 
    169173 
    170174    def theory(self): 
  • sasmodels/multiscat.py

    rbc248f8 r49d1f8b8  
    144144        frame = np.fft.ifft2(F_convolved) 
    145145        result = scale * _inverse_shift(frame.real, dtype=self.dtype) 
    146         #print("multiscat time", time.time()-t0) 
     146        #print("numpy multiscat time", time.time()-t0) 
    147147        return result 
    148148 
     
    237237        #result = scale * _inverse_shift(frame.real, dtype=self.dtype) 
    238238        result = scale * _inverse_shift(frame.real, dtype=self.dtype) 
    239         #print("multiscat time", time.time()-t0) 
     239        #print("OpenCL multiscat time", time.time()-t0) 
    240240        return result 
    241241 
Note: See TracChangeset for help on using the changeset viewer.