Changeset 527a190 in sasview
- Timestamp:
- Apr 9, 2017 5:38:18 AM (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, 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:
- 46d210d, b61bd57, 2ab812d
- Parents:
- 8eb9043
- git-author:
- Jeff Krzywon <krzywon@…> (04/09/17 05:38:18)
- git-committer:
- krzywon <krzywon@…> (04/09/17 05:38:18)
- Location:
- src/sas/sascalc/dataloader/readers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r8434365 r527a190 156 156 # If the file does not match the schema, raise this error 157 157 invalid_xml = self.find_invalid_xml() 158 invalid_xml = INVALID_XML.format(basename + extension) + invalid_xml 159 self.errors.add(invalid_xml) 158 if invalid_xml != "": 159 invalid_xml = INVALID_XML.format(basename + extension) + invalid_xml 160 self.errors.add(invalid_xml) 160 161 # Try again with an invalid CanSAS schema, that requires only a data set in each 161 162 base_name = xml_reader.__file__ … … 261 262 # I and Q - 1D data 262 263 elif tagname == 'I' and isinstance(self.current_dataset, plottable_1D): 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) 264 self.current_dataset.yaxis("Intensity", unit) 269 265 self.current_dataset.y = np.append(self.current_dataset.y, data_point) 270 266 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_1D): 271 267 self.current_dataset.dy = np.append(self.current_dataset.dy, data_point) 272 268 elif tagname == 'Q': 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) 269 self.current_dataset.xaxis("Q", unit) 279 270 self.current_dataset.x = np.append(self.current_dataset.x, data_point) 280 271 elif tagname == 'Qdev': … … 290 281 elif tagname == 'Sesans': 291 282 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')) 292 287 elif tagname == 'zacceptance': 293 288 self.current_datainfo.sample.zacceptance = (data_point, unit) … … 781 776 value_unit = local_unit 782 777 except KeyError: 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) 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) 787 785 value_unit = local_unit 788 786 except: … … 1035 1033 node.append(point) 1036 1034 self.write_node(point, "Q", datainfo.x[i], 1037 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})1035 {'unit': datainfo.x_unit}) 1038 1036 if len(datainfo.y) >= i: 1039 1037 self.write_node(point, "I", datainfo.y[i], 1040 {'unit': datainfo. _yaxis + " | " + datainfo._yunit})1038 {'unit': datainfo.y_unit}) 1041 1039 if datainfo.dy is not None and len(datainfo.dy) > i: 1042 1040 self.write_node(point, "Idev", datainfo.dy[i], 1043 {'unit': datainfo. _yaxis + " | " + datainfo._yunit})1041 {'unit': datainfo.y_unit}) 1044 1042 if datainfo.dx is not None and len(datainfo.dx) > i: 1045 1043 self.write_node(point, "Qdev", datainfo.dx[i], 1046 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})1044 {'unit': datainfo.x_unit}) 1047 1045 if datainfo.dxw is not None and len(datainfo.dxw) > i: 1048 1046 self.write_node(point, "dQw", datainfo.dxw[i], 1049 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})1047 {'unit': datainfo.x_unit}) 1050 1048 if datainfo.dxl is not None and len(datainfo.dxl) > i: 1051 1049 self.write_node(point, "dQl", datainfo.dxl[i], 1052 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})1050 {'unit': datainfo.x_unit}) 1053 1051 if datainfo.isSesans: 1054 sesans = self.create_element("Sesans") 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) 1055 1057 sesans.text = str(datainfo.isSesans) 1056 node.append(sesans)1057 self.write_node( node, "zacceptance", datainfo.sample.zacceptance[0],1058 entry_node.append(sesans) 1059 self.write_node(entry_node, "zacceptance", datainfo.sample.zacceptance[0], 1058 1060 {'unit': datainfo.sample.zacceptance[1]}) 1059 1061 -
src/sas/sascalc/dataloader/readers/xml_reader.py
ra235f715 r527a190 128 128 first_error = schema.assertValid(self.xmldoc) 129 129 except etree.DocumentInvalid as err: 130 # Suppress errors for <'any'> elements 131 if "##other" in str(err): 132 return first_error 130 133 first_error = str(err) 131 134 return first_error
Note: See TracChangeset
for help on using the changeset viewer.