Changeset e2605a5 in sasview for sansdataloader/src/sans/dataloader
- Timestamp:
- May 23, 2012 3:41:29 PM (12 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:
- 0c24e98
- Parents:
- d56fc67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansdataloader/src/sans/dataloader/data_info.py
rf60a8c2 re2605a5 728 728 msg = "Incompatible data sets: x-values do not match" 729 729 raise ValueError, msg 730 if self.dxl != None and other.dxl == None: 731 msg = "Incompatible data sets: dxl-values do not match" 732 raise ValueError, msg 733 if self.dxl == None and other.dxl != None: 734 msg = "Incompatible data sets: dxl-values do not match" 735 raise ValueError, msg 736 if self.dxw != None and other.dxw == None: 737 msg = "Incompatible data sets: dxw-values do not match" 738 raise ValueError, msg 739 if self.dxw == None and other.dxw != None: 740 msg = "Incompatible data sets: dxw-values do not match" 741 raise ValueError, msg 730 742 731 743 # Check that the other data set has errors, otherwise … … 748 760 dy, dy_other = self._validity_check(other) 749 761 result = self.clone_without_data(len(self.x)) 750 762 if self.dxw == None: 763 result.dxw = None 764 else: 765 result.dxw = numpy.zeros(len(self.x)) 766 if self.dxl == None: 767 result.dxl = None 768 else: 769 result.dxl = numpy.zeros(len(self.x)) 770 751 771 for i in range(len(self.x)): 752 772 result.x[i] = self.x[i] 753 773 if self.dx is not None and len(self.x) == len(self.dx): 754 774 result.dx[i] = self.dx[i] 775 if self.dxw is not None and len(self.x) == len(self.dxw): 776 result.dxw[i] = self.dxw[i] 777 if self.dxl is not None and len(self.x) == len(self.dxl): 778 result.dxl[i] = self.dxl[i] 755 779 756 780 a = Uncertainty(self.y[i], dy[i]**2) 757 781 if isinstance(other, Data1D): 758 782 b = Uncertainty(other.y[i], dy_other[i]**2) 783 if other.dx is not None: 784 result.dx[i] *= self.dx[i] 785 result.dx[i] += (other.dx[i]**2) 786 result.dx[i] /= 2 787 result.dx[i] = math.sqrt(result.dx[i]) 788 if result.dxl is not None and other.dxl is not None: 789 result.dxl[i] *= self.dxl[i] 790 other.dxl[i] += (other.dxl[i]**2) 791 result.dxl[i] /= 2 792 result.dxl[i] = math.sqrt(result.dxl[i]) 793 if result.dxw is not None and self.dxw is not None: 794 result.dxw[i] *= self.dxw[i] 795 other.dxw[i] += (other.dxw[i]**2) 796 result.dxw[i] /= 2 797 result.dxw[i] = math.sqrt(result.dxw[i]) 759 798 else: 760 799 b = other … … 866 905 msg = "Unable to perform operation: data length are not equal" 867 906 raise ValueError, msg 868 907 if numpy.size(self.qx_data) != numpy.size(other.qx_data): 908 msg = "Unable to perform operation: data length are not equal" 909 raise ValueError, msg 910 if numpy.size(self.qy_data) != numpy.size(other.qy_data): 911 msg = "Unable to perform operation: data length are not equal" 912 raise ValueError, msg 913 # Here we could also extrapolate between data points 914 for i in range(len(self.data)): 915 if self.qx_data[i] != other.qx_data[i]: 916 msg = "Incompatible data sets: qx-values do not match" 917 raise ValueError, msg 918 if self.qy_data[i] != other.qy_data[i]: 919 msg = "Incompatible data sets: qy-values do not match" 920 raise ValueError, msg 921 869 922 # Check that the scales match 870 #TODO: matching scales?871 872 # Check that the other data set has errors, otherwise873 # create zero vector874 #TODO: test this875 923 err_other = other.err_data 876 924 if other.err_data == None or \ 877 925 (numpy.size(other.err_data) != numpy.size(other.data)): 878 err_other = numpy.zeros([numpy.size(other.data, 0), 879 numpy.size(other.data, 1)]) 926 err_other = numpy.zeros(numpy.size(other.data)) 880 927 881 928 # Check that we have errors, otherwise create zero vector … … 883 930 if self.err_data == None or \ 884 931 (numpy.size(self.err_data) != numpy.size(self.data)): 885 err = numpy.zeros([numpy.size(self.data, 0), 886 numpy.size(self.data, 1)]) 932 err = numpy.zeros(numpy.size(other.data)) 887 933 888 934 return err, err_other … … 898 944 # First, check the data compatibility 899 945 dy, dy_other = self._validity_check(other) 900 901 result = self.clone_without_data([numpy.size(self.data, 0), 902 numpy.size(self.data, 1)]) 903 904 for i in range(numpy.size(self.data, 0)): 905 for j in range(numpy.size(self.data, 1)): 906 result.data[i][j] = self.data[i][j] 907 if self.err_data is not None and \ 908 numpy.size(self.data) == numpy.size(self.err_data): 909 result.err_data[i][j] = self.err_data[i][j] 910 911 a = Uncertainty(self.data[i][j], dy[i][j]**2) 912 if isinstance(other, Data2D): 913 b = Uncertainty(other.data[i][j], dy_other[i][j]**2) 914 else: 915 b = other 916 917 output = operation(a, b) 918 result.data[i][j] = output.x 919 result.err_data[i][j] = math.sqrt(math.fabs(output.variance)) 946 result = self.clone_without_data(numpy.size(self.data)) 947 result.xmin = self.xmin 948 result.xmax = self.xmax 949 result.ymin = self.ymin 950 result.ymax = self.ymax 951 if self.dqx_data == None or self.dqy_data == None: 952 result.dqx_data = None 953 result.dqy_data = None 954 else: 955 result.dqx_data = numpy.zeros(len(self.data)) 956 result.dqy_data = numpy.zeros(len(self.data)) 957 for i in range(numpy.size(self.data)): 958 result.data[i] = self.data[i] 959 if self.err_data is not None and \ 960 numpy.size(self.data) == numpy.size(self.err_data): 961 result.err_data[i] = self.err_data[i] 962 if self.dqx_data is not None: 963 result.dqx_data[i] = self.dqx_data[i] 964 if self.dqy_data is not None: 965 result.dqy_data[i] = self.dqy_data[i] 966 result.qx_data[i] = self.qx_data[i] 967 result.qy_data[i] = self.qy_data[i] 968 result.q_data[i] = self.q_data[i] 969 result.mask[i] = self.mask[i] 970 971 a = Uncertainty(self.data[i], dy[i]**2) 972 if isinstance(other, Data2D): 973 b = Uncertainty(other.data[i], dy_other[i]**2) 974 if other.dqx_data is not None and \ 975 result.dqx_data is not None: 976 result.dqx_data[i] *= self.dqx_data[i] 977 result.dqx_data[i] += (other.dqx_data[i]**2) 978 result.dqx_data[i] /= 2 979 result.dqx_data[i] = math.sqrt(result.dqx_data[i]) 980 if other.dqy_data is not None and \ 981 result.dqy_data is not None: 982 result.dqy_data[i] *= self.dqy_data[i] 983 result.dqy_data[i] += (other.dqy_data[i]**2) 984 result.dqy_data[i] /= 2 985 result.dqy_data[i] = math.sqrt(result.dqy_data[i]) 986 else: 987 b = other 988 989 output = operation(a, b) 990 result.data[i] = output.x 991 result.err_data[i] = math.sqrt(math.fabs(output.variance)) 920 992 return result
Note: See TracChangeset
for help on using the changeset viewer.