Changeset d00f8ff in sasview for DataLoader
- Timestamp:
- Oct 1, 2008 10:54:19 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:
- cfbe9b5
- Parents:
- 57f3320
- Location:
- DataLoader
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/data_info.py
r442f42f rd00f8ff 36 36 Data1D is a place holder for 1D plottables. 37 37 """ 38 # The presence of these should be mutually exclusive with the presence of Qdev (dx) 38 39 x = None 39 40 y = None 40 41 dx = None 41 42 dy = None 43 ## Slit smearing length 44 dxl = None 45 ## Slit smearing width 46 dxw = None 42 47 43 48 # Units … … 47 52 _yunit = '' 48 53 49 def __init__(self,x,y,dx=None,dy=None ):54 def __init__(self,x,y,dx=None,dy=None,dxl=None,dxw=None): 50 55 self.x = x 51 56 self.y = y 52 57 self.dx = dx 53 58 self.dy = dy 59 self.dxl = dxl 60 self.dxw = dxw 54 61 55 62 def xaxis(self, label, unit): -
DataLoader/readers/cansas_reader.py
re390933 rd00f8ff 460 460 dx = numpy.zeros(0) 461 461 dy = numpy.zeros(0) 462 dxw = numpy.zeros(0) 463 dxl = numpy.zeros(0) 462 464 463 465 for item in nodes: 464 466 _x, attr = get_float('Q', item) 465 467 _dx, attr_d = get_float('Qdev', item) 468 _dxl, attr_l = get_float('dQl', item) 469 _dxw, attr_w = get_float('dQw', item) 466 470 if _dx == None: 467 471 _dx = 0.0 472 if _dxl == None: 473 _dxl = 0.0 474 if _dxw == None: 475 _dxw = 0.0 468 476 469 477 if attr.has_key('unit') and attr['unit'].lower() != data_info.x_unit.lower(): … … 478 486 raise ValueError, "CanSAS reader: unrecognized Q unit [%s]; expecting [%s]" \ 479 487 % (attr['unit'], data_info.x_unit) 488 # Error in Q 480 489 if attr_d.has_key('unit') and attr_d['unit'].lower() != data_info.x_unit.lower(): 481 490 if has_converter==True: … … 488 497 else: 489 498 raise ValueError, "CanSAS reader: unrecognized dQ unit [%s]; expecting [%s]" \ 499 % (attr['unit'], data_info.x_unit) 500 # Slit length 501 if attr_l.has_key('unit') and attr_l['unit'].lower() != data_info.x_unit.lower(): 502 if has_converter==True: 503 try: 504 data_conv_q = Converter(attr_l['unit']) 505 _dxl = data_conv_q(_dxl, units=data_info.x_unit) 506 except: 507 raise ValueError, "CanSAS reader: could not convert dQl unit [%s]; expecting [%s]\n %s" \ 508 % (attr['unit'], data_info.x_unit, sys.exc_value) 509 else: 510 raise ValueError, "CanSAS reader: unrecognized dQl unit [%s]; expecting [%s]" \ 511 % (attr['unit'], data_info.x_unit) 512 # Slit width 513 if attr_w.has_key('unit') and attr_w['unit'].lower() != data_info.x_unit.lower(): 514 if has_converter==True: 515 try: 516 data_conv_q = Converter(attr_w['unit']) 517 _dxw = data_conv_q(_dxw, units=data_info.x_unit) 518 except: 519 raise ValueError, "CanSAS reader: could not convert dQw unit [%s]; expecting [%s]\n %s" \ 520 % (attr['unit'], data_info.x_unit, sys.exc_value) 521 else: 522 raise ValueError, "CanSAS reader: unrecognized dQw unit [%s]; expecting [%s]" \ 490 523 % (attr['unit'], data_info.x_unit) 491 524 … … 522 555 dx = numpy.append(dx, _dx) 523 556 dy = numpy.append(dy, _dy) 557 dxl = numpy.append(dxl, _dxl) 558 dxw = numpy.append(dxw, _dxw) 559 524 560 525 561 data_info.x = x … … 527 563 data_info.dx = dx 528 564 data_info.dy = dy 565 data_info.dxl = dxl 566 data_info.dxw = dxw 529 567 530 568 data_conv_q = None -
DataLoader/test/utest_abs_reader.py
r76e2369 rd00f8ff 326 326 327 327 328 328 def test_slits(self): 329 """ 330 Check slit data 331 """ 332 filename = "cansas1d_slit.xml" 333 self.data = Loader().load(filename) 334 self.assertEqual(self.data.filename, filename) 335 self.assertEqual(self.data.run[0], "1234") 336 337 # Data 338 self.assertEqual(len(self.data.x), 2) 339 self.assertEqual(self.data.x_unit, '1/A') 340 self.assertEqual(self.data.y_unit, '1/cm') 341 self.assertEqual(self.data.x[0], 0.02) 342 self.assertEqual(self.data.y[0], 1000) 343 self.assertEqual(self.data.dxl[0], 0.005) 344 self.assertEqual(self.data.dxw[0], 0.001) 345 self.assertEqual(self.data.dy[0], 3) 346 self.assertEqual(self.data.x[1], 0.03) 347 self.assertAlmostEquals(self.data.y[1], 1001.0) 348 self.assertEqual(self.data.dx[1], 0.0) 349 self.assertEqual(self.data.dxl[1], 0.005) 350 self.assertEqual(self.data.dxw[1], 0.001) 351 self.assertEqual(self.data.dy[1], 4) 352 self.assertEqual(self.data.run_name['1234'], 'run name') 353 self.assertEqual(self.data.title, "Test title") 354 329 355 330 356
Note: See TracChangeset
for help on using the changeset viewer.