Changeset e56f335 in sasview for src/sas/sascalc/dataloader/readers
- Timestamp:
- Sep 14, 2017 2:28:11 PM (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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 590b5c2
- Parents:
- 4660990 (diff), 7b3f154 (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. - Location:
- src/sas/sascalc/dataloader/readers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
ra78a02f rc54c965 130 130 self.current_datainfo.meta_data[PREPROCESS] = self.processing_instructions 131 131 self._parse_entry(entry) 132 has_error_dx = self.current_dataset.dx is not None 133 has_error_dy = self.current_dataset.dy is not None 134 self.remove_empty_q_values(has_error_dx=has_error_dx, 135 has_error_dy=has_error_dy) 136 self.send_to_output() # Combine datasets with DataInfo 137 self.current_datainfo = DataInfo() # Reset DataInfo 132 self.data_cleanup() 138 133 except FileContentsException as fc_exc: 139 134 # File doesn't meet schema - try loading with a less strict schema … … 154 149 self.load_file_and_schema(xml_file) # Reload strict schema so we can find where error are in file 155 150 invalid_xml = self.find_invalid_xml() 156 invalid_xml = INVALID_XML.format(basename + self.extension) + invalid_xml 157 raise DataReaderException(invalid_xml) # Handled by base class 151 if invalid_xml != "": 152 invalid_xml = INVALID_XML.format(basename + self.extension) + invalid_xml 153 raise DataReaderException(invalid_xml) # Handled by base class 158 154 except FileContentsException as fc_exc: 159 155 msg = "CanSAS Reader could not load the file {}".format(xml_file) … … 279 275 # I and Q points 280 276 elif tagname == 'I' and isinstance(self.current_dataset, plottable_1D): 281 unit_list = unit.split("|") 282 if len(unit_list) > 1: 283 self.current_dataset.yaxis(unit_list[0].strip(), 284 unit_list[1].strip()) 285 else: 286 self.current_dataset.yaxis("Intensity", unit) 277 self.current_dataset.yaxis("Intensity", unit) 287 278 self.current_dataset.y = np.append(self.current_dataset.y, data_point) 288 279 elif tagname == 'Idev' and isinstance(self.current_dataset, plottable_1D): 289 280 self.current_dataset.dy = np.append(self.current_dataset.dy, data_point) 290 281 elif tagname == 'Q': 291 unit_list = unit.split("|") 292 if len(unit_list) > 1: 293 self.current_dataset.xaxis(unit_list[0].strip(), 294 unit_list[1].strip()) 295 else: 296 self.current_dataset.xaxis("Q", unit) 282 self.current_dataset.xaxis("Q", unit) 297 283 self.current_dataset.x = np.append(self.current_dataset.x, data_point) 298 284 elif tagname == 'Qdev': … … 312 298 elif tagname == 'Sesans': 313 299 self.current_datainfo.isSesans = bool(data_point) 300 self.current_dataset.xaxis(attr.get('x_axis'), 301 attr.get('x_unit')) 302 self.current_dataset.yaxis(attr.get('y_axis'), 303 attr.get('y_unit')) 314 304 elif tagname == 'yacceptance': 315 305 self.current_datainfo.sample.yacceptance = (data_point, unit) … … 512 502 for error in self.errors: 513 503 self.current_datainfo.errors.add(error) 514 self.errors.clear() 515 self.send_to_output() 504 self.data_cleanup() 505 self.sort_one_d_data() 506 self.sort_two_d_data() 507 self.reset_data_list() 516 508 empty = None 517 509 return self.output[0], empty 510 511 def data_cleanup(self): 512 """ 513 Clean up the data sets and refresh everything 514 :return: None 515 """ 516 has_error_dx = self.current_dataset.dx is not None 517 has_error_dy = self.current_dataset.dy is not None 518 self.remove_empty_q_values(has_error_dx=has_error_dx, 519 has_error_dy=has_error_dy) 520 self.send_to_output() # Combine datasets with DataInfo 521 self.current_datainfo = DataInfo() # Reset DataInfo 518 522 519 523 def _is_call_local(self): … … 642 646 value_unit = local_unit 643 647 except KeyError: 644 err_msg = "CanSAS reader: unexpected " 645 err_msg += "\"{0}\" unit [{1}]; " 646 err_msg = err_msg.format(tagname, local_unit) 647 err_msg += "expecting [{0}]".format(default_unit) 648 # Do not throw an error for loading Sesans data in cansas xml 649 # This is a temporary fix. 650 if local_unit != "A" and local_unit != 'pol': 651 err_msg = "CanSAS reader: unexpected " 652 err_msg += "\"{0}\" unit [{1}]; " 653 err_msg = err_msg.format(tagname, local_unit) 654 err_msg += "expecting [{0}]".format(default_unit) 648 655 value_unit = local_unit 649 656 except: … … 857 864 node.append(point) 858 865 self.write_node(point, "Q", datainfo.x[i], 859 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})866 {'unit': datainfo.x_unit}) 860 867 if len(datainfo.y) >= i: 861 868 self.write_node(point, "I", datainfo.y[i], 862 {'unit': datainfo. _yaxis + " | " + datainfo._yunit})869 {'unit': datainfo.y_unit}) 863 870 if datainfo.dy is not None and len(datainfo.dy) > i: 864 871 self.write_node(point, "Idev", datainfo.dy[i], 865 {'unit': datainfo. _yaxis + " | " + datainfo._yunit})872 {'unit': datainfo.y_unit}) 866 873 if datainfo.dx is not None and len(datainfo.dx) > i: 867 874 self.write_node(point, "Qdev", datainfo.dx[i], 868 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})875 {'unit': datainfo.x_unit}) 869 876 if datainfo.dxw is not None and len(datainfo.dxw) > i: 870 877 self.write_node(point, "dQw", datainfo.dxw[i], 871 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})878 {'unit': datainfo.x_unit}) 872 879 if datainfo.dxl is not None and len(datainfo.dxl) > i: 873 880 self.write_node(point, "dQl", datainfo.dxl[i], 874 {'unit': datainfo. _xaxis + " | " + datainfo._xunit})881 {'unit': datainfo.x_unit}) 875 882 if datainfo.isSesans: 876 sesans = self.create_element("Sesans") 883 sesans_attrib = {'x_axis': datainfo._xaxis, 884 'y_axis': datainfo._yaxis, 885 'x_unit': datainfo.x_unit, 886 'y_unit': datainfo.y_unit} 887 sesans = self.create_element("Sesans", attrib=sesans_attrib) 877 888 sesans.text = str(datainfo.isSesans) 878 node.append(sesans)879 self.write_node( node, "yacceptance", datainfo.sample.yacceptance[0],889 entry_node.append(sesans) 890 self.write_node(entry_node, "yacceptance", datainfo.sample.yacceptance[0], 880 891 {'unit': datainfo.sample.yacceptance[1]}) 881 self.write_node( node, "zacceptance", datainfo.sample.zacceptance[0],892 self.write_node(entry_node, "zacceptance", datainfo.sample.zacceptance[0], 882 893 {'unit': datainfo.sample.zacceptance[1]}) 883 894 -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
rdcb91cf rcd57c7d4 140 140 141 141 if isinstance(value, h5py.Group): 142 # Set parent class before recursion 142 143 self.parent_class = class_name 143 144 parent_list.append(key) … … 150 151 # Recursion step to access data within the group 151 152 self.read_children(value, parent_list) 153 # Reset parent class when returning from recursive method 154 self.parent_class = class_name 152 155 self.add_intermediate() 153 156 parent_list.remove(key) -
src/sas/sascalc/dataloader/readers/xml_reader.py
rfafe52a rcd57c7d4 134 134 first_error = schema.assertValid(self.xmldoc) 135 135 except etree.DocumentInvalid as err: 136 # Suppress errors for <'any'> elements 137 if "##other" in str(err): 138 return first_error 136 139 first_error = str(err) 137 140 return first_error
Note: See TracChangeset
for help on using the changeset viewer.