- Timestamp:
- Aug 31, 2015 8:24:45 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3e6aaad
- Parents:
- f224873
- git-author:
- Paul Kienzle <pkienzle@…> (08/31/15 20:12:39)
- git-committer:
- Paul Kienzle <pkienzle@…> (08/31/15 20:24:45)
- Location:
- example
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
example/fit.py
r5d3d7b4 r346bc88 4 4 import sys 5 5 from bumps.names import * 6 from sasmodels.core import load_model 6 7 from sasmodels import bumps_model as sas 7 8 … … 23 24 data = radial_data if section != "tangential" else tan_data 24 25 phi = 0 if section != "tangential" else 90 25 kernel = sas.load_model(name, dtype="single")26 kernel = load_model(name, dtype="single") 26 27 cutoff = 1e-3 27 28 28 29 if name == "ellipsoid": 29 model = sas. BumpsModel(data,kernel,30 scale=0.08,31 rpolar=15, requatorial=800,32 sld=.291, solvent_sld=7.105,33 background=0,34 theta=90, phi=phi,35 theta_pd=15, theta_pd_n=40, theta_pd_nsigma=3,36 rpolar_pd=0.222296, rpolar_pd_n=1, rpolar_pd_nsigma=0,37 requatorial_pd=.000128, requatorial_pd_n=1, requatorial_pd_nsigma=0,38 phi_pd=0, phi_pd_n=20, phi_pd_nsigma=3,39 )30 model = sas.Model(kernel, 31 scale=0.08, 32 rpolar=15, requatorial=800, 33 sld=.291, solvent_sld=7.105, 34 background=0, 35 theta=90, phi=phi, 36 theta_pd=15, theta_pd_n=40, theta_pd_nsigma=3, 37 rpolar_pd=0.222296, rpolar_pd_n=1, rpolar_pd_nsigma=0, 38 requatorial_pd=.000128, requatorial_pd_n=1, requatorial_pd_nsigma=0, 39 phi_pd=0, phi_pd_n=20, phi_pd_nsigma=3, 40 ) 40 41 41 42 42 43 # SET THE FITTING PARAMETERS 43 #model.rpolar.range(15, 1000)44 #model.requatorial.range(15, 1000)45 #model.theta_pd.range(0, 360)46 #model.background.range(0,1000)44 model.rpolar.range(15, 1000) 45 model.requatorial.range(15, 1000) 46 model.theta_pd.range(0, 360) 47 model.background.range(0,1000) 47 48 model.scale.range(0, 10) 48 49 49 50 51 50 52 elif name == "lamellar": 51 model = sas.BumpsModel(data, kernel, 52 scale=0.08, 53 thickness=19.2946, 54 sld=5.38,sld_sol=7.105, 55 background=0.003, 56 thickness_pd= 0.37765, thickness_pd_n=10, thickness_pd_nsigma=3, 57 ) 53 model = sas.Model(kernel, 54 scale=0.08, 55 thickness=19.2946, 56 sld=5.38,sld_sol=7.105, 57 background=0.003, 58 thickness_pd= 0.37765, thickness_pd_n=10, thickness_pd_nsigma=3, 59 ) 60 58 61 59 62 # SET THE FITTING PARAMETERS … … 84 87 theta_pd=10, theta_pd_n=50, theta_pd_nsigma=3, 85 88 phi_pd=0, phi_pd_n=10, phi_pd_nsigma=3) 86 model = sas. BumpsModel(data,kernel, **pars)89 model = sas.Model(kernel, **pars) 87 90 88 91 # SET THE FITTING PARAMETERS … … 99 102 100 103 elif name == "core_shell_cylinder": 101 model = sas. BumpsModel(data,kernel,102 scale= .031, radius=19.5, thickness=30, length=22,103 core_sld=7.105, shell_sld=.291, solvent_sld=7.105,104 background=0, theta=0, phi=phi,104 model = sas.Model(kernel, 105 scale= .031, radius=19.5, thickness=30, length=22, 106 core_sld=7.105, shell_sld=.291, solvent_sld=7.105, 107 background=0, theta=0, phi=phi, 105 108 106 radius_pd=0.26, radius_pd_n=10, radius_pd_nsigma=3,107 length_pd=0.26, length_pd_n=10, length_pd_nsigma=3,108 thickness_pd=1, thickness_pd_n=1, thickness_pd_nsigma=1,109 theta_pd=1, theta_pd_n=10, theta_pd_nsigma=3,110 phi_pd=0.1, phi_pd_n=1, phi_pd_nsigma=1,111 )109 radius_pd=0.26, radius_pd_n=10, radius_pd_nsigma=3, 110 length_pd=0.26, length_pd_n=10, length_pd_nsigma=3, 111 thickness_pd=1, thickness_pd_n=1, thickness_pd_nsigma=1, 112 theta_pd=1, theta_pd_n=10, theta_pd_nsigma=3, 113 phi_pd=0.1, phi_pd_n=1, phi_pd_nsigma=1, 114 ) 112 115 113 116 # SET THE FITTING PARAMETERS … … 126 129 127 130 elif name == "capped_cylinder": 128 model = sas. BumpsModel(data,kernel,129 scale=.08, radius=20, cap_radius=40, length=400,130 sld_capcyl=1, sld_solv=6.3,131 background=0, theta=0, phi=phi,132 radius_pd=.1, radius_pd_n=5, radius_pd_nsigma=3,133 cap_radius_pd=.1, cap_radius_pd_n=5, cap_radius_pd_nsigma=3,134 length_pd=.1, length_pd_n=1, length_pd_nsigma=0,135 theta_pd=.1, theta_pd_n=1, theta_pd_nsigma=0,136 phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0,137 dtype=dtype)131 model = sas.Model(kernel, 132 scale=.08, radius=20, cap_radius=40, length=400, 133 sld_capcyl=1, sld_solv=6.3, 134 background=0, theta=0, phi=phi, 135 radius_pd=.1, radius_pd_n=5, radius_pd_nsigma=3, 136 cap_radius_pd=.1, cap_radius_pd_n=5, cap_radius_pd_nsigma=3, 137 length_pd=.1, length_pd_n=1, length_pd_nsigma=0, 138 theta_pd=.1, theta_pd_n=1, theta_pd_nsigma=0, 139 phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0, 140 ) 138 141 139 142 model.scale.range(0, 1) … … 141 144 142 145 elif name == "triaxial_ellipsoid": 143 model = sas.BumpsModel(data, kernel, 144 scale=0.08, req_minor=15, req_major=20, rpolar=500, 145 sldEll=7.105, solvent_sld=.291, 146 background=5, theta=0, phi=phi, psi=0, 147 theta_pd=20, theta_pd_n=40, theta_pd_nsigma=3, 148 phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0, 149 psi_pd=30, psi_pd_n=1, psi_pd_nsigma=0, 150 req_minor_pd=.1, req_minor_pd_n=1, req_minor_pd_nsigma=0, 151 req_major_pd=.1, req_major_pd_n=1, req_major_pd_nsigma=0, 152 rpolar_pd=.1, rpolar_pd_n=1, rpolar_pd_nsigma=0, dtype=dtype) 146 model = sas.Model(kernel, 147 scale=0.08, req_minor=15, req_major=20, rpolar=500, 148 sldEll=7.105, solvent_sld=.291, 149 background=5, theta=0, phi=phi, psi=0, 150 theta_pd=20, theta_pd_n=40, theta_pd_nsigma=3, 151 phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0, 152 psi_pd=30, psi_pd_n=1, psi_pd_nsigma=0, 153 req_minor_pd=.1, req_minor_pd_n=1, req_minor_pd_nsigma=0, 154 req_major_pd=.1, req_major_pd_n=1, req_major_pd_nsigma=0, 155 rpolar_pd=.1, rpolar_pd_n=1, rpolar_pd_nsigma=0, 156 ) 153 157 154 158 # SET THE FITTING PARAMETERS … … 166 170 167 171 model.cutoff = cutoff 172 M = sas.Experiment(data=data, model=model) 168 173 if section == "both": 169 tan_model = sas. BumpsModel(tan_data, model.model,model.parameters())174 tan_model = sas.Model(model.kernel, **model.parameters()) 170 175 tan_model.phi = model.phi - 90 171 176 tan_model.cutoff = cutoff 172 problem = FitProblem([model, tan_model]) 177 tan_M = sas.Experiment(data=tan_data, model=tan_model) 178 problem = FitProblem([M, tan_M]) 173 179 else: 174 problem = FitProblem( model)180 problem = FitProblem(M) -
example/sesansfit.py
rc210c94 r346bc88 1 import numpy as np2 1 from bumps.names import * 3 2 4 3 from sasmodels import core, bumps_model 5 4 6 kernel = core.load_model("sphere", dtype='single')7 8 9 10 5 if True: # fix when data loader exists 11 6 # from sas.dataloader.readers\ 12 7 from sas.dataloader.loader import Loader 13 loader =Loader()8 loader = Loader() 14 9 filename = 'testsasview1.ses' 15 data =loader.load(filename)10 data = loader.load(filename) 16 11 if data is None: raise IOError("Could not load file %r"%(filename,)) 17 data.x /= 1012 data.x /= 10 18 13 # print data 19 14 # data = load_sesans('mydatfile.pz') … … 43 38 ## Sphere parameters 44 39 40 kernel = core.load_model("sphere", dtype='single') 45 41 phi = Parameter(0.1, name="phi") 46 model = bumps_model.BumpsModel(data, kernel, 47 scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius) 42 model = bumps_model.Model(kernel, 43 scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius, 44 ) 48 45 phi.range(0.001,0.5) 49 46 #model.radius.pmp(40) … … 54 51 #model.radius_pd_n=0 55 52 56 if False: # have sans data57 sansmodel = bumps_model.BumpsModel(sans_data, kernel, **model.parameters())58 problem = FitProblem([model, sansmodel])59 else:60 problem = FitProblem(model)61 62 63 53 ### Tri-Axial Ellipsoid 64 54 # 55 #kernel = core.load_model("triaxial_ellipsoid", dtype='single') 65 56 #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) 57 #model = bumps_model.Model(kernel, 58 # scale=phi*(1-phi), sld=7.0, solvent_sld=1.0, radius=radius, 59 # ) 68 60 #phi.range(0.001,0.90) 69 61 ##model.radius.pmp(40) … … 71 63 ##model.sld.pmp(5) 72 64 ##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) 65 ##model.radius_pd = 0 66 ##model.radius_pd_n = 0 67 68 if 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]) 72 else: 73 M_sesans = bumps_model.Experiment(data=data, model=model) 74 problem = FitProblem(M_sesans) 75
Note: See TracChangeset
for help on using the changeset viewer.