Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • example/multiscatfit.py

    r2c4a190 r49d1f8b8  
    1515 
    1616    # Show the model without fitting 
    17     PYTHONPATH=..:../../bumps:../../sasview/src python multiscatfit.py 
     17    PYTHONPATH=..:../explore:../../bumps:../../sasview/src python multiscatfit.py 
    1818 
    1919    # Run the fit 
    20     PYTHONPATH=..:../../bumps:../../sasview/src ../../bumps/run.py \ 
     20    PYTHONPATH=..:../explore:../../bumps:../../sasview/src ../../bumps/run.py \ 
    2121    multiscatfit.py --store=/tmp/t1 
    2222 
     
    5555    ) 
    5656 
    57 # Tie the model to the data 
    58 M = Experiment(data=data, model=model) 
    59  
    60 # Stack mulitple scattering on top of the existing resolution function. 
    61 M.resolution = MultipleScattering(resolution=M.resolution, probability=0.) 
    62  
    6357# SET THE FITTING PARAMETERS 
    6458model.radius_polar.range(15, 3000) 
     
    7165model.scale.range(0, 0.1) 
    7266 
    73 # The multiple scattering probability parameter is in the resolution function 
    74 # instead of the scattering function, so access it through M.resolution 
    75 M.scattering_probability.range(0.0, 0.9) 
     67# Mulitple scattering probability parameter 
     68# HACK: the probability is stuffed in as an extra parameter to the experiment. 
     69probability = Parameter(name="probability", value=0.0) 
     70probability.range(0.0, 0.9) 
    7671 
    77 # Let bumps know that we are fitting this experiment 
     72M = Experiment(data=data, model=model, extra_pars={'probability': probability}) 
     73 
     74# Stack mulitple scattering on top of the existing resolution function. 
     75# Because resolution functions in sasview don't have fitting parameters, 
     76# we instead allow the multiple scattering calculator to take a function 
     77# instead of a probability.  This function returns the current value of 
     78# the parameter. ** THIS IS TEMPORARY ** when multiple scattering is 
     79# properly integrated into sasmodels and sasview, its fittable parameter 
     80# will be treated like the model parameters. 
     81M.resolution = MultipleScattering(resolution=M.resolution, 
     82                                  probability=lambda: probability.value, 
     83                                  ) 
     84M._kernel_inputs = M.resolution.q_calc 
    7885problem = FitProblem(M) 
    7986 
Note: See TracChangeset for help on using the changeset viewer.