Changeset e390933 in sasview
- Timestamp:
- Sep 2, 2008 2:32:02 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:
- daa56d0
- Parents:
- 1b162dfa
- Location:
- DataLoader
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/cansas_reader.py
r579ba85 re390933 17 17 #TODO: Notes need to be implemented. They can be any XML structure in version 1.0 18 18 # Process notes have the same problem. 19 #TODO: Unit conversion is not complete (temperature units are missing) 19 20 20 21 … … 145 146 if attr.has_key('unit'): 146 147 toks = variable.split('.') 147 exec "local_unit = storage.%s_unit .lower()" % toks[0]148 if attr['unit'].lower()!=local_unit :148 exec "local_unit = storage.%s_unit" % toks[0] 149 if attr['unit'].lower()!=local_unit.lower(): 149 150 if has_converter==True: 150 151 try: … … 462 463 for item in nodes: 463 464 _x, attr = get_float('Q', item) 464 _dx, attr = get_float('Qdev', item)465 _dx, attr_d = get_float('Qdev', item) 465 466 if _dx == None: 466 467 _dx = 0.0 468 467 469 if attr.has_key('unit') and attr['unit'].lower() != data_info.x_unit.lower(): 468 raise ValueError, "CanSAS reader: unrecognized %s unit [%s]; expecting [%s]" \ 469 % (variable, attr['unit'], local_unit) 470 470 if has_converter==True: 471 try: 472 data_conv_q = Converter(attr['unit']) 473 _x = data_conv_q(_x, units=data_info.x_unit) 474 except: 475 raise ValueError, "CanSAS reader: could not convert Q unit [%s]; expecting [%s]\n %s" \ 476 % (attr['unit'], data_info.x_unit, sys.exc_value) 477 else: 478 raise ValueError, "CanSAS reader: unrecognized Q unit [%s]; expecting [%s]" \ 479 % (attr['unit'], data_info.x_unit) 480 if attr_d.has_key('unit') and attr_d['unit'].lower() != data_info.x_unit.lower(): 481 if has_converter==True: 482 try: 483 data_conv_q = Converter(attr_d['unit']) 484 _dx = data_conv_q(_dx, units=data_info.x_unit) 485 except: 486 raise ValueError, "CanSAS reader: could not convert dQ unit [%s]; expecting [%s]\n %s" \ 487 % (attr['unit'], data_info.x_unit, sys.exc_value) 488 else: 489 raise ValueError, "CanSAS reader: unrecognized dQ unit [%s]; expecting [%s]" \ 490 % (attr['unit'], data_info.x_unit) 491 471 492 _y, attr = get_float('I', item) 472 _dy, attr = get_float('Idev', item)493 _dy, attr_d = get_float('Idev', item) 473 494 if _dy == None: 474 495 _dy = 0.0 475 496 if attr.has_key('unit') and attr['unit'].lower() != data_info.y_unit.lower(): 476 raise ValueError, "CanSAS reader: unrecognized %s unit [%s]; expecting [%s]" \ 477 % (variable, attr['unit'], local_unit) 497 if has_converter==True: 498 try: 499 data_conv_i = Converter(attr['unit']) 500 _y = data_conv_i(_y, units=data_info.y_unit) 501 except: 502 raise ValueError, "CanSAS reader: could not convert I(q) unit [%s]; expecting [%s]\n %s" \ 503 % (attr['unit'], data_info.y_unit, sys.exc_value) 504 else: 505 raise ValueError, "CanSAS reader: unrecognized I(q) unit [%s]; expecting [%s]" \ 506 % (attr['unit'], data_info.y_unit) 507 if attr_d.has_key('unit') and attr_d['unit'].lower() != data_info.y_unit.lower(): 508 if has_converter==True: 509 try: 510 data_conv_i = Converter(attr_d['unit']) 511 _dy = data_conv_i(_dy, units=data_info.y_unit) 512 except: 513 raise ValueError, "CanSAS reader: could not convert dI(q) unit [%s]; expecting [%s]\n %s" \ 514 % (attr_d['unit'], data_info.y_unit, sys.exc_value) 515 else: 516 raise ValueError, "CanSAS reader: unrecognized dI(q) unit [%s]; expecting [%s]" \ 517 % (attr_d['unit'], data_info.y_unit) 478 518 479 519 if _x is not None and _y is not None: … … 499 539 data_conv_i = Converter('1/cm') 500 540 # Test it 501 data_conv_i(1.0, output.I_unit) 502 503 541 data_conv_i(1.0, output.I_unit) 542 504 543 if data_conv_q is not None: 505 544 data_info.xaxis("\\rm{Q}", data_info.x_unit) -
DataLoader/test/utest_abs_reader.py
r579ba85 re390933 158 158 self.assertEqual(self.data.dy[0], 3) 159 159 self.assertEqual(self.data.x[1], 0.03) 160 self.assert Equal(self.data.y[1], 1001)160 self.assertAlmostEquals(self.data.y[1], 1001.0) 161 161 self.assertEqual(self.data.dx[1], 0.02) 162 162 self.assertEqual(self.data.dy[1], 4) … … 294 294 self._checkdata() 295 295 296 296 def test_units(self): 297 """ 298 Check units. 299 Note that not all units are available. 300 """ 301 filename = "cansas1d_units.xml" 302 self.data = Loader().load(filename) 303 self.assertEqual(self.data.filename, filename) 304 self._checkdata() 297 305 298 306
Note: See TracChangeset
for help on using the changeset viewer.