Changes in / [84657f7:6d3c4e7] in sasview
- Location:
- src/sas/sascalc/dataloader/readers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r527a190 r8434365 156 156 # If the file does not match the schema, raise this error 157 157 invalid_xml = self.find_invalid_xml() 158 if invalid_xml != "": 159 invalid_xml = INVALID_XML.format(basename + extension) + invalid_xml 160 self.errors.add(invalid_xml) 158 invalid_xml = INVALID_XML.format(basename + extension) + invalid_xml 159 self.errors.add(invalid_xml) 161 160 # Try again with an invalid CanSAS schema, that requires only a data set in each 162 161 base_name = xml_reader.__file__ … … 262 261 # I and Q - 1D data 263 262 elif tagname == 'I' and isinstance(self.current_dataset, plottable_1D): 264 self.current_dataset.yaxis("Intensity", unit) 263 unit_list = unit.split("|") 264 if len(unit_list) > 1: 265 self.current_dataset.yaxis(unit_list[0].strip(), 266 unit_list[1].strip()) 267 else: 268 self.current_dataset.yaxis("Intensity", unit) 265 269 self.current_dataset.y = np.append(self.current_dataset.y, data_point) 266 270 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_1D): 267 271 self.current_dataset.dy = np.append(self.current_dataset.dy, data_point) 268 272 elif tagname == 'Q': 269 self.current_dataset.xaxis("Q", unit) 273 unit_list = unit.split("|") 274 if len(unit_list) > 1: 275 self.current_dataset.xaxis(unit_list[0].strip(), 276 unit_list[1].strip()) 277 else: 278 self.current_dataset.xaxis("Q", unit) 270 279 self.current_dataset.x = np.append(self.current_dataset.x, data_point) 271 280 elif tagname == 'Qdev': … … 281 290 elif tagname == 'Sesans': 282 291 self.current_datainfo.isSesans = bool(data_point) 283 self.current_dataset.xaxis(attr.get('x_axis'),284 attr.get('x_unit'))285 self.current_dataset.yaxis(attr.get('y_axis'),286 attr.get('y_unit'))287 292 elif tagname == 'zacceptance': 288 293 self.current_datainfo.sample.zacceptance = (data_point, unit) … … 776 781 value_unit = local_unit 777 782 except KeyError: 778 # Do not throw an error for loading Sesans data in cansas xml 779 # This is a temporary fix. 780 if local_unit != "A" and local_unit != 'pol': 781 err_msg = "CanSAS reader: unexpected " 782 err_msg += "\"{0}\" unit [{1}]; " 783 err_msg = err_msg.format(tagname, local_unit) 784 err_msg += "expecting [{0}]".format(default_unit) 783 err_msg = "CanSAS reader: unexpected " 784 err_msg += "\"{0}\" unit [{1}]; " 785 err_msg = err_msg.format(tagname, local_unit) 786 err_msg += "expecting [{0}]".format(default_unit) 785 787 value_unit = local_unit 786 788 except: … … 1033 1035 node.append(point) 1034 1036 self.write_node(point, "Q", datainfo.x[i], 1035 {'unit': datainfo. x_unit})1037 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1036 1038 if len(datainfo.y) >= i: 1037 1039 self.write_node(point, "I", datainfo.y[i], 1038 {'unit': datainfo. y_unit})1040 {'unit': datainfo._yaxis + " | " + datainfo._yunit}) 1039 1041 if datainfo.dy is not None and len(datainfo.dy) > i: 1040 1042 self.write_node(point, "Idev", datainfo.dy[i], 1041 {'unit': datainfo. y_unit})1043 {'unit': datainfo._yaxis + " | " + datainfo._yunit}) 1042 1044 if datainfo.dx is not None and len(datainfo.dx) > i: 1043 1045 self.write_node(point, "Qdev", datainfo.dx[i], 1044 {'unit': datainfo. x_unit})1046 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1045 1047 if datainfo.dxw is not None and len(datainfo.dxw) > i: 1046 1048 self.write_node(point, "dQw", datainfo.dxw[i], 1047 {'unit': datainfo. x_unit})1049 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1048 1050 if datainfo.dxl is not None and len(datainfo.dxl) > i: 1049 1051 self.write_node(point, "dQl", datainfo.dxl[i], 1050 {'unit': datainfo. x_unit})1052 {'unit': datainfo._xaxis + " | " + datainfo._xunit}) 1051 1053 if datainfo.isSesans: 1052 sesans_attrib = {'x_axis': datainfo._xaxis, 1053 'y_axis': datainfo._yaxis, 1054 'x_unit': datainfo.x_unit, 1055 'y_unit': datainfo.y_unit} 1056 sesans = self.create_element("Sesans", attrib=sesans_attrib) 1054 sesans = self.create_element("Sesans") 1057 1055 sesans.text = str(datainfo.isSesans) 1058 entry_node.append(sesans)1059 self.write_node( entry_node, "zacceptance", datainfo.sample.zacceptance[0],1056 node.append(sesans) 1057 self.write_node(node, "zacceptance", datainfo.sample.zacceptance[0], 1060 1058 {'unit': datainfo.sample.zacceptance[1]}) 1061 1059 -
src/sas/sascalc/dataloader/readers/xml_reader.py
r527a190 ra235f715 128 128 first_error = schema.assertValid(self.xmldoc) 129 129 except etree.DocumentInvalid as err: 130 # Suppress errors for <'any'> elements131 if "##other" in str(err):132 return first_error133 130 first_error = str(err) 134 131 return first_error
Note: See TracChangeset
for help on using the changeset viewer.