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