Changeset 9a5097c in sasview for src/sas/sascalc/dataloader/data_info.py
- Timestamp:
- Mar 26, 2017 11:33:16 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ed2276f
- Parents:
- 9146ed9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
r2ffe241 r9a5097c 23 23 #from sas.guitools.plottables import Data1D as plottable_1D 24 24 from sas.sascalc.data_util.uncertainty import Uncertainty 25 import numpy 25 import numpy as np 26 26 import math 27 27 … … 51 51 52 52 def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None): 53 self.x = n umpy.asarray(x)54 self.y = n umpy.asarray(y)53 self.x = np.asarray(x) 54 self.y = np.asarray(y) 55 55 if dx is not None: 56 self.dx = n umpy.asarray(dx)56 self.dx = np.asarray(dx) 57 57 if dy is not None: 58 self.dy = n umpy.asarray(dy)58 self.dy = np.asarray(dy) 59 59 if dxl is not None: 60 self.dxl = n umpy.asarray(dxl)60 self.dxl = np.asarray(dxl) 61 61 if dxw is not None: 62 self.dxw = n umpy.asarray(dxw)62 self.dxw = np.asarray(dxw) 63 63 if lam is not None: 64 self.lam = n umpy.asarray(lam)64 self.lam = np.asarray(lam) 65 65 if dlam is not None: 66 self.dlam = n umpy.asarray(dlam)66 self.dlam = np.asarray(dlam) 67 67 68 68 def xaxis(self, label, unit): … … 109 109 qy_data=None, q_data=None, mask=None, 110 110 dqx_data=None, dqy_data=None): 111 self.data = n umpy.asarray(data)112 self.qx_data = n umpy.asarray(qx_data)113 self.qy_data = n umpy.asarray(qy_data)114 self.q_data = n umpy.asarray(q_data)115 self.mask = n umpy.asarray(mask)116 self.err_data = n umpy.asarray(err_data)111 self.data = np.asarray(data) 112 self.qx_data = np.asarray(qx_data) 113 self.qy_data = np.asarray(qy_data) 114 self.q_data = np.asarray(q_data) 115 self.mask = np.asarray(mask) 116 self.err_data = np.asarray(err_data) 117 117 if dqx_data is not None: 118 self.dqx_data = n umpy.asarray(dqx_data)118 self.dqx_data = np.asarray(dqx_data) 119 119 if dqy_data is not None: 120 self.dqy_data = n umpy.asarray(dqy_data)120 self.dqy_data = np.asarray(dqy_data) 121 121 122 122 def xaxis(self, label, unit): … … 734 734 """ 735 735 def _check(v): 736 if (v.__class__ == list or v.__class__ == n umpy.ndarray) \736 if (v.__class__ == list or v.__class__ == np.ndarray) \ 737 737 and len(v) > 0 and min(v) > 0: 738 738 return True … … 752 752 753 753 if clone is None or not issubclass(clone.__class__, Data1D): 754 x = n umpy.zeros(length)755 dx = n umpy.zeros(length)756 y = n umpy.zeros(length)757 dy = n umpy.zeros(length)758 lam = n umpy.zeros(length)759 dlam = n umpy.zeros(length)754 x = np.zeros(length) 755 dx = np.zeros(length) 756 y = np.zeros(length) 757 dy = np.zeros(length) 758 lam = np.zeros(length) 759 dlam = np.zeros(length) 760 760 clone = Data1D(x, y, lam=lam, dx=dx, dy=dy, dlam=dlam) 761 761 … … 806 806 dy_other = other.dy 807 807 if other.dy == None or (len(other.dy) != len(other.y)): 808 dy_other = n umpy.zeros(len(other.y))808 dy_other = np.zeros(len(other.y)) 809 809 810 810 # Check that we have errors, otherwise create zero vector 811 811 dy = self.dy 812 812 if self.dy == None or (len(self.dy) != len(self.y)): 813 dy = n umpy.zeros(len(self.y))813 dy = np.zeros(len(self.y)) 814 814 815 815 return dy, dy_other … … 824 824 result.dxw = None 825 825 else: 826 result.dxw = n umpy.zeros(len(self.x))826 result.dxw = np.zeros(len(self.x)) 827 827 if self.dxl == None: 828 828 result.dxl = None 829 829 else: 830 result.dxl = n umpy.zeros(len(self.x))830 result.dxl = np.zeros(len(self.x)) 831 831 832 832 for i in range(len(self.x)): … … 886 886 result.dy = None 887 887 else: 888 result.dy = n umpy.zeros(len(self.x) + len(other.x))888 result.dy = np.zeros(len(self.x) + len(other.x)) 889 889 if self.dx == None or other.dx is None: 890 890 result.dx = None 891 891 else: 892 result.dx = n umpy.zeros(len(self.x) + len(other.x))892 result.dx = np.zeros(len(self.x) + len(other.x)) 893 893 if self.dxw == None or other.dxw is None: 894 894 result.dxw = None 895 895 else: 896 result.dxw = n umpy.zeros(len(self.x) + len(other.x))896 result.dxw = np.zeros(len(self.x) + len(other.x)) 897 897 if self.dxl == None or other.dxl is None: 898 898 result.dxl = None 899 899 else: 900 result.dxl = n umpy.zeros(len(self.x) + len(other.x))901 902 result.x = n umpy.append(self.x, other.x)900 result.dxl = np.zeros(len(self.x) + len(other.x)) 901 902 result.x = np.append(self.x, other.x) 903 903 #argsorting 904 ind = n umpy.argsort(result.x)904 ind = np.argsort(result.x) 905 905 result.x = result.x[ind] 906 result.y = n umpy.append(self.y, other.y)906 result.y = np.append(self.y, other.y) 907 907 result.y = result.y[ind] 908 908 if result.dy != None: 909 result.dy = n umpy.append(self.dy, other.dy)909 result.dy = np.append(self.dy, other.dy) 910 910 result.dy = result.dy[ind] 911 911 if result.dx is not None: 912 result.dx = n umpy.append(self.dx, other.dx)912 result.dx = np.append(self.dx, other.dx) 913 913 result.dx = result.dx[ind] 914 914 if result.dxw is not None: 915 result.dxw = n umpy.append(self.dxw, other.dxw)915 result.dxw = np.append(self.dxw, other.dxw) 916 916 result.dxw = result.dxw[ind] 917 917 if result.dxl is not None: 918 result.dxl = n umpy.append(self.dxl, other.dxl)918 result.dxl = np.append(self.dxl, other.dxl) 919 919 result.dxl = result.dxl[ind] 920 920 return result … … 970 970 971 971 if clone is None or not issubclass(clone.__class__, Data2D): 972 data = n umpy.zeros(length)973 err_data = n umpy.zeros(length)974 qx_data = n umpy.zeros(length)975 qy_data = n umpy.zeros(length)976 q_data = n umpy.zeros(length)977 mask = n umpy.zeros(length)972 data = np.zeros(length) 973 err_data = np.zeros(length) 974 qx_data = np.zeros(length) 975 qy_data = np.zeros(length) 976 q_data = np.zeros(length) 977 mask = np.zeros(length) 978 978 dqx_data = None 979 979 dqy_data = None … … 1031 1031 if other.err_data == None or \ 1032 1032 (len(other.err_data) != len(other.data)): 1033 err_other = n umpy.zeros(len(other.data))1033 err_other = np.zeros(len(other.data)) 1034 1034 1035 1035 # Check that we have errors, otherwise create zero vector … … 1037 1037 if self.err_data == None or \ 1038 1038 (len(self.err_data) != len(self.data)): 1039 err = n umpy.zeros(len(other.data))1039 err = np.zeros(len(other.data)) 1040 1040 return err, err_other 1041 1041 … … 1049 1049 # First, check the data compatibility 1050 1050 dy, dy_other = self._validity_check(other) 1051 result = self.clone_without_data(n umpy.size(self.data))1051 result = self.clone_without_data(np.size(self.data)) 1052 1052 if self.dqx_data == None or self.dqy_data == None: 1053 1053 result.dqx_data = None 1054 1054 result.dqy_data = None 1055 1055 else: 1056 result.dqx_data = n umpy.zeros(len(self.data))1057 result.dqy_data = n umpy.zeros(len(self.data))1058 for i in range(n umpy.size(self.data)):1056 result.dqx_data = np.zeros(len(self.data)) 1057 result.dqy_data = np.zeros(len(self.data)) 1058 for i in range(np.size(self.data)): 1059 1059 result.data[i] = self.data[i] 1060 1060 if self.err_data is not None and \ 1061 numpy.size(self.data) == numpy.size(self.err_data):1061 np.size(self.data) == np.size(self.err_data): 1062 1062 result.err_data[i] = self.err_data[i] 1063 1063 if self.dqx_data is not None: … … 1118 1118 # First, check the data compatibility 1119 1119 self._validity_check_union(other) 1120 result = self.clone_without_data(n umpy.size(self.data) + \1121 n umpy.size(other.data))1120 result = self.clone_without_data(np.size(self.data) + \ 1121 np.size(other.data)) 1122 1122 result.xmin = self.xmin 1123 1123 result.xmax = self.xmax … … 1129 1129 result.dqy_data = None 1130 1130 else: 1131 result.dqx_data = n umpy.zeros(len(self.data) + \1132 numpy.size(other.data))1133 result.dqy_data = n umpy.zeros(len(self.data) + \1134 numpy.size(other.data))1135 1136 result.data = n umpy.append(self.data, other.data)1137 result.qx_data = n umpy.append(self.qx_data, other.qx_data)1138 result.qy_data = n umpy.append(self.qy_data, other.qy_data)1139 result.q_data = n umpy.append(self.q_data, other.q_data)1140 result.mask = n umpy.append(self.mask, other.mask)1131 result.dqx_data = np.zeros(len(self.data) + \ 1132 np.size(other.data)) 1133 result.dqy_data = np.zeros(len(self.data) + \ 1134 np.size(other.data)) 1135 1136 result.data = np.append(self.data, other.data) 1137 result.qx_data = np.append(self.qx_data, other.qx_data) 1138 result.qy_data = np.append(self.qy_data, other.qy_data) 1139 result.q_data = np.append(self.q_data, other.q_data) 1140 result.mask = np.append(self.mask, other.mask) 1141 1141 if result.err_data is not None: 1142 result.err_data = n umpy.append(self.err_data, other.err_data)1142 result.err_data = np.append(self.err_data, other.err_data) 1143 1143 if self.dqx_data is not None: 1144 result.dqx_data = n umpy.append(self.dqx_data, other.dqx_data)1144 result.dqx_data = np.append(self.dqx_data, other.dqx_data) 1145 1145 if self.dqy_data is not None: 1146 result.dqy_data = n umpy.append(self.dqy_data, other.dqy_data)1146 result.dqy_data = np.append(self.dqy_data, other.dqy_data) 1147 1147 1148 1148 return result
Note: See TracChangeset
for help on using the changeset viewer.