Changeset 1905128 in sasview
- Timestamp:
- Jan 12, 2017 1:17:10 PM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 18b7ca96
- Parents:
- af08e55
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
raf08e55 r1905128 244 244 self.add_intermediate() 245 245 else: 246 data_point, unit = self._get_node_value(node, tagname) 246 if isinstance(self.current_dataset, plottable_2D): 247 data_point = node.text 248 unit = attr.get('unit', '') 249 else: 250 data_point, unit = self._get_node_value(node, tagname) 247 251 248 252 # If this is a dataset, store the data appropriately … … 274 278 elif tagname == 'Shadowfactor': 275 279 pass 280 276 281 # I and Qx, Qy - 2D data 277 282 elif tagname == 'I' and isinstance(self.current_dataset, plottable_2D): 278 283 self.current_dataset.yaxis("Intensity", unit) 279 self.current_dataset.data = np. append(self.current_dataset.data, data_point)284 self.current_dataset.data = np.fromstring(data_point, dtype=float, sep=",") 280 285 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_2D): 281 self.current_dataset.err_data = np. append(self.current_dataset.err_data, data_point)286 self.current_dataset.err_data = np.fromstring(data_point, dtype=float, sep=",") 282 287 elif tagname == 'Qx': 283 288 self.current_dataset.xaxis("Qx", unit) 284 self.current_dataset.qx_data = np. append(self.current_dataset.qx_data, data_point)289 self.current_dataset.qx_data = np.fromstring(data_point, dtype=float, sep=",") 285 290 elif tagname == 'Qy': 286 291 self.current_dataset.yaxis("Qy", unit) 287 self.current_dataset.qy_data = np. append(self.current_dataset.qy_data, data_point)292 self.current_dataset.qy_data = np.fromstring(data_point, dtype=float, sep=",") 288 293 elif tagname == 'Qxdev': 289 294 self.current_dataset.xaxis("Qxdev", unit) 290 self.current_dataset.dqx_data = np. append(self.current_dataset.dqx_data, data_point)295 self.current_dataset.dqx_data = np.fromstring(data_point, dtype=float, sep=",") 291 296 elif tagname == 'Qydev': 292 297 self.current_dataset.yaxis("Qydev", unit) 293 self.current_dataset.dqy_data = np. append(self.current_dataset.dqy_data, data_point)298 self.current_dataset.dqy_data = np.fromstring(data_point, dtype=float, sep=",") 294 299 elif tagname == 'Mask': 295 self.current_dataset.mask = np.append(self.current_dataset.mask, bool(data_point)) 300 inter = data_point.split(",") 301 self.current_dataset.mask = np.asarray(inter, dtype=bool) 296 302 297 303 # Sample Information … … 624 630 np.trim_zeros(dataset.dy) 625 631 elif isinstance(dataset, plottable_2D): 626 dataset.data = np.delete(dataset.data, [0])627 632 dataset.data = dataset.data.astype(np.float64) 628 dataset.qx_data = np.delete(dataset.qx_data, [0])629 633 dataset.qx_data = dataset.qx_data.astype(np.float64) 630 634 dataset.xmin = np.min(dataset.qx_data) 631 635 dataset.xmax = np.max(dataset.qx_data) 632 dataset.qy_data = np.delete(dataset.qy_data, [0])633 636 dataset.qy_data = dataset.qy_data.astype(np.float64) 634 637 dataset.ymin = np.min(dataset.qy_data) … … 637 640 + dataset.qy_data * dataset.qy_data) 638 641 if dataset.err_data is not None: 639 dataset.err_data = np.delete(dataset.err_data, [0])640 642 dataset.err_data = dataset.err_data.astype(np.float64) 641 643 if dataset.dqx_data is not None: 642 dataset.dqx_data = np.delete(dataset.dqx_data, [0])643 644 dataset.dqx_data = dataset.dqx_data.astype(np.float64) 644 645 if dataset.dqy_data is not None: 645 dataset.dqy_data = np.delete(dataset.dqy_data, [0])646 646 dataset.dqy_data = dataset.dqy_data.astype(np.float64) 647 647 if dataset.mask is not None: 648 dataset.mask = np.delete(dataset.mask, [0])649 648 dataset.mask = dataset.mask.astype(dtype=bool) 650 649 … … 1045 1044 :param entry_node: lxml node ElementTree object to be appended to 1046 1045 """ 1047 node = self.create_element("SASdata")1048 1046 attr = {} 1049 1047 if datainfo.data.shape: 1050 attr["x_bins"] = len(datainfo.x_bins) 1051 attr["y_bins"] = len(datainfo.y_bins) 1048 attr["x_bins"] = str(len(datainfo.x_bins)) 1049 attr["y_bins"] = str(len(datainfo.y_bins)) 1050 node = self.create_element("SASdata", attr) 1052 1051 self.append(node, entry_node) 1053 1052 1054 for i in range(len(datainfo.data)): 1055 point = self.create_element("Idata") 1056 node.append(point) 1057 self.write_node(point, "Qx", datainfo.qx_data[i], 1053 point = self.create_element("Idata") 1054 node.append(point) 1055 qx = ','.join([str(datainfo.qx_data[i]) for i in xrange(len(datainfo.qx_data))]) 1056 qy = ','.join([str(datainfo.qy_data[i]) for i in xrange(len(datainfo.qy_data))]) 1057 intensity = ','.join([str(datainfo.data[i]) for i in xrange(len(datainfo.data))]) 1058 err = ','.join([str(datainfo.err_data[i]) for i in xrange(len(datainfo.err_data))]) 1059 dqy = ','.join([str(datainfo.dqy_data[i]) for i in xrange(len(datainfo.dqy_data))]) 1060 dqx = ','.join([str(datainfo.dqx_data[i]) for i in xrange(len(datainfo.dqx_data))]) 1061 mask = ','.join([str(datainfo.mask[i]) for i in xrange(len(datainfo.mask))]) 1062 1063 self.write_node(point, "Qx", qx, 1064 {'unit': datainfo._xunit}) 1065 self.write_node(point, "Qy", qy, 1066 {'unit': datainfo._yunit}) 1067 self.write_node(point, "I", intensity, 1068 {'unit': datainfo._zunit}) 1069 if datainfo.err_data is not None: 1070 self.write_node(point, "Idev", err, 1071 {'unit': datainfo._zunit}) 1072 if datainfo.dqy_data is not None: 1073 self.write_node(point, "Qydev", dqy, 1074 {'unit': datainfo._yunit}) 1075 if datainfo.dqx_data is not None: 1076 self.write_node(point, "Qxdev", dqx, 1058 1077 {'unit': datainfo._xunit}) 1059 self.write_node(point, "Qy", datainfo.qy_data[i], 1060 {'unit': datainfo._yunit}) 1061 self.write_node(point, "I", datainfo.data[i], 1062 {'unit': datainfo._zunit}) 1063 if datainfo.err_data is not None and len(datainfo.err_data) > i: 1064 self.write_node(point, "Idev", datainfo.err_data[i], 1065 {'unit': datainfo._zunit}) 1066 if datainfo.dqy_data is not None and len(datainfo.dqy_data) > i: 1067 self.write_node(point, "Qydev", datainfo.dqy_data[i], 1068 {'unit': datainfo._yunit}) 1069 if datainfo.dqx_data is not None and len(datainfo.dqx_data) > i: 1070 self.write_node(point, "Qxdev", datainfo.dqx_data[i], 1071 {'unit': datainfo._xunit}) 1072 if datainfo.mask is not None and len(datainfo.mask) > i: 1073 self.write_node(point, "Mask", datainfo.mask[i]) 1078 if datainfo.mask is not None: 1079 self.write_node(point, "Mask", mask) 1074 1080 1075 1081 def _write_trans_spectrum(self, datainfo, entry_node):
Note: See TracChangeset
for help on using the changeset viewer.