Changeset 2f4b430 in sasview for src/sas/perspectives/fitting/model_thread.py
- Timestamp:
- Mar 4, 2015 3:39:45 PM (9 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 74f419d
- Parents:
- 2f732b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/model_thread.py
r79492222 r2f4b430 43 43 self.update_chisqr = update_chisqr 44 44 self.source = source 45 45 46 46 def compute(self): 47 47 """ … … 59 59 math.fabs(self.data.ymin)), 2) 60 60 self.qmax = math.sqrt(newx + newy) 61 61 62 62 if self.data is None: 63 63 msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 64 64 raise ValueError, msg 65 65 66 66 # Define matrix where data will be plotted 67 67 radius = numpy.sqrt((self.data.qx_data * self.data.qx_data) + \ … … 73 73 index_model = index_model & self.data.mask 74 74 index_model = index_model & numpy.isfinite(self.data.data) 75 75 76 76 if self.smearer is not None: 77 77 # Set smearer w/ data, model and index. … … 112 112 update_chisqr=self.update_chisqr, 113 113 source=self.source) 114 114 115 115 116 116 class Calc1D(CalcThread): … … 156 156 self.out = None 157 157 self.index = None 158 158 159 159 def compute(self): 160 160 """ … … 164 164 output = numpy.zeros((len(self.data.x))) 165 165 index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 166 166 167 167 ##smearer the ouput of the plot 168 168 if self.smearer is not None: … … 174 174 else: 175 175 output[index] = self.model.evalDistribution(self.data.x[index]) 176 176 177 177 elapsed = time.time() - self.starttime 178 178 179 179 self.complete(x=self.data.x[index], y=output[index], 180 180 page_id=self.page_id, … … 187 187 update_chisqr=self.update_chisqr, 188 188 source=self.source) 189 189 190 190 def results(self): 191 191 """ … … 196 196 """ 197 197 Example: :: 198 198 199 199 class CalcCommandline: 200 200 def __init__(self, n=20000): 201 201 #print thread.get_ident() 202 202 from sas.models.CylinderModel import CylinderModel 203 203 204 204 model = CylinderModel() 205 206 205 206 207 207 print model.runXY([0.01, 0.02]) 208 208 209 209 qmax = 0.01 210 210 qstep = 0.0001 211 211 self.done = False 212 212 213 213 x = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 214 214 y = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 215 216 215 216 217 217 calc_thread_2D = Calc2D(x, y, None, model.clone(),None, 218 218 -qmax, qmax,qstep, … … 220 220 updatefn=self.update , 221 221 yieldtime=0.0) 222 222 223 223 calc_thread_2D.queue() 224 224 calc_thread_2D.ready(2.5) 225 225 226 226 while not self.done: 227 227 time.sleep(1) 228 228 229 229 def update(self,output): 230 230 print "update" 231 231 232 232 def complete(self, image, data, model, elapsed, qmin, qmax,index, qstep ): 233 233 print "complete" 234 234 self.done = True 235 235 236 236 if __name__ == "__main__": 237 237 CalcCommandline()
Note: See TracChangeset
for help on using the changeset viewer.