Changeset dcd6efd in sasview for src/sas/sasgui


Ignore:
Timestamp:
Jan 2, 2019 3:57:45 PM (5 years ago)
Author:
GitHub <noreply@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
Children:
ef74a8b, a13c41b, 462e019
Parents:
cb9640f (diff), d96744de (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/02/19 15:57:45)
git-committer:
GitHub <noreply@…> (01/02/19 15:57:45)
Message:

Merge pull request #180 from SasView?/ticket-1111

Multiple data loader and writer updates - NXcanSAS compliance, data conversion, saving as NXcanSAS, plus more

Fixes #976
Fixes #1129
Fixes #1111
Fixes #1221

Location:
src/sas/sasgui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/gui_manager.py

    r47be5a1 rdcd6efd  
    4646from sas.sasgui.guiframe.CategoryManager import CategoryManager 
    4747from sas.sascalc.dataloader.loader import Loader 
     48from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
    4849from sas.sasgui.guiframe.proxy import Connection 
    4950 
     
    24072408        default_name = fname 
    24082409        wildcard = "Text files (*.txt)|*.txt|"\ 
    2409                     "CanSAS 1D files(*.xml)|*.xml" 
    2410         path = None 
     2410                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2411                     "NXcanSAS files (*.h5)|*.h5|" 
     2412        options = [".txt", ".xml",".h5"] 
    24112413        dlg = wx.FileDialog(self, "Choose a file", 
    24122414                            self._default_save_location, 
     
    24182420            # This is MAC Fix 
    24192421            ext_num = dlg.GetFilterIndex() 
    2420             if ext_num == 0: 
    2421                 ext_format = '.txt' 
    2422             else: 
    2423                 ext_format = '.xml' 
     2422 
     2423            ext_format = options[ext_num] 
    24242424            path = os.path.splitext(path)[0] + ext_format 
    24252425            mypath = os.path.basename(path) 
    2426  
    2427             # Instantiate a loader 
    2428             loader = Loader() 
    2429             ext_format = ".txt" 
    2430             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2426            fName = os.path.splitext(path)[0] + ext_format 
     2427 
     2428            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24312429                # Make sure the ext included in the file name 
    24322430                # especially on MAC 
    2433                 fName = os.path.splitext(path)[0] + ext_format 
    24342431                self._onsaveTXT(data, fName) 
    2435             ext_format = ".xml" 
    2436             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2432            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24372433                # Make sure the ext included in the file name 
    24382434                # especially on MAC 
    2439                 fName = os.path.splitext(path)[0] + ext_format 
     2435                # Instantiate a loader 
     2436                loader = Loader() 
    24402437                loader.save(fName, data, ext_format) 
     2438            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2439                nxcansaswriter = NXcanSASWriter() 
     2440                nxcansaswriter.write([data], fName) 
    24412441            try: 
    24422442                self._default_save_location = os.path.dirname(path) 
     
    24652465            if has_errors: 
    24662466                if data.dx is not None and data.dx != []: 
    2467                     out.write("<X>   <Y>   <dY>   <dX>\n") 
     2467                    out.write("<X>\t<Y>\t<dY>\t<dX>\n") 
    24682468                else: 
    2469                     out.write("<X>   <Y>   <dY>\n") 
     2469                    out.write("<X>\t<Y>\t<dY>\n") 
    24702470            else: 
    2471                 out.write("<X>   <Y>\n") 
     2471                out.write("<X>\t<Y>\n") 
    24722472 
    24732473            for i in range(len(data.x)): 
     
    25132513            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25142514        text += '\nData Points:\n' 
    2515         x_st = "X" 
     2515        text += "<index> \t<X> \t<Y> \t<dY> " 
     2516        text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 
     2517                                       data.dxw is not None) else "\t<dX>\n" 
    25162518        for index in range(len(data.x)): 
    25172519            if data.dy is not None and len(data.dy) > index: 
     
    25242526                dx_val = 0.0 
    25252527            if data.dxl is not None and len(data.dxl) > index: 
    2526                 if index == 0: 
    2527                     x_st = "Xl" 
    25282528                dx_val = data.dxl[index] 
    2529             elif data.dxw is not None and len(data.dxw) > index: 
    2530                 if index == 0: 
    2531                     x_st = "Xw" 
    2532                 dx_val = data.dxw[index] 
    2533  
    2534             if index == 0: 
    2535                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
     2529                if data.dxw is not None and len(data.dxw) > index: 
     2530                    dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 
     2531 
    25362532            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    25372533                                                  data.x[index], 
     
    25502546        """ 
    25512547        default_name = fname 
    2552         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2548        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2549                   "NXcanSAS files (*.h5)|*.h5|" 
    25532550        dlg = wx.FileDialog(self, "Choose a file", 
    25542551                            self._default_save_location, 
     
    25622559            if ext_num == 0: 
    25632560                ext_format = '.dat' 
     2561            elif ext_num == 1: 
     2562                ext_format = '.h5' 
    25642563            else: 
    25652564                ext_format = '' 
     
    25692568            # Instantiate a loader 
    25702569            loader = Loader() 
    2571  
    2572             ext_format = ".dat" 
    2573             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2570            ext = os.path.splitext(mypath)[1].lower() 
     2571            if ext == '.dat': 
    25742572                # Make sure the ext included in the file name 
    25752573                # especially on MAC 
    25762574                fileName = os.path.splitext(path)[0] + ext_format 
    25772575                loader.save(fileName, data, ext_format) 
     2576            elif ext == '.h5': 
     2577                # Make sure the ext included in the file name 
     2578                # especially on MAC 
     2579                fileName = os.path.splitext(path)[0] + ext_format 
     2580                nxcansaswriter = NXcanSASWriter() 
     2581                nxcansaswriter.write([data], fileName) 
    25782582            try: 
    25792583                self._default_save_location = os.path.dirname(path) 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    r9c7e2b8 r5218180  
    205205            except NoKnownLoaderException as e: 
    206206                exception_occurred = True 
    207                 error_message = "Loading data failed!" + e.message 
     207                error_message = "Loading data failed!\n" + e.message 
    208208                file_errors[basename] = [error_message] 
    209209            except Exception as e: 
     
    224224                for message in error_array: 
    225225                    error_message += message + "\n" 
     226                error_message = error_message[:-1] 
    226227            self.load_complete(output=output, 
    227228                               message=error_message, 
     
    231232            self.load_complete(output=output, message="Loading data complete!", 
    232233                               info="info") 
    233         else: 
    234             self.load_complete(output=None, message=error_message, info="error") 
    235234 
    236235    def load_update(self, message="", info="warning"): 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r9bf40e7 r1752f38  
    965965        out_f.write('    """Absolute scattering"""\n') 
    966966        if "scipy." in func_str: 
    967             out_f.write('    import scipy') 
     967            out_f.write('    import scipy\n') 
    968968        if "numpy." in func_str: 
    969             out_f.write('    import numpy') 
     969            out_f.write('    import numpy\n') 
    970970        if "np." in func_str: 
    971             out_f.write('    import numpy as np') 
     971            out_f.write('    import numpy as np\n') 
    972972        for func_line in func_str.split('\n'): 
    973973            out_f.write('%s%s\n' % ('    ', func_line)) 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    raba4559 ra5cffe5  
    776776        :param weight: current dy data 
    777777        """ 
    778         # If we are not dealing with a specific fit problem, then 
    779         # there is no point setting the weights. 
    780         if fid is None: 
    781             return 
     778        # Note: this is used to set the data weights for the fit based on 
     779        # the weight selection in the GUI. 
    782780        if uid in self.page_finder.keys(): 
    783781            self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r8e109f9 r895703d  
    2323import sasmodels 
    2424import sasmodels.model_test 
    25 import sasmodels.kernelcl 
     25import sasmodels.sasview_model 
    2626 
    2727from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     
    239239            if "SAS_OPENCL" in os.environ: 
    240240                del os.environ["SAS_OPENCL"] 
    241         sasmodels.kernelcl.reset_environment() 
     241        sasmodels.sasview_model.reset_environment() 
    242242        event.Skip() 
    243243 
     
    265265            if "SAS_OPENCL" in os.environ: 
    266266                del os.environ["SAS_OPENCL"] 
    267         sasmodels.kernelcl.reset_environment() 
     267        sasmodels.sasview_model.reset_environment() 
    268268 
    269269        try: 
Note: See TracChangeset for help on using the changeset viewer.