Changeset 9a9f5b5 in sasmodels
- Timestamp:
- Jul 22, 2014 9:16:56 AM (10 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:
- d772f5d
- Parents:
- 79fcc40
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
compare.py
r09e15be r9a9f5b5 15 15 16 16 def sasview_model(modelname, **pars): 17 modelname = modelname .capitalize()+"Model"17 modelname = modelname+"Model" 18 18 sans = __import__('sans.models.'+modelname) 19 19 ModelClass = getattr(getattr(sans.models,modelname,None),modelname,None) … … 54 54 ) 55 55 56 model = sasview_model(' cylinder', **pars)56 model = sasview_model('Cylinder', **pars) 57 57 tic() 58 58 for i in range(N): … … 91 91 axis_phi_pd_n=6, axis_phi_pd_nsigma=3,) 92 92 93 model = sasview_model(' ellipsoid', **pars)93 model = sasview_model('Ellipsoid', **pars) 94 94 tic() 95 95 for i in range(N): … … 130 130 length_pd=0.1, length_pd_n=1, length_pd_nsigma=0, 131 131 thickness_pd=0.1, thickness_pd_n=1, thickness_pd_nsigma=0, 132 axis_theta_pd_n= 10, axis_theta_pd_nsigma=3,133 axis_phi_pd=0.0008748, axis_phi_pd_n= 10, axis_phi_pd_nsigma=3,)132 axis_theta_pd_n=20, axis_theta_pd_nsigma=3, 133 axis_phi_pd=0.0008748, axis_phi_pd_n=60, axis_phi_pd_nsigma=3,) 134 134 135 135 model = sasview_model('CoreShellCylinder', **pars) -
sasmodel.py
r09e15be r9a9f5b5 41 41 extent=[xmin, xmax, ymin, ymax], vmin=vmin, vmax=vmax) 42 42 43 44 def plot_result(data, theory): 43 def plot_result(data, theory, view='linear'): 45 44 import matplotlib.pyplot as plt 45 from numpy.ma import masked_array, masked 46 46 plt.subplot(1, 3, 1) 47 47 #print "not a number",sum(np.isnan(data.data)) 48 48 #data.data[data.data<0.05] = 0.5 49 logdata = np.log10(data.data) 50 #print data.data.min(), data.data.max() 51 clean = logdata[~np.isnan(logdata)] 52 vmin, vmax = clean.min(), clean.max() 53 vmin, vmax = np.percentile(clean, 5), 1.05*vmax 54 #vmin,vmax = None,None 55 plot_data(data, logdata, vmin=vmin, vmax=vmax) 49 mdata = masked_array(data.data, data.mask) 50 mdata[np.isnan(mdata)] = masked 51 if view is 'log': 52 mdata[mdata <= 0] = masked 53 mdata = np.log10(mdata) 54 mtheory = masked_array(np.log10(theory), mdata.mask) 55 else: 56 mtheory = masked_array(theory, mdata.mask) 57 mresid = masked_array((theory-data.data)/data.err_data, data.mask) 58 vmin = min(mdata.min(), mtheory.min()) 59 vmax = max(mdata.max(), mtheory.max()) 60 61 plot_data(data, mdata, vmin=vmin, vmax=vmax) 56 62 plt.colorbar() 57 63 plt.subplot(1, 3, 2) 58 plot_data(data, np.log10(theory), vmin=vmin, vmax=vmax)64 plot_data(data, mtheory, vmin=vmin, vmax=vmax) 59 65 plt.colorbar() 60 66 plt.subplot(1, 3, 3) 61 plot_data(data, (theory-data.data)/data.err_data)67 plot_data(data, mresid) 62 68 plt.colorbar() 63 69 … … 102 108 self._parameters = dict((k, Parameter.default(v, name=k)) for k, v in pars.items()) 103 109 110 def set_result(self, result): 111 self.result = result 112 return self.result 113 114 def get_result(self): 115 return self.result 116 104 117 def numpoints(self): 105 118 return len(self.iq) … … 124 137 def residuals(self): 125 138 #if np.any(self.err ==0): print "zeros in err" 126 return (self. theory()[self.index]-self.iq)/self.diq139 return (self.get_result()[self.index]-self.iq)/self.diq 127 140 128 141 def nllf(self): … … 134 147 return 2*self.nllf()/self.dof 135 148 136 def plot(self, view='l inear'):137 plot_result(self.data, self. theory())149 def plot(self, view='log'): 150 plot_result(self.data, self.get_result(), view=view) 138 151 139 152 def save(self, basename):
Note: See TracChangeset
for help on using the changeset viewer.