Changeset dcf73a4 in sasview for sansdataloader/src/sans
- Timestamp:
- Jun 14, 2012 1:48:28 PM (13 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 72538fc
- Parents:
- 965264a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansdataloader/src/sans/dataloader/data_info.py
r9ab366a rdcf73a4 959 959 dqx_data = None 960 960 dqy_data = None 961 clone = Data2D(data, err_data, qx_data, qy_data, 962 q_data, mask, dqx_data=dqx_data, dqy_data=dqy_data) 961 clone = Data2D(data, err_data, qx_data, qy_data, q_data, mask) 963 962 964 963 clone.title = self.title … … 995 994 if isinstance(other, Data2D): 996 995 # Check that data lengths are the same 997 if numpy.size(self.data) != numpy.size(other.data): 996 if len(self.data) != len(other.data) or \ 997 len(self.qx_data) != len(other.qx_data) or \ 998 len(self.qy_data) != len(other.qy_data): 998 999 msg = "Unable to perform operation: data length are not equal" 999 1000 raise ValueError, msg 1000 if numpy.size(self.qx_data) != numpy.size(other.qx_data): 1001 msg = "Unable to perform operation: data length are not equal" 1002 raise ValueError, msg 1003 if numpy.size(self.qy_data) != numpy.size(other.qy_data): 1004 msg = "Unable to perform operation: data length are not equal" 1005 raise ValueError, msg 1006 # Here we could also extrapolate between data points 1007 if self.qx_data.all() != other.qx_data.all(): 1008 msg = "Incompatible data sets: qx-values do not match" 1009 raise ValueError, msg 1010 if self.qy_data.all() != other.qy_data.all(): 1011 msg = "Incompatible data sets: qy-values do not match" 1012 raise ValueError, msg 1013 if numpy.size(self.data) < 2: 1014 msg = "Incompatible data sets: I-values do not match" 1015 raise ValueError, msg 1016 elif other.__class__.__name__ == 'ndarray': 1017 for ind in range(len(self.data)): 1018 if self.qx_data[ind] != other.qx_data[ind]: 1019 msg = "Incompatible data sets: qx-values do not match" 1020 raise ValueError, msg 1021 if self.qy_data[ind] != other.qy_data[ind]: 1022 msg = "Incompatible data sets: qy-values do not match" 1023 raise ValueError, msg 1001 #if len(self.data) < 1: 1002 # msg = "Incompatible data sets: I-values do not match" 1003 # raise ValueError, msg 1004 for ind in range(len(self.data)): 1005 if self.qx_data[ind] != other.qx_data[ind]: 1006 msg = "Incompatible data sets: qx-values do not match" 1007 raise ValueError, msg 1008 if self.qy_data[ind] != other.qy_data[ind]: 1009 msg = "Incompatible data sets: qy-values do not match" 1010 raise ValueError, msg 1024 1011 1025 1012 # Check that the scales match 1026 1013 err_other = other.err_data 1027 1014 if other.err_data == None or \ 1028 ( numpy.size(other.err_data) != numpy.size(other.data)):1029 err_other = numpy.zeros( numpy.size(other.data))1015 (len(other.err_data) != len(other.data)): 1016 err_other = numpy.zeros(len(other.data)) 1030 1017 1031 1018 # Check that we have errors, otherwise create zero vector 1032 1019 err = self.err_data 1033 1020 if self.err_data == None or \ 1034 ( numpy.size(self.err_data) != numpy.size(self.data)):1035 err = numpy.zeros( numpy.size(other.data))1021 (len(self.err_data) != len(self.data)): 1022 err = numpy.zeros(len(other.data)) 1036 1023 1037 1024 return err, err_other … … 1045 1032 1046 1033 """ 1034 print "numpy.size(self.data)=", numpy.size(self.data) 1047 1035 # First, check the data compatibility 1048 1036 dy, dy_other = self._validity_check(other) 1049 1037 result = self.clone_without_data(numpy.size(self.data)) 1038 result.data = self.data 1039 result.qx_data = self.qx_data 1040 result.qy_data = self.qy_data 1041 result.q_data = self.q_data 1042 result.mask = self.mask 1050 1043 result.xmin = self.xmin 1051 1044 result.xmax = self.xmax 1052 1045 result.ymin = self.ymin 1053 1046 result.ymax = self.ymax 1047 1048 if self.err_data is not None: 1049 result.err_data = self.err_data 1050 if self.dqx_data is not None: 1051 result.dqx_data = self.dqx_data 1052 if self.dqy_data is not None: 1053 result.dqy_data = self.dqy_data 1054 1054 if self.dqx_data == None or self.dqy_data == None: 1055 1055 result.dqx_data = None 1056 1056 result.dqy_data = None 1057 1057 else: 1058 result.dqx_data = numpy.zeros(len(self.data)) 1059 result.dqy_data = numpy.zeros(len(self.data)) 1058 result.dqx_data = numpy.zeros(numpy.size(self.data)) 1059 result.dqy_data = numpy.zeros(numpy.size(self.data)) 1060 1060 1061 for i in range(numpy.size(self.data)): 1061 result.data[i] = self.data[i]1062 if self.err_data is not None and \1063 numpy.size(self.data) == numpy.size(self.err_data):1064 result.err_data[i] = self.err_data[i]1065 if self.dqx_data is not None:1066 result.dqx_data[i] = self.dqx_data[i]1067 if self.dqy_data is not None:1068 result.dqy_data[i] = self.dqy_data[i]1069 result.qx_data[i] = self.qx_data[i]1070 result.qy_data[i] = self.qy_data[i]1071 result.q_data[i] = self.q_data[i]1072 result.mask[i] = self.mask[i]1073 1074 1062 a = Uncertainty(self.data[i], dy[i]**2) 1075 1063 if isinstance(other, Data2D):
Note: See TracChangeset
for help on using the changeset viewer.