Changeset 35ac8df in sasview for src/sas/sasgui


Ignore:
Timestamp:
Aug 21, 2018 9:20:27 AM (6 years ago)
Author:
krzywon
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
Children:
c2525bf
Parents:
96d06a4 (diff), ec52ea1 (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.
Message:

Merge branch 'master' into ticket-1111

Location:
src/sas/sasgui
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py

    ra26f67f ra20a255  
    251251            self.bck.Add(self.batch_slicer_button, (iy, ix), (1, 1), 
    252252                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     253            # Help button 
     254 
     255            self.bt_help = wx.Button(self, wx.NewId(), "HELP") 
     256            self.bt_help.SetToolTipString( 
     257                "Help for the slicer parameters and batch slicing.") 
     258            self.bck.Add(self.bt_help, (iy, 1), (1, 1), 
     259                         wx.ALIGN_RIGHT | wx.ADJUST_MINSIZE, 15) 
     260            wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help) 
     261 
    253262            iy += 1 
    254263            self.bck.Add((5, 5), (iy, ix), (1, 1), 
    255264                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 
     265 
    256266        self.bck.Layout() 
    257267        self.bck.Fit(self) 
     
    535545            self.default_value += "_{0}".format(key).split(" [")[0] 
    536546            self.default_value += "-{:.2f}".format(params[key]) 
     547 
     548    def on_help(self, event=None): 
     549        """ 
     550        Opens a help window for the slicer parameters/batch slicing window 
     551        :param event: 
     552        :return: 
     553        """ 
     554        from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     555 
     556        _TreeLocation = "user/sasgui/guiframe/graph_help.html" 
     557        _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
     558                                          "#d-data-averaging", 
     559                                          "Data Explorer Help") 
  • src/sas/sasgui/guiframe/media/graph_help.rst

    r5ed76f8 rde68f78  
    266266 
    267267.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     268.. _d_data_averaging: 
    268269 
    2692702D data averaging 
     
    301302Alternatively, once a 'slicer' is active you can also select the region to 
    302303average by bringing back the *Dataset Menu* and selecting *Edit Slicer 
    303 Parameters*. A dialog window will appear in which you can enter values to 
    304 define a region or select the number of points to plot (*nbins*). 
     304Parameters and Batch Fitting*. A dialog window will appear in which you can 
     305enter values to define a region, select the number of points to plot (*nbins*), 
     306or apply the slicer to any or all other 2D data plots. 
    305307 
    306308A separate plot window will also have appeared, displaying the requested 
     
    315317 
    316318To remove a 'slicer', bring back the *Dataset menu* and select *Clear Slicer*. 
     319 
     320Batch Slicing 
     321^^^^^^^^^^^^^ 
     322 
     323A slicer can be applied to any or all existing 2D data plots using the 'Slicer 
     324Parameters' window. To open the window, select *Edit Slicer Parameters and Batch 
     325Fitting* in the *Dataset Menu* (see Invoking_the_dataset_menu_). Batch slicing 
     326options are available at the bottom of the window. 
     327 
     328Select the 2D plots you want to apply the slicer to. All 2D plots are selected 
     329by default. The resulting 1D data for all slicers can be saved as a text file 
     330and then sent to fitting by selecting the *Auto save generated 1D* check box. 
     331Sending data to the fitting perspective requires the data be saved. 
     332 
     333Once the auto save check box is selected, you can select where the files are 
     334saved. The file name for the saved data is the slicer name plus the file name 
     335of the original data set, plus what is in the *Append to file name* field. The 
     336default value in the append to field includes the names and values for all of 
     337the slicer parameters. 
     338 
     339The batch of slices can be sent to fitting if desired, with three options 
     340available. The first is to not fit the data, the second is to send the 
     341slices to individual fit pages, and the third is to send all sliced data to a 
     342single batch fit window. 
     343 
     344Clicking *Apply Slicer to Selected Plots* will create a slicer for each selected 
     345plot with the parameters entered in the 'Slicer Parameters' window. Depending on 
     346the options selected the data may then be saved, loaded as separate data sets in 
     347the data manager panel, and finally sent to fitting. 
    317348 
    318349Unmasked circular average 
  • src/sas/sasgui/perspectives/calculator/pyconsole.py

    r4627657 re2663b7  
    2828    Check that the model on the path can run. 
    2929    """ 
     30    # TODO: fix model caching 
     31    # model_test.run_one() is directly forcing a reload of the module, but 
     32    # sasview_model is caching models that have already been loaded. 
     33    # If the sasview load happens before the test, then the module is 
     34    # reloaded out from under it, which causes the global variables in 
     35    # the model function definitions to be cleared (at least in python 2.7). 
     36    # To fix the proximal problem of models failing on test, perform the 
     37    # run_one() tests first.  To fix the deeper problem we should either 
     38    # remove caching from sasmodels.sasview_model.load_custom_model() or 
     39    # add caching to sasmodels.custom.load_custom_kernel_module().  Another 
     40    # option is to add a runTests method to SasviewModel which runs the 
     41    # test suite directly from the model info structure.  Probably some 
     42    # combination of options: 
     43    #    (1) have this function (check_model) operate on a loaded model 
     44    #    so that caching isn't needed in sasview_models.load_custom_model 
     45    #    (2) add the runTests method to SasviewModel so that tests can 
     46    #    be run on a loaded module. 
     47    # 
     48    # Also, note that the model test suite runs the equivalent of the 
     49    # "try running the model" block below, and doesn't need to be run 
     50    # twice.  The reason for duplicating the block here is to generate 
     51    # an exception that show_model_output can catch.  Need to write the 
     52    # runTests method so that it returns success flag as well as output 
     53    # string so that the extra test is not necessary. 
     54 
     55    # check the model's unit tests run 
     56    from sasmodels.model_test import run_one 
     57    result = run_one(path) 
     58 
     59    # remove cached version of the model, if any 
     60    from sasmodels import sasview_model 
     61    sasview_model.MODEL_BY_PATH.pop(path, None) 
     62 
    3063    # try running the model 
    31     from sasmodels.sasview_model import load_custom_model 
    32     Model = load_custom_model(path) 
     64    Model = sasview_model.load_custom_model(path) 
    3365    model = Model() 
    3466    q =  np.array([0.01, 0.1]) 
     
    3668    qx, qy =  np.array([0.01, 0.01]), np.array([0.1, 0.1]) 
    3769    Iqxy = model.evalDistribution([qx, qy]) 
    38  
    39     # check the model's unit tests run 
    40     from sasmodels.model_test import run_one 
    41     result = run_one(path) 
    4270 
    4371    return result 
  • src/sas/sasgui/perspectives/calculator/slit_length_calculator_panel.py

    r7432acb rd788619  
    248248            Complete the loading and compute the slit size 
    249249        """ 
     250        if isinstance(data, list): 
     251            data = data[0] 
    250252        if data is None or data.__class__.__name__ == 'Data2D': 
    251253            if self.parent.parent is None: 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    rc192960 r8a51dea0  
    25522552            # draw 
    25532553            self._draw_model() 
     2554            self.Layout() 
    25542555            self.Refresh() 
    25552556        except Exception: 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    ra7c6f38 rdabcaf7  
    706706 
    707707                        ix = 3 
    708                         ctl2 = wx.TextCtrl(self, wx.ID_ANY, 
    709                                            size=(_BOX_WIDTH / 1.3, 20), 
    710                                            style=0) 
     708                        ctl2 = BGTextCtrl(self, wx.ID_ANY, 
     709                                           size=(_BOX_WIDTH / 1.3, 20)) 
    711710 
    712711                        self.sizer4_4.Add(ctl2, (iy, ix), (1, 1), 
     
    19981997        self.on_smear_helper() 
    19991998        self.on_set_focus(None) 
     1999        self.Layout() 
    20002000        self.Refresh() 
    20012001        # update model plot with new data information 
     
    28922892                        text2.Hide() 
    28932893                    ix += 1 
    2894                     ctl2 = wx.TextCtrl(self, wx.ID_ANY, 
    2895                                        size=(_BOX_WIDTH / 1.2, 20), style=0) 
     2894                    ctl2 = BGTextCtrl(self, wx.ID_ANY, 
     2895                                       size=(_BOX_WIDTH / 1.2, 20)) 
    28962896                    sizer.Add(ctl2, (iy, ix), (1, 1), 
    28972897                              wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
  • src/sas/sasgui/guiframe/gui_manager.py

    rb963b20 rb799f09  
    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 
     
    24222423        default_name = fname 
    24232424        wildcard = "Text files (*.txt)|*.txt|"\ 
    2424                     "CanSAS 1D files(*.xml)|*.xml" 
    2425         path = None 
     2425                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2426                     "NXcanSAS files (*.h5)|*.h5|" 
     2427        options = {0: ".txt", 
     2428                   1: ".xml", 
     2429                   2: ".h5"} 
    24262430        dlg = wx.FileDialog(self, "Choose a file", 
    24272431                            self._default_save_location, 
     
    24332437            # This is MAC Fix 
    24342438            ext_num = dlg.GetFilterIndex() 
    2435             if ext_num == 0: 
    2436                 ext_format = '.txt' 
    2437             else: 
    2438                 ext_format = '.xml' 
     2439 
     2440            ext_format = options[ext_num] 
    24392441            path = os.path.splitext(path)[0] + ext_format 
    24402442            mypath = os.path.basename(path) 
    2441  
    2442             # Instantiate a loader 
    2443             loader = Loader() 
    2444             ext_format = ".txt" 
    2445             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2443            fName = os.path.splitext(path)[0] + ext_format 
     2444 
     2445            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24462446                # Make sure the ext included in the file name 
    24472447                # especially on MAC 
    2448                 fName = os.path.splitext(path)[0] + ext_format 
    24492448                self._onsaveTXT(data, fName) 
    2450             ext_format = ".xml" 
    2451             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2449            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24522450                # Make sure the ext included in the file name 
    24532451                # especially on MAC 
    2454                 fName = os.path.splitext(path)[0] + ext_format 
     2452                # Instantiate a loader 
     2453                loader = Loader() 
    24552454                loader.save(fName, data, ext_format) 
     2455            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2456                nxcansaswriter = NXcanSASWriter() 
     2457                nxcansaswriter.write([data], fName) 
    24562458            try: 
    24572459                self._default_save_location = os.path.dirname(path) 
     
    25652567        """ 
    25662568        default_name = fname 
    2567         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2569        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2570                   "NXcanSAS files (*.h5)|*.h5|" 
    25682571        dlg = wx.FileDialog(self, "Choose a file", 
    25692572                            self._default_save_location, 
     
    25772580            if ext_num == 0: 
    25782581                ext_format = '.dat' 
     2582            elif ext_num == 1: 
     2583                ext_format = '.h5' 
    25792584            else: 
    25802585                ext_format = '' 
     
    25842589            # Instantiate a loader 
    25852590            loader = Loader() 
    2586  
    2587             ext_format = ".dat" 
    2588             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2591            if os.path.splitext(mypath)[1].lower() == '.dat': 
    25892592                # Make sure the ext included in the file name 
    25902593                # especially on MAC 
    25912594                fileName = os.path.splitext(path)[0] + ext_format 
    25922595                loader.save(fileName, data, ext_format) 
     2596            elif os.path.splitext(mypath)[1].lower() == '.h5': 
     2597                # Make sure the ext included in the file name 
     2598                # especially on MAC 
     2599                fileName = os.path.splitext(path)[0] + ext_format 
     2600                nxcansaswriter = NXcanSASWriter() 
     2601                nxcansaswriter.write([data], fileName) 
    25932602            try: 
    25942603                self._default_save_location = os.path.dirname(path) 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    r2924532 r02c1608e  
    239239            self.load_complete(output=output, message="Loading data complete!", 
    240240                               info="info") 
    241         else: 
    242             self.load_complete(output=None, message=error_message, info="error") 
    243241 
    244242    def load_update(self, message="", info="warning"): 
Note: See TracChangeset for help on using the changeset viewer.