Changeset 0b79323 in sasview for src/sas/sascalc/dataloader/readers
- Timestamp:
- Jul 27, 2017 7:11:42 AM (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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 9d786e5
- Parents:
- 7477fb9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r7477fb9 r0b79323 236 236 self.parent_class = tagname_original 237 237 if tagname == 'SASdata': 238 self.current_dataset = plottable_1D(np.array(0), np.array(0)) 238 self._initialize_new_data_set(node) 239 if isinstance(self.current_dataset, plottable_2D): 240 x_bins = attr.get("x_bins", "") 241 y_bins = attr.get("y_bins", "") 242 if x_bins is not "" and y_bins is not "": 243 self.current_dataset.shape = (x_bins, y_bins) 244 else: 245 self.current_dataset.shape = () 239 246 # Recurse to access data within the group 240 247 self._parse_entry(node, recurse=True) … … 250 257 self._add_intermediate() 251 258 else: 252 data_point, unit = self._get_node_value(node, tagname) 259 if isinstance(self.current_dataset, plottable_2D): 260 data_point = node.text 261 unit = attr.get('unit', '') 262 else: 263 data_point, unit = self._get_node_value(node, tagname) 253 264 254 265 # If this is a dataset, store the data appropriately … … 260 271 elif tagname == 'SASnote': 261 272 self.current_datainfo.notes.append(data_point) 262 elif tagname == 'I': # I and Q points 273 274 # I and Q points 275 elif tagname == 'I' and isinstance(self.current_dataset, plottable_1D): 263 276 unit_list = unit.split("|") 264 277 if len(unit_list) > 1: … … 268 281 self.current_dataset.yaxis("Intensity", unit) 269 282 self.current_dataset.y = np.append(self.current_dataset.y, data_point) 270 elif tagname == 'Idev' :283 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_1D): 271 284 self.current_dataset.dy = np.append(self.current_dataset.dy, data_point) 272 285 elif tagname == 'Q': … … 294 307 elif tagname == 'zacceptance': 295 308 self.current_datainfo.sample.zacceptance = (data_point, unit) 309 310 # I and Qx, Qy - 2D data 311 elif tagname == 'I' and isinstance(self.current_dataset, plottable_2D): 312 self.current_dataset.yaxis("Intensity", unit) 313 self.current_dataset.data = np.fromstring(data_point, dtype=float, sep=",") 314 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_2D): 315 self.current_dataset.err_data = np.fromstring(data_point, dtype=float, sep=",") 316 elif tagname == 'Qx': 317 self.current_dataset.xaxis("Qx", unit) 318 self.current_dataset.qx_data = np.fromstring(data_point, dtype=float, sep=",") 319 elif tagname == 'Qy': 320 self.current_dataset.yaxis("Qy", unit) 321 self.current_dataset.qy_data = np.fromstring(data_point, dtype=float, sep=",") 322 elif tagname == 'Qxdev': 323 self.current_dataset.xaxis("Qxdev", unit) 324 self.current_dataset.dqx_data = np.fromstring(data_point, dtype=float, sep=",") 325 elif tagname == 'Qydev': 326 self.current_dataset.yaxis("Qydev", unit) 327 self.current_dataset.dqy_data = np.fromstring(data_point, dtype=float, sep=",") 328 elif tagname == 'Mask': 329 inter = [item == "1" for item in data_point.split(",")] 330 self.current_dataset.mask = np.asarray(inter, dtype=bool) 296 331 297 332 # Sample Information … … 647 682 np.zeros([array_size])) 648 683 684 def _initialize_new_data_set(self, node=None): 685 if node is not None: 686 for child in node: 687 if child.tag.replace(self.base_ns, "") == "Idata": 688 for i_child in child: 689 if i_child.tag.replace(self.base_ns, "") == "Qx": 690 self.current_dataset = plottable_2D() 691 return 692 self.current_dataset = plottable_1D(np.array(0), np.array(0)) 693 694 ## Writing Methods 649 695 def write(self, filename, datainfo): 650 696 """
Note: See TracChangeset
for help on using the changeset viewer.