Changeset 83c09af in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Jan 3, 2017 1:12:00 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:
- af08e55
- Parents:
- c1681ea
- Location:
- src/sas/sascalc/dataloader/readers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r0639476 r83c09af 20 20 import inspect 21 21 # For saving individual sections of data 22 from sas.sascalc.dataloader.data_info import Data1D, DataInfo, plottable_1D 23 from sas.sascalc.dataloader.data_info import Collimation, TransmissionSpectrum, Detector, Process, Aperture 24 from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable as combine_data 22 from sas.sascalc.dataloader.data_info import Data1D, Data2D, DataInfo, \ 23 plottable_1D 24 from sas.sascalc.dataloader.data_info import Collimation, TransmissionSpectrum, \ 25 Detector, Process, Aperture 26 from sas.sascalc.dataloader.data_info import \ 27 combine_data_info_with_plottable as combine_data 25 28 import sas.sascalc.dataloader.readers.xml_reader as xml_reader 26 29 from sas.sascalc.dataloader.readers.xml_reader import XMLreader … … 792 795 :param datainfo: Data1D object 793 796 """ 794 if not issubclass(datainfo.__class__, Data1D):795 raise RuntimeError, "The cansas writer expects a Data1D instance"797 if issubclass(datainfo.__class__, Data2D): 798 is_2d = True 796 799 797 800 # Get PIs and create root element … … 813 816 self._write_run_names(datainfo, entry_node) 814 817 # Add Data info to SASEntry 815 self._write_data(datainfo, entry_node) 818 if is_2d: 819 self._write_data_2d(datainfo, entry_node) 820 else: 821 self._write_data(datainfo, entry_node) 816 822 # Transmission Spectrum Info 817 823 self._write_trans_spectrum(datainfo, entry_node) … … 907 913 def _write_data(self, datainfo, entry_node): 908 914 """ 909 Writes theI and Q data to the XML file915 Writes 1D I and Q data to the XML file 910 916 911 917 :param datainfo: The Data1D object the information is coming from … … 935 941 self.write_node(point, "dQl", datainfo.dxl[i], 936 942 {'unit': datainfo.x_unit}) 943 944 def _write_data_2d(self, datainfo, entry_node): 945 """ 946 Writes 2D data to the XML file 947 948 :param datainfo: The Data2D object the information is coming from 949 :param entry_node: lxml node ElementTree object to be appended to 950 """ 951 node = self.create_element("SASdata") 952 self.append(node, entry_node) 953 954 for i in range(len(datainfo.data)): 955 point = self.create_element("Idata") 956 node.append(point) 957 self.write_node(point, "Qx", datainfo.qx_data[i], 958 {'unit': datainfo._xunit}) 959 self.write_node(point, "Qy", datainfo.qy_data[i], 960 {'unit': datainfo._yunit}) 961 self.write_node(point, "I", datainfo.data[i], 962 {'unit': datainfo._zunit}) 963 if datainfo.err_data is not None and len(datainfo.err_data) > i: 964 self.write_node(point, "Idev", datainfo.err_data[i], 965 {'unit': datainfo._zunit}) 966 if datainfo.dqy_data is not None and len(datainfo.dqy_data) > i: 967 self.write_node(point, "Qydev", datainfo.dqy_data[i], 968 {'unit': datainfo._yunit}) 969 if datainfo.dqx_data is not None and len(datainfo.dqx_data) > i: 970 self.write_node(point, "Qxdev", datainfo.dqx_data[i], 971 {'unit': datainfo._xunit}) 972 if datainfo.mask is not None and len(datainfo.mask) > i: 973 self.write_node(point, "Mask", datainfo.err_data[i]) 937 974 938 975 def _write_trans_spectrum(self, datainfo, entry_node): -
src/sas/sascalc/dataloader/readers/schema/cansas1d_invalid_v1_0.xsd
r250fec92 r83c09af 24 24 25 25 <complexType name="IdataType"> 26 <xsd:choice> 26 27 <sequence> 27 28 <element name="Q" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> … … 40 41 <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax" namespace="##other" /> 41 42 </sequence> 43 <sequence> 44 <element name="Qx" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 45 <element name="Qy" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 46 <element name="I" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 47 <element name="Idev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 48 <element name="Qydev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 49 <element name="Qxdev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 50 <element name="Mask" minOccurs="0" maxOccurs="1" type="string" default="0" /> 51 </sequence> 52 </xsd:choice> 42 53 </complexType> 43 54 -
src/sas/sascalc/dataloader/readers/schema/cansas1d_invalid_v1_1.xsd
r250fec92 r83c09af 24 24 25 25 <complexType name="IdataType"> 26 <xsd:choice> 26 27 <sequence> 27 28 <element name="Q" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> … … 40 41 <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax" namespace="##other" /> 41 42 </sequence> 43 <sequence> 44 <element name="Qx" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 45 <element name="Qy" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 46 <element name="I" minOccurs="1" maxOccurs="1" type="tns:floatUnitType" /> 47 <element name="Idev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 48 <element name="Qydev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 49 <element name="Qxdev" minOccurs="0" maxOccurs="1" type="tns:floatUnitType" default="0" /> 50 <element name="Mask" minOccurs="0" maxOccurs="1" type="string" default="0" /> 51 </sequence> 52 </xsd:choice> 42 53 </complexType> 43 54
Note: See TracChangeset
for help on using the changeset viewer.