Changeset 3d6c010 in sasview for src/sas/sascalc/dataloader/readers/cansas_reader.py
- Timestamp:
- Apr 5, 2017 5:40:56 AM (8 years ago)
- Children:
- a2573fc
- Parents:
- d619341 (diff), a2e980b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r3beacab4 r3d6c010 245 245 self.add_intermediate() 246 246 else: 247 # I and Q - 1D data 248 if tagname == 'I' and isinstance(self.current_dataset, 249 plottable_1D): 250 self.current_dataset.yaxis("Intensity", unit) 251 data_list = node.text.split(',') 252 for item in data_list: 253 data_point, unit = self._get_node_value_from_text(node, 254 item) 255 self.current_dataset.y = np.append( 256 self.current_dataset.y, data_point) 257 elif tagname == 'Idev' and isinstance(self.current_dataset, 258 plottable_1D): 259 data_list = node.text.split(',') 260 for item in data_list: 261 data_point, unit = self._get_node_value_from_text(node, 262 item) 263 self.current_dataset.dy = np.append( 264 self.current_dataset.dy, data_point) 265 elif tagname == 'Q': 266 data_list = node.text.split(',') 267 for item in data_list: 268 data_point, unit = self._get_node_value_from_text(node, 269 item) 270 self.current_dataset.x = np.append( 271 self.current_dataset.x, data_point) 272 elif tagname == 'Qdev': 273 data_list = node.text.split(',') 274 for item in data_list: 275 data_point, unit = self._get_node_value_from_text(node, 276 item) 277 self.current_dataset.dx = np.append( 278 self.current_dataset.dx, data_point) 279 elif tagname == 'dQw': 280 data_list = node.text.split(',') 281 for item in data_list: 282 data_point, unit = self._get_node_value_from_text(node, 283 item) 284 self.current_dataset.dqw = np.append( 285 self.current_dataset.dqw, data_point) 286 elif tagname == 'dQl': 287 data_list = node.text.split(',') 288 for item in data_list: 289 data_point, unit = self._get_node_value_from_text(node, 290 item) 291 self.current_dataset.dxl = np.append( 292 self.current_dataset.dxl, data_point) 293 elif tagname == 'Qmean': 294 pass 295 elif tagname == 'Shadowfactor': 296 pass 297 elif isinstance(self.current_dataset, plottable_2D): 247 if isinstance(self.current_dataset, plottable_2D): 298 248 data_point = node.text 299 249 unit = attr.get('unit', '') … … 309 259 elif tagname == 'SASnote': 310 260 self.current_datainfo.notes.append(data_point) 261 262 # I and Q - 1D data 263 elif tagname == 'I' and isinstance(self.current_dataset, plottable_1D): 264 unit_list = unit.split("|") 265 if len(unit_list) > 1: 266 self.current_dataset.yaxis(unit_list[0].strip(), 267 unit_list[1].strip()) 268 else: 269 self.current_dataset.yaxis("Intensity", unit) 270 self.current_dataset.y = np.append(self.current_dataset.y, data_point) 271 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_1D): 272 self.current_dataset.dy = np.append(self.current_dataset.dy, data_point) 273 elif tagname == 'Q': 274 unit_list = unit.split("|") 275 if len(unit_list) > 1: 276 self.current_dataset.xaxis(unit_list[0].strip(), 277 unit_list[1].strip()) 278 else: 279 self.current_dataset.xaxis("Q", unit) 280 self.current_dataset.x = np.append(self.current_dataset.x, data_point) 281 elif tagname == 'Qdev': 282 self.current_dataset.dx = np.append(self.current_dataset.dx, data_point) 283 elif tagname == 'dQw': 284 self.current_dataset.dxw = np.append(self.current_dataset.dxw, data_point) 285 elif tagname == 'dQl': 286 self.current_dataset.dxl = np.append(self.current_dataset.dxl, data_point) 287 elif tagname == 'Qmean': 288 pass 289 elif tagname == 'Shadowfactor': 290 pass 291 elif tagname == 'Sesans': 292 self.current_datainfo.isSesans = bool(data_point) 293 elif tagname == 'zacceptance': 294 self.current_datainfo.sample.zacceptance = (data_point, unit) 311 295 312 296 # I and Qx, Qy - 2D data … … 961 945 self._write_data_linearized(datainfo, entry_node) 962 946 # Transmission Spectrum Info 963 self._write_trans_spectrum(datainfo, entry_node) 947 # TODO: fix the writer to linearize all data, including T_spectrum 948 # self._write_trans_spectrum(datainfo, entry_node) 964 949 # Sample info 965 950 self._write_sample_info(datainfo, entry_node) … … 1065 1050 node.append(point) 1066 1051 self.write_node(point, "Q", datainfo.x[i], 1067 {'unit': datainfo. x_unit})1052 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1068 1053 if len(datainfo.y) >= i: 1069 1054 self.write_node(point, "I", datainfo.y[i], 1070 {'unit': datainfo. y_unit})1055 {'unit': datainfo._yaxis + " | " + datainfo._yunit}) 1071 1056 if datainfo.dy is not None and len(datainfo.dy) > i: 1072 1057 self.write_node(point, "Idev", datainfo.dy[i], 1073 {'unit': datainfo. y_unit})1058 {'unit': datainfo._yaxis + " | " + datainfo._yunit}) 1074 1059 if datainfo.dx is not None and len(datainfo.dx) > i: 1075 1060 self.write_node(point, "Qdev", datainfo.dx[i], 1076 {'unit': datainfo. x_unit})1061 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1077 1062 if datainfo.dxw is not None and len(datainfo.dxw) > i: 1078 1063 self.write_node(point, "dQw", datainfo.dxw[i], 1079 {'unit': datainfo. x_unit})1064 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1080 1065 if datainfo.dxl is not None and len(datainfo.dxl) > i: 1081 1066 self.write_node(point, "dQl", datainfo.dxl[i], 1082 {'unit': datainfo.x_unit}) 1083 1084 def _write_data_linearized(self, datainfo, entry_node): 1085 """ 1086 Writes 1D I and Q data to an XML file is a single Idata element 1087 1088 :param datainfo: The Data1D object the information is coming from 1089 :param entry_node: lxml node ElementTree object to be appended to 1090 """ 1091 node = self.create_element("SASdata") 1092 self.append(node, entry_node) 1093 1094 point = self.create_element("Idata") 1095 node.append(point) 1096 x = ','.join([str(datainfo.x[i]) for i in xrange(len(datainfo.x))]) 1097 self.write_node(point, "Q", x, {'unit': datainfo.x_unit}) 1098 y = ','.join([str(datainfo.y[i]) for i in xrange(len(datainfo.y))]) 1099 self.write_node(point, "I", y, {'unit': datainfo.y_unit}) 1100 if datainfo.dy is not None: 1101 dy = ','.join( 1102 [str(datainfo.dy[i]) for i in xrange(len(datainfo.dy))]) 1103 self.write_node(point, "Idev", dy, {'unit': datainfo.y_unit}) 1104 if datainfo.dx is not None: 1105 dx = ','.join( 1106 [str(datainfo.dx[i]) for i in xrange(len(datainfo.dx))]) 1107 self.write_node(point, "Qdev", dx, {'unit': datainfo.x_unit}) 1108 if datainfo.dxw is not None: 1109 dxw = ','.join( 1110 [str(datainfo.dxw[i]) for i in xrange(len(datainfo.dxw))]) 1111 self.write_node(point, "dQw", dxw, {'unit': datainfo.x_unit}) 1112 if datainfo.dxl is not None: 1113 dxl = ','.join( 1114 [str(datainfo.dxl[i]) for i in xrange(len(datainfo.dxl))]) 1115 self.write_node(point, "dQl", dxl, {'unit': datainfo.x_unit}) 1067 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1068 if datainfo.isSesans: 1069 sesans = self.create_element("Sesans") 1070 sesans.text = str(datainfo.isSesans) 1071 node.append(sesans) 1072 self.write_node(node, "zacceptance", datainfo.sample.zacceptance[0], 1073 {'unit': datainfo.sample.zacceptance[1]}) 1074 1116 1075 1117 1076 def _write_data_2d(self, datainfo, entry_node):
Note: See TracChangeset
for help on using the changeset viewer.