source: sasmodels/example/sesansfit_CodeCampIII.py @ 1198f90

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 1198f90 was a98958b, checked in by krzywon, 9 years ago

Good progress on SESANS scripting.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1from bumps.names import *
2
3from sasmodels import core, bumps_model
4
5if True: # fix when data loader exists
6#    from sas.dataloader.readers\
7    from sas.dataloader.loader import Loader
8    loader = Loader()
9    filename = 'sphere.ses'
10    data = loader.load(filename)
11    if data is None: raise IOError("Could not load file %r"%(filename,))
12    data.x /= 10
13#    print data
14#    data = load_sesans('mydatfile.pz')
15#    sans_data = load_sans('mysansfile.xml')
16
17else:
18    SElength = np.linspace(0, 2400, 61) # [A]
19    data = np.ones_like(SElength)
20    err_data = np.ones_like(SElength)*0.03
21
22    class Sample:
23        zacceptance = 0.1 # [A^-1]
24        thickness = 0.2 # [cm]
25
26    class SESANSData1D:
27        #q_zmax = 0.23 # [A^-1]
28        lam = 0.2 # [nm]
29        x = SElength
30        y = data
31        dy = err_data
32        sample = Sample()
33    data = SESANSData1D()
34
35radius = 1000
36data.Rmax = 3*radius # [A]
37
38##  Sphere parameters
39
40kernel = core.load_model("sphere", dtype='single')
41phi = Parameter(0.1, name="phi")
42model = bumps_model.Model(kernel,
43    scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius,
44    )
45phi.range(0.001,0.5)
46#model.radius.pmp(40)
47model.radius.range(1,10000)
48#model.sld.pm(5)
49#model.background
50#model.radius_pd=0
51#model.radius_pd_n=0
52
53### Tri-Axial Ellipsoid
54#
55#kernel = core.load_model("triaxial_ellipsoid", dtype='single')
56#phi = Parameter(0.1, name='phi')
57#model = bumps_model.Model(kernel,
58#    scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius,
59#    )
60#phi.range(0.001,0.90)
61##model.radius.pmp(40)
62#model.radius.range(100,10000)
63##model.sld.pmp(5)
64##model.background
65##model.radius_pd = 0
66##model.radius_pd_n = 0
67
68if False: # have sans data
69    M_sesans = bumps_model.Experiment(data=data, model=model)
70    M_sans = bumps_model.Experiment(data=sans_data, model=model)
71    problem = FitProblem([M_sesans, M_sans])
72else:
73    M_sesans = bumps_model.Experiment(data=data, model=model)
74    problem = FitProblem(M_sesans)
Note: See TracBrowser for help on using the repository browser.