1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | # To Sasview/documents/scripts |
---|
5 | |
---|
6 | from bumps.names import * |
---|
7 | from sasmodels.core import load_model |
---|
8 | from sasmodels.bumps_model import Model, Experiment |
---|
9 | from sasmodels.data import load_data, plot_data |
---|
10 | |
---|
11 | |
---|
12 | """ IMPORT THE DATA USED """ |
---|
13 | datafiles = ['latex_smeared_out_0.txt', 'latex_smeared_out_1.txt'] |
---|
14 | datasets = [load_data(el) for el in datafiles] |
---|
15 | |
---|
16 | for data in datasets: |
---|
17 | data.qmin = 0.0 |
---|
18 | data.qmax = 10.0 |
---|
19 | |
---|
20 | #sphere model |
---|
21 | kernel = load_model('sphere', dtype="single") |
---|
22 | pars = dict(scale=0.01, background=0.0, sld=1.0, sld_solvent=6.0, radius=1500.) |
---|
23 | model = Model(kernel, **pars) |
---|
24 | model.radius.range(0, inf) |
---|
25 | #model.background.range(-inf, inf) |
---|
26 | #model.scale.range(0, inf) |
---|
27 | model.sld.range(-inf, inf) |
---|
28 | model.sld_solvent.range(-inf, inf) |
---|
29 | |
---|
30 | free = FreeVariables( |
---|
31 | names=[data.filename for data in datasets], |
---|
32 | background=model.background, |
---|
33 | scale=model.scale, |
---|
34 | ) |
---|
35 | free.background.range(-inf, inf) |
---|
36 | free.scale.range(0, inf) |
---|
37 | |
---|
38 | M = [Experiment(data=data, model=model) for data in datasets] |
---|
39 | |
---|
40 | problem = FitProblem(M, freevars=free) |
---|
41 | |
---|
42 | print(problem._parameters) |
---|