Changes in src/sas/sascalc/dataloader/data_info.py [deaa0c6:4fdcc65] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
rdeaa0c6 r4fdcc65 716 716 self.y_unit = '1/cm' 717 717 except: # the data is not recognized/supported, and the user is notified 718 raise (TypeError,'data not recognized, check documentation for supported 1D data formats')718 raise TypeError('data not recognized, check documentation for supported 1D data formats') 719 719 720 720 def __str__(self): … … 796 796 len(self.y) != len(other.y): 797 797 msg = "Unable to perform operation: data length are not equal" 798 raise ValueError , msg798 raise ValueError(msg) 799 799 # Here we could also extrapolate between data points 800 800 TOLERANCE = 0.01 … … 802 802 if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 803 803 msg = "Incompatible data sets: x-values do not match" 804 raise ValueError , msg804 raise ValueError(msg) 805 805 806 806 # Check that the other data set has errors, otherwise … … 876 876 if not isinstance(other, Data1D): 877 877 msg = "Unable to perform operation: different types of data set" 878 raise ValueError , msg878 raise ValueError(msg) 879 879 return True 880 880 … … 948 948 949 949 if len(self.detector) > 0: 950 raise RuntimeError , "Data2D: Detector bank already filled at init"950 raise RuntimeError("Data2D: Detector bank already filled at init") 951 951 952 952 def __str__(self): … … 954 954 _str += "Data:\n" 955 955 _str += " Type: %s\n" % self.__class__.__name__ 956 _str += " X- & Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 956 _str += " X-axis: %s\t[%s]\n" % (self._xaxis, self._xunit) 957 _str += " Y-axis: %s\t[%s]\n" % (self._yaxis, self._yunit) 957 958 _str += " Z-axis: %s\t[%s]\n" % (self._zaxis, self._zunit) 958 959 _str += " Length: %g \n" % (len(self.data)) … … 983 984 qx_data=qx_data, qy_data=qy_data, 984 985 q_data=q_data, mask=mask) 986 987 clone._xaxis = self._xaxis 988 clone._yaxis = self._yaxis 989 clone._zaxis = self._zaxis 990 clone._xunit = self._xunit 991 clone._yunit = self._yunit 992 clone._zunit = self._zunit 993 clone.x_bins = self.x_bins 994 clone.y_bins = self.y_bins 985 995 986 996 clone.title = self.title … … 1020 1030 len(self.qy_data) != len(other.qy_data): 1021 1031 msg = "Unable to perform operation: data length are not equal" 1022 raise ValueError , msg1032 raise ValueError(msg) 1023 1033 for ind in range(len(self.data)): 1024 1034 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 1025 1035 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1026 raise ValueError , msg1036 raise ValueError(msg) 1027 1037 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 1028 1038 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1029 raise ValueError , msg1039 raise ValueError(msg) 1030 1040 1031 1041 # Check that the scales match … … 1108 1118 if not isinstance(other, Data2D): 1109 1119 msg = "Unable to perform operation: different types of data set" 1110 raise ValueError , msg1120 raise ValueError(msg) 1111 1121 return True 1112 1122 … … 1153 1163 def combine_data_info_with_plottable(data, datainfo): 1154 1164 """ 1155 A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object. 1165 A function that combines the DataInfo data in self.current_datainto with a 1166 plottable_1D or 2D data object. 1156 1167 1157 1168 :param data: A plottable_1D or plottable_2D data object … … 1171 1182 final_dataset.yaxis(data._yaxis, data._yunit) 1172 1183 elif isinstance(data, plottable_2D): 1173 final_dataset = Data2D(data.data, data.err_data, data.qx_data, data.qy_data, data.q_data, 1174 data.mask, data.dqx_data, data.dqy_data) 1184 final_dataset = Data2D(data.data, data.err_data, data.qx_data, 1185 data.qy_data, data.q_data, data.mask, 1186 data.dqx_data, data.dqy_data) 1175 1187 final_dataset.xaxis(data._xaxis, data._xunit) 1176 1188 final_dataset.yaxis(data._yaxis, data._yunit) 1177 1189 final_dataset.zaxis(data._zaxis, data._zunit) 1178 if len(data.data.shape) == 2: 1179 n_rows, n_cols = data.data.shape 1180 final_dataset.y_bins = data.qy_data[0::int(n_cols)] 1181 final_dataset.x_bins = data.qx_data[:int(n_cols)] 1190 final_dataset.y_bins = data.y_bins 1191 final_dataset.x_bins = data.x_bins 1182 1192 else: 1183 return_string = "Should Never Happen: _combine_data_info_with_plottable input is not a plottable1d or " + \ 1184 "plottable2d data object" 1193 return_string = ("Should Never Happen: _combine_data_info_with_plottabl" 1194 "e input is not a plottable1d or plottable2d data " 1195 "object") 1185 1196 return return_string 1186 1197
Note: See TracChangeset
for help on using the changeset viewer.