- Timestamp:
- Mar 6, 2019 6:05:28 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- f64b154, bd91e8f, c11d09f, 02226a2
- Parents:
- e589e9a (diff), 37f38ff (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- example
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
example/multiscatfit.py
r49d1f8b8 r2c4a190 15 15 16 16 # Show the model without fitting 17 PYTHONPATH=..:../ explore:../../bumps:../../sasview/src python multiscatfit.py17 PYTHONPATH=..:../../bumps:../../sasview/src python multiscatfit.py 18 18 19 19 # Run the fit 20 PYTHONPATH=..:../ explore:../../bumps:../../sasview/src ../../bumps/run.py \20 PYTHONPATH=..:../../bumps:../../sasview/src ../../bumps/run.py \ 21 21 multiscatfit.py --store=/tmp/t1 22 22 … … 55 55 ) 56 56 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 57 63 # SET THE FITTING PARAMETERS 58 64 model.radius_polar.range(15, 3000) … … 65 71 model.scale.range(0, 0.1) 66 72 67 # Mulitple scattering probability parameter 68 # HACK: the probability is stuffed in as an extra parameter to the experiment. 69 probability = Parameter(name="probability", value=0.0) 70 probability.range(0.0, 0.9) 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) 71 76 72 M = 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. 81 M.resolution = MultipleScattering(resolution=M.resolution, 82 probability=lambda: probability.value, 83 ) 84 M._kernel_inputs = M.resolution.q_calc 77 # Let bumps know that we are fitting this experiment 85 78 problem = FitProblem(M) 86 79 -
example/cylinder_eval.py
r2e66ef5 r23df833 3 3 """ 4 4 5 from numpy import logspace 5 from numpy import logspace, sqrt 6 6 from matplotlib import pyplot as plt 7 7 from sasmodels.core import load_model 8 from sasmodels.direct_model import call_kernel 8 from sasmodels.direct_model import call_kernel, call_Fq 9 9 10 10 model = load_model('cylinder') 11 11 q = logspace(-3, -1, 200) 12 12 kernel = model.make_kernel([q]) 13 Iq = call_kernel(kernel, dict(radius=200.)) 14 plt.loglog(q, Iq) 13 pars = {'radius': 200, 'radius_pd': 0.1, 'scale': 2} 14 Iq = call_kernel(kernel, pars) 15 F, Fsq, Reff, V, Vratio = call_Fq(kernel, pars) 16 plt.loglog(q, Iq, label='2 I(q)') 17 plt.loglog(q, F**2/V, label='<F(q)>^2/V') 18 plt.loglog(q, Fsq/V, label='<F^2(q)>/V') 15 19 plt.xlabel('q (1/A)') 16 plt.ylabel('I(q) ')20 plt.ylabel('I(q) (1/cm)') 17 21 plt.title('Cylinder with radius 200.') 22 plt.legend() 18 23 plt.show()
Note: See TracChangeset
for help on using the changeset viewer.