Changes in src/sas/sasgui/guiframe/dataFitting.py [9b6d62d:7988501] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/dataFitting.py
r9b6d62d r7988501 17 17 """ 18 18 """ 19 def __init__(self, x=None, y=None, dx=None, dy=None ):19 def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None): 20 20 """ 21 21 """ … … 24 24 if y is None: 25 25 y = [] 26 PlotData1D.__init__(self, x, y, dx, dy)27 LoadData1D.__init__(self, x, y, dx, dy)26 PlotData1D.__init__(self, x, y, lam, dx, dy, dlam) 27 LoadData1D.__init__(self, x, y, lam, dx, dy, dlam) 28 28 self.id = None 29 29 self.list_group_id = [] … … 68 68 # First, check the data compatibility 69 69 dy, dy_other = self._validity_check(other) 70 result = Data1D(x=[], y=[], dx=None, dy=None)70 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 71 71 result.clone_without_data(length=len(self.x), clone=self) 72 72 result.copy_from_datainfo(data1d=self) … … 115 115 # First, check the data compatibility 116 116 self._validity_check_union(other) 117 result = Data1D(x=[], y=[], dx=None, dy=None)117 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 118 118 tot_length = len(self.x) + len(other.x) 119 119 result = self.clone_without_data(length=tot_length, clone=result) 120 if self.dlam == None or other.dlam is None: 121 result.dlam = None 122 else: 123 result.dlam = numpy.zeros(tot_length) 120 124 if self.dy == None or other.dy is None: 121 125 result.dy = None … … 141 145 result.y = numpy.append(self.y, other.y) 142 146 result.y = result.y[ind] 147 result.lam = numpy.append(self.lam, other.lam) 148 result.lam = result.lam[ind] 149 if result.dlam != None: 150 result.dlam = numpy.append(self.dlam, other.dlam) 151 result.dlam = result.dlam[ind] 143 152 if result.dy != None: 144 153 result.dy = numpy.append(self.dy, other.dy) … … 260 269 # First, check the data compatibility 261 270 self._validity_check_union(other) 262 result = Data1D(x=[], y=[], dx=None, dy=None)271 result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[]) 263 272 tot_length = len(self.x)+len(other.x) 264 273 result.clone_without_data(length=tot_length, clone=self) 274 if self.dlam == None or other.dlam is None: 275 result.dlam = None 276 else: 277 result.dlam = numpy.zeros(tot_length) 265 278 if self.dy == None or other.dy is None: 266 279 result.dy = None … … 285 298 result.y = numpy.append(self.y, other.y) 286 299 result.y = result.y[ind] 300 result.lam = numpy.append(self.lam, other.lam) 301 result.lam = result.lam[ind] 287 302 if result.dy != None: 288 303 result.dy = numpy.append(self.dy, other.dy) … … 363 378 _str = "%s\n" % LoadData2D.__str__(self) 364 379 return _str 365 380 381 def _validity_check(self, other): 382 """ 383 Checks that the data lengths are compatible. 384 Checks that the x vectors are compatible. 385 Returns errors vectors equal to original 386 errors vectors if they were present or vectors 387 of zeros when none was found. 388 389 :param other: other data set for operation 390 391 :return: dy for self, dy for other [numpy arrays] 392 393 :raise ValueError: when lengths are not compatible 394 395 """ 396 err_other = None 397 if isinstance(other, Data2D): 398 # Check that data lengths are the same 399 if len(self.data) != len(other.data) or \ 400 len(self.qx_data) != len(other.qx_data) or \ 401 len(self.qy_data) != len(other.qy_data): 402 msg = "Unable to perform operation: data length are not equal" 403 raise ValueError, msg 404 #if len(self.data) < 1: 405 # msg = "Incompatible data sets: I-values do not match" 406 # raise ValueError, msg 407 for ind in range(len(self.data)): 408 if self.qx_data[ind] != other.qx_data[ind]: 409 msg = "Incompatible data sets: qx-values do not match" 410 raise ValueError, msg 411 if self.qy_data[ind] != other.qy_data[ind]: 412 msg = "Incompatible data sets: qy-values do not match" 413 raise ValueError, msg 414 415 # Check that the scales match 416 err_other = other.err_data 417 if other.err_data == None or \ 418 (len(other.err_data) != len(other.data)): 419 err_other = numpy.zeros(len(other.data)) 420 421 # Check that we have errors, otherwise create zero vector 422 err = self.err_data 423 if self.err_data == None or \ 424 (len(self.err_data) != len(self.data)): 425 err = numpy.zeros(len(other.data)) 426 427 return err, err_other 428 429 def _validity_check_union(self, other): 430 """ 431 Checks that the data lengths are compatible. 432 Checks that the x vectors are compatible. 433 Returns errors vectors equal to original 434 errors vectors if they were present or vectors 435 of zeros when none was found. 436 437 :param other: other data set for operation 438 439 :return: bool 440 441 :raise ValueError: when data types are not compatible 442 443 """ 444 if not isinstance(other, Data2D): 445 msg = "Unable to perform operation: different types of data set" 446 raise ValueError, msg 447 return True 448 366 449 def _perform_operation(self, other, operation): 367 450 """
Note: See TracChangeset
for help on using the changeset viewer.