Changeset 109e60ab in sasview
- Timestamp:
- Oct 21, 2008 3:47:16 PM (16 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:
- 5cab7d3
- Parents:
- 5893cdb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
rf2817bb r109e60ab 173 173 Data can be initital with a data (sans plottable) 174 174 or with vectors. 175 """ 175 176 self.smearer is an object of class QSmearer or SlitSmearer 177 that will smear the theory data (slit smearing or resolution 178 smearing) when set. 179 180 The proper way to set the smearing object would be to 181 do the following: 182 183 from DataLoader.qsmearing import smear_selection 184 fitdata1d = FitData1D(some_data) 185 fitdata1d.smearer = smear_selection(some_data) 186 187 Note that some_data _HAS_ to be of class DataLoader.data_info.Data1D 188 189 Setting it back to None will turn smearing off. 190 191 """ 192 ## Smearing object 193 self.smearer = None 194 195 # Initialize from Data1D object 176 196 self.data=sans_data1d 177 197 self.x= sans_data1d.x … … 179 199 self.dx= sans_data1d.dx 180 200 self.dy= sans_data1d.dy 201 202 ## Min Q-value 181 203 self.qmin=None 204 ## Max Q-value 182 205 self.qmax=None 183 206 … … 197 220 198 221 def residuals(self, fn): 222 """ 223 Compute residuals. 224 225 If self.smearer has been set, use if to smear 226 the data before computing chi squared. 227 228 @param fn: function that return model value 229 @return residuals 230 """ 231 x,y,dy = [numpy.asarray(v) for v in (self.x,self.y,self.dy)] 232 233 # Find entries to consider 234 if self.qmin==None and self.qmax==None: 235 idx = Ellipsis 236 else: 237 idx = (x>=self.qmin) & (x <= self.qmax) 238 239 # Compute theory data f(x) 240 fx = numpy.zeros(len(x)) 241 fx[idx] = numpy.asarray([fn(v) for v in x[idx]]) 242 243 # Smear theory data 244 if self.smearer is not None: 245 fx = self.smearer(fx) 246 247 # Sanity check 248 if numpy.size(dy) < numpy.size(x): 249 raise RuntimeError, "FitData1D: invalid error array" 250 251 return (y[idx] - fx[idx])/dy[idx] 252 253 def residuals_old(self, fn): 199 254 """ @param fn: function that return model value 200 255 @return residuals … … 333 388 during fitting 334 389 """ 390 #TODO: we have to refactor the way we handle data. 391 # We should move away from plottables and move towards the Data1D objects 392 # defined in DataLoader. Data1D allows data manipulations, which should be 393 # used to concatenate. 394 # In the meantime we should switch off the concatenation. 395 #if len(listdata)>1: 396 # raise RuntimeError, "FitEngine._concatenateData: Multiple data files is not currently supported" 397 #return listdata[0] 398 335 399 if listdata==[]: 336 400 raise ValueError, " data list missing"
Note: See TracChangeset
for help on using the changeset viewer.