[c97724e] | 1 | import numpy as np |
---|
| 2 | from bumps.names import * |
---|
| 3 | |
---|
| 4 | from sasmodels import bumps_model as sas |
---|
| 5 | kernel = sas.load_model('sphere', dtype='single') |
---|
[9c117a2] | 6 | #kernel = sas.load_model('triaxial_ellipsoid', dtype='single') |
---|
[c97724e] | 7 | |
---|
| 8 | |
---|
[0ac3db5] | 9 | if True: # fix when data loader exists |
---|
| 10 | # from sas.dataloader.readers\ |
---|
| 11 | from sas.dataloader.loader import Loader |
---|
| 12 | loader=Loader() |
---|
| 13 | data=loader.load('testsasview1.ses') |
---|
[9c117a2] | 14 | data.x /=10 |
---|
[0ac3db5] | 15 | |
---|
| 16 | # data = load_sesans('mydatfile.pz') |
---|
| 17 | # sans_data = load_sans('mysansfile.xml') |
---|
| 18 | |
---|
[e806077] | 19 | else: |
---|
[c97724e] | 20 | SElength = np.linspace(0, 2400, 61) # [A] |
---|
[e806077] | 21 | data = np.ones_like(SElength) |
---|
| 22 | err_data = np.ones_like(SElength)*0.03 |
---|
| 23 | |
---|
[9c117a2] | 24 | class Sample: |
---|
[0ac3db5] | 25 | zacceptance = 0.1 # [A^-1] |
---|
[e806077] | 26 | thickness = 0.2 # [cm] |
---|
[9c117a2] | 27 | |
---|
| 28 | class SESANSData1D: |
---|
| 29 | #q_zmax = 0.23 # [A^-1] |
---|
| 30 | lam = 0.2 # [nm] |
---|
[0ac3db5] | 31 | x = SElength |
---|
| 32 | y = data |
---|
| 33 | dy = err_data |
---|
[9c117a2] | 34 | sample = Sample() |
---|
| 35 | data = SESANSData1D() |
---|
[0ac3db5] | 36 | |
---|
| 37 | radius = 1000 |
---|
| 38 | data.Rmax = 3*radius # [A] |
---|
[c97724e] | 39 | |
---|
[9c117a2] | 40 | ## Sphere parameters |
---|
| 41 | |
---|
[c97724e] | 42 | phi = Parameter(0.1, name="phi") |
---|
| 43 | model = sas.BumpsModel(data, kernel, |
---|
| 44 | scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) |
---|
[9c117a2] | 45 | phi.range(0.001,0.90) |
---|
| 46 | #model.radius.pmp(40) |
---|
| 47 | model.radius.range(100,10000) |
---|
| 48 | #model.sld.pmp(5) |
---|
| 49 | #model.background |
---|
| 50 | #model.radius_pd=0 |
---|
| 51 | #model.radius_pd_n=0 |
---|
[e806077] | 52 | |
---|
| 53 | if False: # have sans data |
---|
| 54 | sansmodel = sas.BumpsModel(sans_data, kernel, **model.parameters()) |
---|
| 55 | problem = FitProblem([model, sansmodel]) |
---|
| 56 | else: |
---|
| 57 | problem = FitProblem(model) |
---|
[c97724e] | 58 | |
---|
[9c117a2] | 59 | |
---|
| 60 | ### Tri-Axial Ellipsoid |
---|
| 61 | # |
---|
| 62 | #phi = Parameter(0.1, name='phi') |
---|
| 63 | #model = sas.BumpsModel(data, kernel, |
---|
| 64 | # scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) |
---|
| 65 | #phi.range(0.001,0.90) |
---|
| 66 | ##model.radius.pmp(40) |
---|
| 67 | #model.radius.range(100,10000) |
---|
| 68 | ##model.sld.pmp(5) |
---|
| 69 | ##model.background |
---|
| 70 | ##model.radius_pd=0 |
---|
| 71 | ##model.radius_pd_n=0 |
---|
| 72 | # |
---|
| 73 | #if False: # have sans data |
---|
| 74 | # sansmodel = sas.BumpsModel(sans_data, kernel, **model.parameters()) |
---|
| 75 | # problem = FitProblem([model, sansmodel]) |
---|
| 76 | #else: |
---|
| 77 | # problem = FitProblem(model) |
---|