Changeset c222c27 in sasview for src/sas/sasgui
- Timestamp:
- Nov 15, 2018 2:09:18 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
- Children:
- 9220e89c
- Parents:
- a165bee (diff), f560e23 (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. - Location:
- src/sas/sasgui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r388aefb r8e109f9 8 8 ''' 9 9 10 import json 11 import platform 10 12 import logging 11 13 import os 12 14 import sys 15 13 16 import wx 17 18 try: 19 import pyopencl as cl 20 except ImportError: 21 cl = None 22 14 23 import sasmodels 24 import sasmodels.model_test 25 import sasmodels.kernelcl 26 15 27 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 16 28 … … 169 181 clinfo = [] 170 182 platforms = [] 171 try: 172 import pyopencl as cl 173 platforms = cl.get_platforms() 174 except ImportError: 183 184 if cl is None: 175 185 logger.warn("Unable to import the pyopencl package. It may not " 176 186 "have been installed. If you wish to use OpenCL, try " 177 187 "running pip install --user pyopencl") 178 except cl.LogicError as err: 179 logger.warn("Unable to fetch the OpenCL platforms. This likely " 180 "means that the opencl drivers for your system are " 181 "not installed.") 182 logger.warn(err) 188 else: 189 try: 190 platforms = cl.get_platforms() 191 except cl.LogicError as err: 192 logger.warn("Unable to fetch the OpenCL platforms. This likely " 193 "means that the opencl drivers for your system are " 194 "not installed.") 195 logger.warn(err) 183 196 184 197 p_index = 0 … … 226 239 if "SAS_OPENCL" in os.environ: 227 240 del os.environ["SAS_OPENCL"] 228 229 #Sasmodels kernelcl doesn't exist when initiated with None 230 if 'sasmodels.kernelcl' in sys.modules: 231 sasmodels.kernelcl.ENV = None 232 233 reload(sasmodels.core) 241 sasmodels.kernelcl.reset_environment() 234 242 event.Skip() 235 243 … … 247 255 Run sasmodels check from here and report results from 248 256 """ 249 import json250 import platform251 #import sasmodels252 253 257 #The same block of code as for OK but it is needed if we want to have 254 258 #active response to Test button … … 261 265 if "SAS_OPENCL" in os.environ: 262 266 del os.environ["SAS_OPENCL"] 263 264 #Sasmodels kernelcl doesn't exist when initiated with None 265 if 'sasmodels.kernelcl' in sys.modules: 266 sasmodels.kernelcl.ENV = None 267 268 269 #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 270 reload(sasmodels.core) 271 272 273 from sasmodels.model_test import model_tests 267 sasmodels.kernelcl.reset_environment() 274 268 275 269 try: 276 from sasmodels.kernelcl import environment 277 env = environment() 270 env = sasmodels.kernelcl.environment() 278 271 clinfo = [(ctx.devices[0].platform.vendor, 279 272 ctx.devices[0].platform.version, … … 282 275 ctx.devices[0].version) 283 276 for ctx in env.context] 284 except ImportError:277 except Exception: 285 278 clinfo = None 286 279 287 280 failures = [] 288 281 tests_completed = 0 289 for test in model_tests():282 for test in sasmodels.model_test.model_tests(): 290 283 try: 291 284 test() -
src/sas/sasgui/guiframe/gui_manager.py
r8ac05a5 r9f45f83 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 2419 2420 default_name = fname 2420 2421 wildcard = "Text files (*.txt)|*.txt|"\ 2421 "CanSAS 1D files(*.xml)|*.xml" 2422 path = None 2422 "CanSAS 1D files (*.xml)|*.xml|"\ 2423 "NXcanSAS files (*.h5)|*.h5|" 2424 options = [".txt", ".xml",".h5"] 2423 2425 dlg = wx.FileDialog(self, "Choose a file", 2424 2426 self._default_save_location, … … 2430 2432 # This is MAC Fix 2431 2433 ext_num = dlg.GetFilterIndex() 2432 if ext_num == 0: 2433 ext_format = '.txt' 2434 else: 2435 ext_format = '.xml' 2434 2435 ext_format = options[ext_num] 2436 2436 path = os.path.splitext(path)[0] + ext_format 2437 2437 mypath = os.path.basename(path) 2438 2439 # Instantiate a loader 2440 loader = Loader() 2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2438 fName = os.path.splitext(path)[0] + ext_format 2439 2440 if os.path.splitext(mypath)[1].lower() == options[0]: 2443 2441 # Make sure the ext included in the file name 2444 2442 # especially on MAC 2445 fName = os.path.splitext(path)[0] + ext_format2446 2443 self._onsaveTXT(data, fName) 2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2444 elif os.path.splitext(mypath)[1].lower() == options[1]: 2449 2445 # Make sure the ext included in the file name 2450 2446 # especially on MAC 2451 fName = os.path.splitext(path)[0] + ext_format 2447 # Instantiate a loader 2448 loader = Loader() 2452 2449 loader.save(fName, data, ext_format) 2450 elif os.path.splitext(mypath)[1].lower() == options[2]: 2451 nxcansaswriter = NXcanSASWriter() 2452 nxcansaswriter.write([data], fName) 2453 2453 try: 2454 2454 self._default_save_location = os.path.dirname(path) … … 2477 2477 if has_errors: 2478 2478 if data.dx is not None and data.dx != []: 2479 out.write("<X> <Y> <dY><dX>\n")2479 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2480 2480 else: 2481 out.write("<X> <Y><dY>\n")2481 out.write("<X>\t<Y>\t<dY>\n") 2482 2482 else: 2483 out.write("<X> 2483 out.write("<X>\t<Y>\n") 2484 2484 2485 2485 for i in range(len(data.x)): … … 2525 2525 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2526 2526 text += '\nData Points:\n' 2527 x_st = "X" 2527 text += "<index> \t<X> \t<Y> \t<dY> " 2528 text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 2529 data.dxw is not None) else "\t<dX>\n" 2528 2530 for index in range(len(data.x)): 2529 2531 if data.dy is not None and len(data.dy) > index: … … 2536 2538 dx_val = 0.0 2537 2539 if data.dxl is not None and len(data.dxl) > index: 2538 if index == 0:2539 x_st = "Xl"2540 2540 dx_val = data.dxl[index] 2541 elif data.dxw is not None and len(data.dxw) > index: 2542 if index == 0: 2543 x_st = "Xw" 2544 dx_val = data.dxw[index] 2545 2546 if index == 0: 2547 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2541 if data.dxw is not None and len(data.dxw) > index: 2542 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2543 2548 2544 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2549 2545 data.x[index], … … 2562 2558 """ 2563 2559 default_name = fname 2564 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2560 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2561 "NXcanSAS files (*.h5)|*.h5|" 2565 2562 dlg = wx.FileDialog(self, "Choose a file", 2566 2563 self._default_save_location, … … 2574 2571 if ext_num == 0: 2575 2572 ext_format = '.dat' 2573 elif ext_num == 1: 2574 ext_format = '.h5' 2576 2575 else: 2577 2576 ext_format = '' … … 2581 2580 # Instantiate a loader 2582 2581 loader = Loader() 2583 2584 ext_format = ".dat" 2585 if os.path.splitext(mypath)[1].lower() == ext_format: 2582 if os.path.splitext(mypath)[1].lower() == '.dat': 2586 2583 # Make sure the ext included in the file name 2587 2584 # especially on MAC 2588 2585 fileName = os.path.splitext(path)[0] + ext_format 2589 2586 loader.save(fileName, data, ext_format) 2587 elif os.path.splitext(mypath)[1].lower() == '.h5': 2588 # Make sure the ext included in the file name 2589 # especially on MAC 2590 fileName = os.path.splitext(path)[0] + ext_format 2591 nxcansaswriter = NXcanSASWriter() 2592 nxcansaswriter.write([data], fileName) 2590 2593 try: 2591 2594 self._default_save_location = os.path.dirname(path) -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r9c7e2b8 r5218180 205 205 except NoKnownLoaderException as e: 206 206 exception_occurred = True 207 error_message = "Loading data failed! " + e.message207 error_message = "Loading data failed!\n" + e.message 208 208 file_errors[basename] = [error_message] 209 209 except Exception as e: … … 224 224 for message in error_array: 225 225 error_message += message + "\n" 226 error_message = error_message[:-1] 226 227 self.load_complete(output=output, 227 228 message=error_message, … … 231 232 self.load_complete(output=output, message="Loading data complete!", 232 233 info="info") 233 else:234 self.load_complete(output=None, message=error_message, info="error")235 234 236 235 def load_update(self, message="", info="warning"):
Note: See TracChangeset
for help on using the changeset viewer.