Changeset b39c817 in sasview for DataLoader/data_info.py
- Timestamp:
- Aug 4, 2008 10:39:43 AM (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:
- ccb560a
- Parents:
- cfe97ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/data_info.py
r9198b83 rb39c817 18 18 copyright 2008, University of Tennessee 19 19 """ 20 21 #TODO: Keep track of data manipulation in the 'process' data structure. 20 22 21 23 from sans.guitools.plottables import Data1D as plottable_1D … … 71 73 ## Sample to detector distance [float] [mm] 72 74 distance = None 73 distance_unit = 'm '75 distance_unit = 'mm' 74 76 ## Offset of this detector position in X, Y, (and Z if necessary) [Vector] [mm] 75 77 offset = Vector() 76 offset_unit = 'm m'78 offset_unit = 'm' 77 79 ## Orientation (rotation) of this detector in roll, pitch, and yaw [Vector] [degrees] 78 80 orientation = Vector() … … 280 282 errors = [] 281 283 284 # Private method to perform operation. Not implemented for DataInfo, 285 # but should be implemented for each data class inherited from DataInfo 286 # that holds actual data (ex.: Data1D) 287 def _perform_operation(self, other, operation): return NotImplemented 288 289 def __add__(self, other): 290 """ 291 Add two data sets 292 293 @param other: data set to add to the current one 294 @return: new data set 295 @raise ValueError: raised when two data sets are incompatible 296 """ 297 def operation(a, b): return a+b 298 return self._perform_operation(other, operation) 299 300 def __radd__(self, other): 301 """ 302 Add two data sets 303 304 @param other: data set to add to the current one 305 @return: new data set 306 @raise ValueError: raised when two data sets are incompatible 307 """ 308 def operation(a, b): return b+a 309 return self._perform_operation(other, operation) 310 311 def __sub__(self, other): 312 """ 313 Subtract two data sets 314 315 @param other: data set to subtract from the current one 316 @return: new data set 317 @raise ValueError: raised when two data sets are incompatible 318 """ 319 def operation(a, b): return a-b 320 return self._perform_operation(other, operation) 321 322 def __rsub__(self, other): 323 """ 324 Subtract two data sets 325 326 @param other: data set to subtract from the current one 327 @return: new data set 328 @raise ValueError: raised when two data sets are incompatible 329 """ 330 def operation(a, b): return b-a 331 return self._perform_operation(other, operation) 332 333 def __mul__(self, other): 334 """ 335 Multiply two data sets 336 337 @param other: data set to subtract from the current one 338 @return: new data set 339 @raise ValueError: raised when two data sets are incompatible 340 """ 341 def operation(a, b): return a*b 342 return self._perform_operation(other, operation) 343 344 def __rmul__(self, other): 345 """ 346 Multiply two data sets 347 348 @param other: data set to subtract from the current one 349 @return: new data set 350 @raise ValueError: raised when two data sets are incompatible 351 """ 352 def operation(a, b): return b*a 353 return self._perform_operation(other, operation) 354 355 def __div__(self, other): 356 """ 357 Divided a data set by another 358 359 @param other: data set that the current one is divided by 360 @return: new data set 361 @raise ValueError: raised when two data sets are incompatible 362 """ 363 def operation(a, b): return a/b 364 return self._perform_operation(other, operation) 365 366 def __rdiv__(self, other): 367 """ 368 Divided a data set by another 369 370 @param other: data set that the current one is divided by 371 @return: new data set 372 @raise ValueError: raised when two data sets are incompatible 373 """ 374 def operation(a, b): return b/a 375 return self._perform_operation(other, operation) 376 282 377 class Data1D(plottable_1D, DataInfo): 283 378 """ … … 309 404 _str += "%s\n" % str(item) 310 405 311 312 406 _str += "Data:\n" 313 407 _str += " Type: %s\n" % self.__class__.__name__ … … 319 413 320 414 def clone_without_data(self, length=0): 415 """ 416 Clone the current object, without copying the data (which 417 will be filled out by a subsequent operation). 418 The data arrays will be initialized to zero. 419 420 @param length: length of the data array to be initialized 421 """ 321 422 from copy import deepcopy 322 423 … … 401 502 return result 402 503 403 404 def __add__(self, other):405 """406 Add two data sets407 408 @param other: data set to add to the current one409 @return: new data set410 @raise ValueError: raised when two data sets are incompatible411 """412 def operation(a, b): return a+b413 return self._perform_operation(other, operation)414 415 def __radd__(self, other):416 """417 Add two data sets418 419 @param other: data set to add to the current one420 @return: new data set421 @raise ValueError: raised when two data sets are incompatible422 """423 def operation(a, b): return b+a424 return self._perform_operation(other, operation)425 426 def __sub__(self, other):427 """428 Subtract two data sets429 430 @param other: data set to subtract from the current one431 @return: new data set432 @raise ValueError: raised when two data sets are incompatible433 """434 def operation(a, b): return a-b435 return self._perform_operation(other, operation)436 437 def __rsub__(self, other):438 """439 Subtract two data sets440 441 @param other: data set to subtract from the current one442 @return: new data set443 @raise ValueError: raised when two data sets are incompatible444 """445 def operation(a, b): return b-a446 return self._perform_operation(other, operation)447 448 def __mul__(self, other):449 """450 Multiply two data sets451 452 @param other: data set to subtract from the current one453 @return: new data set454 @raise ValueError: raised when two data sets are incompatible455 """456 def operation(a, b): return a*b457 return self._perform_operation(other, operation)458 459 def __rmul__(self, other):460 """461 Multiply two data sets462 463 @param other: data set to subtract from the current one464 @return: new data set465 @raise ValueError: raised when two data sets are incompatible466 """467 def operation(a, b): return b*a468 return self._perform_operation(other, operation)469 470 def __div__(self, other):471 """472 Divided a data set by another473 474 @param other: data set that the current one is divided by475 @return: new data set476 @raise ValueError: raised when two data sets are incompatible477 """478 def operation(a, b): return a/b479 return self._perform_operation(other, operation)480 481 def __rdiv__(self, other):482 """483 Divided a data set by another484 485 @param other: data set that the current one is divided by486 @return: new data set487 @raise ValueError: raised when two data sets are incompatible488 """489 def operation(a, b): return b/a490 return self._perform_operation(other, operation)491 492 493
Note: See TracChangeset
for help on using the changeset viewer.