Changeset b39c817 in sasview for DataLoader/readers
- Timestamp:
- Aug 4, 2008 10:39:43 AM (17 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/readers/cansas_reader.py
r8780e9a rb39c817 22 22 from DataLoader.data_info import Data1D, Collimation, Detector, Process 23 23 from xml import xpath 24 25 has_converter = True 26 try: 27 from data_util.nxsunit import Converter 28 except: 29 has_converter = False 24 30 25 31 def get_node_text(node): … … 87 93 if content is not None: 88 94 try: 89 value = float(content) 95 value = float(content) 90 96 except: 91 97 # Could not pass, skip and return None … … 113 119 value, attr = get_float(location, node) 114 120 if value is not None: 115 exec "storage.%s = value" % variable116 117 121 # If the entry has units, check to see that they are 118 122 # compatible with what we currently have in the data object … … 121 125 exec "local_unit = storage.%s_unit.lower()" % toks[0] 122 126 if attr['unit'].lower()!=local_unit: 123 raise ValueError, "CanSAS reader: unrecognized %s unit [%s]; expecting [%s]" \ 124 % (variable, attr['unit'], local_unit) 127 if has_converter==True: 128 try: 129 conv = Converter(attr['unit']) 130 exec "storage.%s = %g" % (variable, conv(value, units=local_unit)) 131 except: 132 raise ValueError, "CanSAS reader: could not convert %s unit [%s]; expecting [%s]\n %s" \ 133 % (variable, attr['unit'], local_unit, sys.exc_value) 134 else: 135 raise ValueError, "CanSAS reader: unrecognized %s unit [%s]; expecting [%s]" \ 136 % (variable, attr['unit'], local_unit) 137 else: 138 exec "storage.%s = value" % variable 139 else: 140 exec "storage.%s = value" % variable 141 125 142 126 143 def _store_content(location, node, variable, storage):
Note: See TracChangeset
for help on using the changeset viewer.