Changeset 2651724 in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Aug 17, 2017 4:13:32 PM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- d7fd7be
- Parents:
- 9e0dd49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r9e0dd49 r2651724 97 97 self.logging = [] 98 98 self.output = [] 99 self.q_name = [] 100 self.mask_name = u'' 101 self.i_name = u'' 102 self.i_node = u'' 103 self.q_uncertainties = u'' 104 self.q_resolutions = u'' 105 self.i_uncertainties = u'' 99 106 self.parent_class = u'' 100 107 self.detector = Detector() … … 135 142 self.add_data_set(key) 136 143 elif class_prog.match(u'SASdata'): 144 self._find_data_attributes(value) 137 145 self._initialize_new_data_set(parent_list) 138 self._find_data_attributes(value)139 146 # Recursion step to access data within the group 140 147 self.read_children(value, parent_list) … … 212 219 """ 213 220 # FIXME: check attributes of SASdata for Q, dQ, Mask, etc. 214 if key == u'I':221 if key == self.i_name: 215 222 if isinstance(self.current_dataset, plottable_2D): 216 223 self.current_dataset.data = data_set … … 219 226 self.current_dataset.y = data_set.flatten() 220 227 self.current_dataset.yaxis("Intensity", unit) 221 elif key == u'Idev':228 elif key == self.i_uncertainties: 222 229 if isinstance(self.current_dataset, plottable_2D): 223 230 self.current_dataset.err_data = data_set.flatten() 224 231 else: 225 232 self.current_dataset.dy = data_set.flatten() 226 elif key == u'Q':233 elif key in self.q_name: 227 234 self.current_dataset.xaxis("Q", unit) 228 235 if isinstance(self.current_dataset, plottable_2D): … … 230 237 else: 231 238 self.current_dataset.x = data_set.flatten() 232 elif key == u'Qdev': 233 self.current_dataset.dx = data_set.flatten() 234 elif key == u'dQw': 235 self.current_dataset.dxw = data_set.flatten() 236 elif key == u'dQl': 237 self.current_dataset.dxl = data_set.flatten() 239 elif key in self.q_resolutions: 240 if key == u'dQw': 241 self.current_dataset.dxw = data_set.flatten() 242 elif key == u'dQl': 243 self.current_dataset.dxl = data_set.flatten() 244 else: 245 self.current_dataset.dx = data_set.flatten() 238 246 elif key == u'Qy': 239 247 self.current_dataset.yaxis("Q_y", unit) … … 246 254 elif key == u'Qxdev': 247 255 self.current_dataset.dqx_data = data_set.flatten() 248 elif key == u'Mask':256 elif key == self.mask_name: 249 257 self.current_dataset.mask = data_set.flatten() 250 258 elif key == u'wavelength': … … 553 561 self.current_datainfo = DataInfo() 554 562 555 556 563 def _initialize_new_data_set(self, parent_list=None): 557 564 """ … … 574 581 575 582 def _find_data_attributes(self, value): 583 """ 584 A class to find the indices for Q, the name of the Qdev and Idev, and 585 the name of the mask. 586 :param value: SASdata/NXdata HDF5 Group 587 """ 576 588 attrs = value.attrs 577 589 signal = attrs.get("signal") 578 i_axes = attrs.get("I_axes") 579 q_indices = attrs.get("Q_indices")580 mask = attrs.get("mask")581 mask_indices = attrs.get("Mask_indices")590 591 i_axes = np.array(attrs.get("I_axes").split(",")) 592 q_indices = np.array(attrs.get("Q_indices")) 593 self.mask_name = attrs.get("mask") 582 594 keys = value.keys() 583 self.q_name = i_axes[q_indices]584 self.mask_name = mask[mask_indices]595 for val in q_indices: 596 self.q_name.append(i_axes[val]) 585 597 self.i_name = signal 586 if self.q_name in keys: 587 q_vals = value.get(self.q_name) 588 self.q_uncertainties = q_vals.attrs.get("uncertainties") 589 self.q_resolutions = q_vals.attrs.get("resolutions") 598 self.i_node = value.get(self.i_name) 599 for item in self.q_name: 600 if item in keys: 601 q_vals = value.get(item) 602 self.q_uncertainties = q_vals.attrs.get("uncertainty") 603 self.q_resolutions = q_vals.attrs.get("resolution") 590 604 if self.i_name in keys: 591 605 i_vals = value.get(self.i_name) 592 self.i_uncertainties = i_vals.attrs.get("uncertaint ies")606 self.i_uncertainties = i_vals.attrs.get("uncertainty") 593 607 594 608 def _find_intermediate(self, parent_list, basename=""):
Note: See TracChangeset
for help on using the changeset viewer.