Changeset 5c5e7fd in sasview
- Timestamp:
- Sep 22, 2017 7:06:16 PM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- af3e9f5
- Parents:
- a5bd87a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
rcd57c7d4 r5c5e7fd 16 16 from sas.sascalc.dataloader.file_reader_base_class import FileReader 17 17 18 def decode(s): 19 return s.decode() if isinstance(s, bytes) else s 20 21 def h5attr(node, key, default=None): 22 return decode(node.attrs.get(key, default)) 18 23 19 24 class Reader(FileReader): … … 130 135 # Get all information for the current key 131 136 value = data.get(key) 132 if value.attrs.get(u'canSAS_class') is not None: 133 class_name = value.attrs.get(u'canSAS_class') 134 else: 135 class_name = value.attrs.get(u'NX_class') 137 classname = h5attr(value, u'canSAS_class') 138 if classname is None: 139 class_name = h5attr(value, u'NX_class') 136 140 if class_name is not None: 137 141 class_prog = re.compile(class_name) … … 225 229 226 230 for data_point in data_set: 231 if data_point.dtype.char == 'S': 232 data_point = decode(bytes(data_point)) 227 233 # Top Level Meta Data 228 234 if key == u'definition': … … 231 237 self.current_datainfo.run.append(data_point) 232 238 try: 233 run_name = value.attrs['name']239 run_name = h5attr(value, 'name') 234 240 run_dict = {data_point: run_name} 235 241 self.current_datainfo.run_name = run_dict … … 576 582 :return: unit for the value passed to the method 577 583 """ 578 unit = value.attrs.get(u'units')584 unit = h5attr(value, u'units') 579 585 if unit is None: 580 unit = value.attrs.get(u'unit')586 unit = h5attr(value, u'unit') 581 587 # Convert the unit formats 582 588 if unit == "1/A":
Note: See TracChangeset
for help on using the changeset viewer.