Changeset 6eb02a5 in sasview
- Timestamp:
- Jan 15, 2018 6:11:57 PM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e110cb0
- Parents:
- a40e913 (diff), a0f4768 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Paul Butler <butlerpd@…> (01/15/18 18:11:57)
- git-committer:
- GitHub <noreply@…> (01/15/18 18:11:57)
- Files:
-
- 7 added
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
installers/installer_generator.py
r460d3a1 ra0f4768 9 9 import sys 10 10 import string 11 12 is_64bit = sys.maxsize > 2**32 11 13 12 14 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) … … 25 27 AppSupportURL = local_config._homepage 26 28 AppUpdatesURL = local_config._homepage 29 ArchitecturesInstallIn64BitMode = 'x64' 27 30 ChangesEnvironment = 'true' 28 31 DefaultDirName = os.path.join("{pf}" , AppName+Dev) … … 343 346 TEMPLATE += "AppSupportURL=%s\n" % str(AppSupportURL) 344 347 TEMPLATE += "AppUpdatesURL=%s \n" % str(AppUpdatesURL) 348 if is_64bit: 349 TEMPLATE += "ArchitecturesInstallIn64BitMode=%s \n" % str(ArchitecturesInstallIn64BitMode) 345 350 TEMPLATE += "ChangesEnvironment=%s \n" % str(ChangesEnvironment) 346 351 TEMPLATE += "DefaultDirName=%s\n" % str(DefaultDirName) -
.gitignore
r948484f r1b605fb 29 29 default_categories.json 30 30 /setup.cfg 31 Thumbs.db 31 32 32 33 # doc build -
installers/sasview.spec
- Property mode changed from 100755 to 100644
-
installers/version.txt
- Property mode changed from 100755 to 100644
-
src/sas/sascalc/dataloader/file_reader_base_class.py
r3053a4a ra58b5a0 7 7 import os 8 8 import sys 9 import re9 import math 10 10 import logging 11 11 from abc import abstractmethod … … 25 25 def decode(s): 26 26 return s.decode() if isinstance(s, bytes) else s 27 28 # Data 1D fields for iterative purposes 29 FIELDS_1D = ('x', 'y', 'dx', 'dy', 'dxl', 'dxw') 30 # Data 2D fields for iterative purposes 31 FIELDS_2D = ('data', 'qx_data', 'qy_data', 'q_data', 'err_data', 32 'dqx_data', 'dqy_data', 'mask') 33 27 34 28 35 class FileReader(object): … … 102 109 self.current_dataset = None 103 110 self.filepath = None 111 self.ind = None 104 112 self.output = [] 105 113 … … 159 167 # Sort data by increasing x and remove 1st point 160 168 ind = np.lexsort((data.y, data.x)) 161 data.x = np.asarray([data.x[i] for i in ind]).astype(np.float64)162 data.y = np.asarray([data.y[i] for i in ind]).astype(np.float64)169 data.x = self._reorder_1d_array(data.x, ind) 170 data.y = self._reorder_1d_array(data.y, ind) 163 171 if data.dx is not None: 164 172 if len(data.dx) == 0: 165 173 data.dx = None 166 174 continue 167 data.dx = np.asarray([data.dx[i] for i in ind]).astype(np.float64)175 data.dx = self._reorder_1d_array(data.dx, ind) 168 176 if data.dxl is not None: 169 data.dxl = np.asarray([data.dxl[i] for i in ind]).astype(np.float64)177 data.dxl = self._reorder_1d_array(data.dxl, ind) 170 178 if data.dxw is not None: 171 data.dxw = np.asarray([data.dxw[i] for i in ind]).astype(np.float64)179 data.dxw = self._reorder_1d_array(data.dxw, ind) 172 180 if data.dy is not None: 173 181 if len(data.dy) == 0: 174 182 data.dy = None 175 183 continue 176 data.dy = np.asarray([data.dy[i] for i in ind]).astype(np.float64)184 data.dy = self._reorder_1d_array(data.dy, ind) 177 185 if data.lam is not None: 178 data.lam = np.asarray([data.lam[i] for i in ind]).astype(np.float64)186 data.lam = self._reorder_1d_array(data.lam, ind) 179 187 if data.dlam is not None: 180 data.dlam = np.asarray([data.dlam[i] for i in ind]).astype(np.float64) 188 data.dlam = self._reorder_1d_array(data.dlam, ind) 189 data = self._remove_nans_in_data(data) 181 190 if len(data.x) > 0: 182 191 data.xmin = np.min(data.x) … … 184 193 data.ymin = np.min(data.y) 185 194 data.ymax = np.max(data.y) 195 196 @staticmethod 197 def _reorder_1d_array(array, ind): 198 """ 199 Reorders a 1D array based on the indices passed as ind 200 :param array: Array to be reordered 201 :param ind: Indices used to reorder array 202 :return: reordered array 203 """ 204 array = np.asarray(array, dtype=np.float64) 205 return array[ind] 206 207 @staticmethod 208 def _remove_nans_in_data(data): 209 """ 210 Remove data points where nan is loaded 211 :param data: 1D or 2D data object 212 :return: data with nan points removed 213 """ 214 if isinstance(data, Data1D): 215 fields = FIELDS_1D 216 elif isinstance(data, Data2D): 217 fields = FIELDS_2D 218 else: 219 return data 220 # Make array of good points - all others will be removed 221 good = np.isfinite(getattr(data, fields[0])) 222 for name in fields[1:]: 223 array = getattr(data, name) 224 if array is not None: 225 # Update good points only if not already changed 226 good &= np.isfinite(array) 227 if not np.all(good): 228 for name in fields: 229 array = getattr(data, name) 230 if array is not None: 231 setattr(data, name, array[good]) 232 return data 186 233 187 234 def sort_two_d_data(self): … … 214 261 dataset.x_bins = dataset.qx_data[:int(n_cols)] 215 262 dataset.data = dataset.data.flatten() 263 dataset = self._remove_nans_in_data(dataset) 216 264 if len(dataset.data) > 0: 217 265 dataset.xmin = np.min(dataset.qx_data) -
src/sas/sascalc/dataloader/readers/abs_reader.py
r1efbc190 re3775c6 29 29 type_name = "IGOR 1D" 30 30 # Wildcards 31 type = ["IGOR 1D files (*.abs)|*.abs" ]31 type = ["IGOR 1D files (*.abs)|*.abs", "IGOR 1D USANS files (*.cor)|*.cor"] 32 32 # List of allowed extensions 33 ext = ['.abs' ]33 ext = ['.abs', '.cor'] 34 34 35 35 def get_file_contents(self): … … 46 46 self.current_datainfo = DataInfo() 47 47 self.current_datainfo.filename = filepath 48 self.reset_data_list(len(lines))49 48 detector = Detector() 50 49 data_line = 0 … … 188 187 self.current_dataset.y[data_line] = _y 189 188 self.current_dataset.dy[data_line] = _dy 190 self.current_dataset.dx[data_line] = _dx 189 if _dx > 0: 190 self.current_dataset.dx[data_line] = _dx 191 else: 192 if data_line == 0: 193 self.current_dataset.dx = None 194 self.current_dataset.dxl = np.zeros(len(lines)) 195 self.current_dataset.dxw = np.zeros(len(lines)) 196 self.current_dataset.dxl[data_line] = abs(_dx) 197 self.current_dataset.dxw[data_line] = 0 191 198 data_line += 1 192 199 … … 197 204 pass 198 205 206 # SANS Data: 199 207 # The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. 200 208 # I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor| 201 if line.count("The 6 columns") > 0: 209 # USANS Data: 210 # EMP LEVEL: <value> ; BKG LEVEL: <value> 211 if line.startswith("The 6 columns") or line.startswith("EMP LEVEL"): 202 212 is_data_started = True 203 213 -
src/sas/sascalc/dataloader/readers/associations.py
r574adc7 ra32c19c 26 26 ".dat": "red2d_reader", 27 27 ".abs": "abs_reader", 28 ".cor": "abs_reader", 28 29 ".sans": "danse_reader", 29 30 ".pdh": "anton_paar_saxs_reader" -
src/sas/sasgui/perspectives/fitting/fitting.py
- Property mode changed from 100755 to 100644
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r20fa5fe r42a6e02 8 8 ''' 9 9 10 import logging 10 11 import os 11 12 import sys 12 import warnings13 13 import wx 14 14 import sasmodels 15 15 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 16 17 logger = logging.getLogger(__name__) 16 18 17 19 … … 168 170 platforms = cl.get_platforms() 169 171 except ImportError: 170 warnings.warn("pyopencl import failed. Using only CPU computations") 172 logger.warn("Unable to import the pyopencl package. It may not " 173 "have been installed. If you wish to use OpenCL, try " 174 "running pip install --user pyopencl") 175 except cl.LogicError as err: 176 logger.warn("Unable to fetch the OpenCL platforms. This likely " 177 "means that the opencl drivers for your system are " 178 "not installed.") 179 logger.warn(err) 171 180 172 181 p_index = 0 -
src/sas/sasview/images/dls_logo.png
- Property mode changed from 100755 to 100644
-
src/sas/sasview/images/tudelft_logo.png
- Property mode changed from 100755 to 100644
-
src/sas/sasview/test/1d_data/saxess_example.pdh
- Property mode changed from 100755 to 100644
-
test/sasdataloader/test/utest_abs_reader.py
rf53d684 rfa749b7 75 75 data = Loader().load(find("jan08002.ABS")) 76 76 self.assertEqual(data[0].meta_data['loader'], "IGOR 1D") 77 78 def test_usans_negative_dxl(self): 79 data_abs = Loader().load(find("sam14_cor.ABS")) 80 data_cor = Loader().load(find("sam14_cor.cor")) 81 for i in range(0, len(data_abs) - 1): 82 self.assertEquals(data_abs.x[i], data_cor.x[i]) 83 self.assertEquals(data_abs.y[i], data_cor.y[i]) 84 self.assertEquals(data_abs.dxl[i], data_cor.dxl[i]) 85 self.assertEquals(data_abs.dxw[i], data_cor.dxw[i]) 86 self.assertTrue(data_abs.dxl > 0) 87 77 88 78 89 class DanseReaderTests(unittest.TestCase): -
test/sasdataloader/test/utest_ascii.py
rf53d684 rdb5196d 5 5 import os.path 6 6 import warnings 7 import math 7 8 warnings.simplefilter("ignore") 8 9 … … 110 111 self.assertEqual(f, None) 111 112 113 def test_nan_values(self): 114 """ 115 Test loading an ascii data file with nan values saved in x, y, or dy. 116 """ 117 f_1d = self.loader.load(find("nans_in_1d_data.dat"))[0] 118 f_2d = self.loader.load(find("nans_in_2d_data.DAT"))[0] 119 for i in range(0, len(f_1d.x) - 1): 120 self.assertFalse(math.isnan(f_1d.x[i])) 121 self.assertFalse(math.isnan(f_1d.y[i])) 122 self.assertFalse(math.isnan(f_1d.dy[i])) 123 f_2d.data = f_2d.data.flatten() 124 f_2d.qx_data = f_2d.qx_data.flatten() 125 f_2d.qy_data = f_2d.qy_data.flatten() 126 for i in range(0, len(f_2d.data) - 1): 127 self.assertFalse(math.isnan(f_2d.data[i])) 128 self.assertFalse(math.isnan(f_2d.qx_data[i])) 129 self.assertFalse(math.isnan(f_2d.qy_data[i])) 130 131 112 132 if __name__ == '__main__': 113 133 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.