Changeset 7182d96 in sasview
- Timestamp:
- Jun 8, 2010 2:54:45 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:
- 76f2d63
- Parents:
- fca90f82
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Invariant/invariant.py
ra45622a r7182d96 361 361 self._background = background 362 362 self._scale = scale 363 363 # slit height for smeared data 364 self._smeared = None 364 365 # The data should be private 365 366 self._data = self._get_data(data) 367 # get the dxl if the data is smeared: This is done only once on init. 368 if data.dxl != None and data.dxl.all() >0: 369 # assumes constant dxl 370 self._smeared = data.dxl[0] 366 371 367 372 # Since there are multiple variants of Q*, you should force the … … 407 412 (min(new_data.dy)==0 and max(new_data.dy)==0): 408 413 new_data.dy = numpy.ones(len(new_data.x)) 409 410 414 return new_data 411 415 … … 438 442 439 443 q_star = x0**2 *y0 *dx0 +x1**2 *y1 *dx1 440 + ..+ xn**2 *yn *dxn 444 + ..+ xn**2 *yn *dxn for non smeared data 445 446 q_star = dxl0 *x0 *y0 *dx0 +dxl1 *x1 *y1 *dx1 447 + ..+ dlxn *xn *yn *dxn for smeared data 441 448 442 449 where n >= len(data.x)-1 450 dxl = slit height dQl 443 451 dxi = 1/2*(xi+1 - xi) + (xi - xi-1) 444 452 dx0 = (x1 - x0)/2 … … 454 462 raise ValueError, msg 455 463 else: 464 # Take care of smeared data 465 if self._smeared is None: 466 gx = data.x * data.x 467 # assumes that len(x) == len(dxl). 468 else: 469 gx = data.dxl * data.x 470 456 471 n = len(data.x)- 1 457 472 #compute the first delta q … … 460 475 dxn = (data.x[n] - data.x[n-1])/2 461 476 sum = 0 462 sum += data.x[0] * data.x[0] * data.y[0] * dx0463 sum += data.x[n] * data.x[n] * data.y[n] * dxn477 sum += gx[0] * data.y[0] * dx0 478 sum += gx[n] * data.y[n] * dxn 464 479 465 480 if len(data.x) == 2: … … 469 484 for i in xrange(1, n-1): 470 485 dxi = (data.x[i+1] - data.x[i-1])/2 471 sum += data.x[i] * data.x[i] * data.y[i] * dxi486 sum += gx[i] * data.y[i] * dxi 472 487 return sum 473 488 … … 501 516 else: 502 517 dy = data.dy 503 518 # Take care of smeared data 519 if self._smeared is None: 520 gx = data.x * data.x 521 # assumes that len(x) == len(dxl). 522 else: 523 gx = data.dxl * data.x 524 504 525 n = len(data.x) - 1 505 526 #compute the first delta … … 508 529 dxn= (data.x[n] - data.x[n-1])/2 509 530 sum = 0 510 sum += ( data.x[0] * data.x[0] * dy[0] * dx0)**2511 sum += ( data.x[n] * data.x[n] * dy[n] * dxn)**2531 sum += (gx[0] * dy[0] * dx0)**2 532 sum += (gx[n] * dy[n] * dxn)**2 512 533 if len(data.x) == 2: 513 534 return math.sqrt(sum) … … 516 537 for i in xrange(1, n-1): 517 538 dxi = (data.x[i+1] - data.x[i-1])/2 518 sum += ( data.x[i] * data.x[i] * dy[i] * dxi)**2539 sum += (gx[i] * dy[i] * dxi)**2 519 540 return math.sqrt(sum) 520 541 … … 533 554 534 555 result_data = LoaderData1D(x=q, y=iq, dy=diq) 556 if self._smeared != None: 557 result_data.dxl = self._smeared * numpy.ones(len(q)) 535 558 return result_data 536 559
Note: See TracChangeset
for help on using the changeset viewer.