Changeset 83195f7 in sasview for park_integration/AbstractFitEngine.py
- Timestamp:
- Mar 12, 2010 12:58:44 PM (15 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:
- 7e99f5c
- Parents:
- 20b6760
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
r393f0f3 r83195f7 257 257 or with vectors. 258 258 """ 259 self.x_bins_array = []260 self.y_bins_array = []261 259 self.res_err_image=[] 262 260 self.index_model=[] … … 265 263 self.set_data(sans_data2d ) 266 264 267 268 265 def set_data(self, sans_data2d, qmin=None, qmax=None ): 269 266 """ 270 Determine the correct x_bin and y_bin to fit 271 """ 272 self.x_bins_array= numpy.reshape(sans_data2d.x_bins, 273 [1,len(sans_data2d.x_bins)]) 274 self.y_bins_array = numpy.reshape(sans_data2d.y_bins, 275 [len(sans_data2d.y_bins),1]) 276 277 x_max = max(sans_data2d.xmin, sans_data2d.xmax) 278 y_max = max(sans_data2d.ymin, sans_data2d.ymax) 267 Determine the correct qx_data and qy_data within range to fit 268 """ 269 self.data = sans_data2d.data 270 self.err_data = sans_data2d.err_data 271 self.qx_data = sans_data2d.qx_data 272 self.qy_data = sans_data2d.qy_data 273 self.mask = sans_data2d.mask 274 275 x_max = max(math.fabs(sans_data2d.xmin), math.fabs(sans_data2d.xmax)) 276 y_max = max(math.fabs(sans_data2d.ymin), math.fabs(sans_data2d.ymax)) 279 277 280 278 ## fitting range … … 285 283 ## new error image for fitting purpose 286 284 if self.err_data== None or self.err_data ==[]: 287 self.res_err_data= numpy.zeros(len(self. y_bins),len(self.x_bins))285 self.res_err_data= numpy.zeros(len(self.data)) 288 286 else: 289 287 self.res_err_data = copy.deepcopy(self.err_data) 290 self.res_err_data[self.res_err_data==0]=1 291 292 self.radius= numpy.sqrt(self.x_bins_array**2 + self.y_bins_array**2) 293 self.index_model = (self.qmin <= self.radius)&(self.radius<= self.qmax) 294 295 288 self.res_err_data[self.res_err_data==0]=numpy.sqrt(self.data[self.res_err_data==0]) 289 290 self.radius= numpy.sqrt(self.qx_data**2 + self.qy_data**2) 291 292 # Note: mask = True: for MASK while mask = False for NOT to mask 293 self.index_model = ((self.qmin <= self.radius)&(self.radius<= self.qmax)) 294 self.mask = (self.index_model) & (self.mask) 295 296 296 def setFitRange(self,qmin=None,qmax=None): 297 297 """ to set the fit range""" … … 301 301 self.qmin = qmin 302 302 if qmax!=None: 303 self.qmax= qmax 304 305 self.radius= numpy.sqrt(self.x_bins_array**2 + self.y_bins_array**2) 306 self.index_model = (self.qmin <= self.radius)&(self.radius<= self.qmax) 303 self.qmax= qmax 304 self.radius= numpy.sqrt(self.qx_data**2 + self.qy_data**2) 305 self.index_model = ((self.qmin <= self.radius)&(self.radius<= self.qmax)) 306 self.mask = (self.index_model) &(self.mask) 307 307 308 308 309 def getFitRange(self): … … 313 314 314 315 def residuals(self, fn): 315 316 res=self.index_model*(self.data - fn([self.x_bins_array, 317 self.y_bins_array]))/self.res_err_data 318 return res.ravel() 316 """ 317 @return the residuals 318 """ 319 # use only the data point within ROI range 320 res=(self.data[self.mask] - fn([self.qx_data[self.mask], 321 self.qy_data[self.mask]]))/self.res_err_data[self.mask] 322 return res 319 323 320 324
Note: See TracChangeset
for help on using the changeset viewer.