Changeset e575db9 in sasview for sansview/perspectives/fitting/model_thread.py
- Timestamp:
- Mar 12, 2010 1:16:01 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:
- 00d3528
- Parents:
- 3080527
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/model_thread.py
re627f19 re575db9 25 25 self.qmax= qmax 26 26 self.qstep= qstep 27 # Reshape dimensions of x and y to call evalDistribution 28 #self.x_array = numpy.reshape(x,[len(x),1]) 29 #self.y_array = numpy.reshape(y,[1,len(y)]) 30 self.x_array = numpy.reshape(x,[1,len(x)]) 31 self.y_array = numpy.reshape(y,[len(y),1]) 32 # Numpy array of dimensions 1 used for model.run method 33 self.x= numpy.array(x) 34 self.y= numpy.array(y) 27 28 self.x = x 29 self.y = y 35 30 self.data= data 36 31 # the model on to calculate … … 51 46 newy= math.pow(max(math.fabs(self.data.ymax),math.fabs(self.data.ymin)),2) 52 47 self.qmax=math.sqrt( newx + newy ) 53 # Define matrix where data will be plotted 54 radius= numpy.sqrt( self.x_array**2 + self.y_array**2 ) 55 index_data= (self.qmin<= radius) 56 index_model = (self.qmin <= radius)&(radius<= self.qmax) 57 58 output = numpy.zeros((len(self.x),len(self.y))) 59 60 ## receive only list of 2 numpy array 61 ## One must reshape to vertical and the other to horizontal 62 value = self.model.evalDistribution([self.x_array,self.y_array] ) 63 ## for data ignore the qmax 64 if self.data == None: 48 49 if self.data != None: 50 self.qx_data = self.data.qx_data 51 self.qy_data = self.data.qy_data 52 self.mask = self.data.mask 53 else: 54 xbin = numpy.linspace(start= -1*self.qmax, 55 stop= self.qmax, 56 num= self.qstep, 57 endpoint=True ) 58 ybin = numpy.linspace(start= -1*self.qmax, 59 stop= self.qmax, 60 num= self.qstep, 61 endpoint=True ) 62 63 new_xbin = numpy.tile(xbin, (len(ybin),1)) 64 new_ybin = numpy.tile(ybin, (len(xbin),1)) 65 new_ybin = new_ybin.swapaxes(0,1) 66 new_xbin = new_xbin.flatten() 67 new_ybin = new_ybin.flatten() 68 self.qy_data = new_ybin 69 self.qx_data = new_xbin 70 71 self.mask = numpy.ones(len(self.qx_data),dtype=bool) 72 73 # Define matrix where data will be plotted 74 radius= numpy.sqrt( self.qx_data*self.qx_data + self.qy_data*self.qy_data ) 75 index_data= (self.qmin<= radius)&(self.mask) 76 77 # For theory, qmax is based on 1d qmax 78 # so that must be mulitified by sqrt(2) to get actual max for 2d 79 index_model = ((self.qmin <= radius)&(radius<= self.qmax)) 80 self.mask = (index_model)&(self.mask) 81 82 if self.data ==None: 65 83 # Only qmin value will be consider for the detector 66 output = value *index_data 67 else: 68 # The user can define qmin and qmax for the detector 69 output = index_model*value 70 84 self.mask = index_data 85 86 value = self.model.evalDistribution([self.qx_data[self.mask],self.qy_data[self.mask]] ) 87 88 output = numpy.zeros(len(self.mask)) 89 output[self.mask] = value 90 71 91 elapsed = time.time()-self.starttime 72 92 self.complete( image = output, … … 75 95 elapsed = elapsed, 76 96 qmin = self.qmin, 77 qmax = self.qmax,97 qmax = self.qmax, 78 98 qstep = self.qstep ) 79 99
Note: See TracChangeset
for help on using the changeset viewer.