Changeset 57be490 in sasview for src/sas/qtgui/Perspectives/Fitting


Ignore:
Timestamp:
May 17, 2018 2:50:09 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, 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
Children:
085e3c9d
Parents:
976978b
git-author:
Piotr Rozyczko <rozyczko@…> (04/13/18 07:34:43)
git-committer:
Piotr Rozyczko <rozyczko@…> (05/17/18 02:50:09)
Message:

Merged ESS_GUI_reporting

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r3b3b40b r57be490  
    3737        self.maxIndex = 0 
    3838 
    39         # Index of the current tab 
    40         self.currentTab = 0 
     39        ## Index of the current tab 
     40        #self.currentTab = 0 
    4141 
    4242        # The default optimizer 
     
    318318 
    319319        pass 
     320 
     321    @property 
     322    def currentTab(self): 
     323        """ 
     324        Returns the tab widget currently shown 
     325        """ 
     326        return self.currentWidget() 
     327 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rb5cc06e r57be490  
    6868    multishell_parameters = getIterParams(parameters) 
    6969    multishell_param_name, _ = getMultiplicity(parameters) 
     70 
    7071    if is2D: 
    7172        params = [p for p in parameters.kernel_parameters if p.type != 'magnetic'] 
     
    443444 
    444445 
     446def getStandardParam(model=None): 
     447    """ 
     448    Returns a list with standard parameters for the current model 
     449    """ 
     450    param = [] 
     451    num_rows = model.rowCount() 
     452    if num_rows < 1: 
     453        return None 
     454 
     455    for row in range(num_rows): 
     456        param_name = model.item(row, 0).text() 
     457        checkbox_state = model.item(row,0).checkState() == QtCore.Qt.Checked 
     458        value= model.item(row, 1).text() 
     459        column_shift = 0 
     460        if model.columnCount() == 5: # no error column 
     461            error_state = False 
     462            error_value = 0.0 
     463        else: 
     464            error_state = True 
     465            error_value = model.item(row, 2).text() 
     466            column_shift = 1 
     467        min_state = True 
     468        max_state = True 
     469        min_value = model.item(row, 2+column_shift).text() 
     470        max_value = model.item(row, 3+column_shift).text() 
     471        unit = "" 
     472        if model.item(row, 4+column_shift) is not None: 
     473            unit = model.item(row, 4+column_shift).text() 
     474 
     475        param.append([checkbox_state, param_name, value, "", 
     476                        [error_state, error_value], 
     477                        [min_state, min_value], 
     478                        [max_state, max_value], unit]) 
     479 
     480    return param 
     481 
     482def getOrientationParam(kernel_module=None): 
     483    """ 
     484    Get the dictionary with orientation parameters 
     485    """ 
     486    param = [] 
     487    if kernel_module is None:  
     488        return None 
     489    for param_name in list(kernel_module.params.keys()): 
     490        name = param_name 
     491        value = kernel_module.params[param_name] 
     492        min_state = True 
     493        max_state = True 
     494        error_state = False 
     495        error_value = 0.0 
     496        checkbox_state = True #?? 
     497        details = kernel_module.details[param_name] #[unit, mix, max] 
     498        param.append([checkbox_state, name, value, "", 
     499                     [error_state, error_value], 
     500                     [min_state, details[1]], 
     501                     [max_state, details[2]], details[0]]) 
     502 
     503    return param 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    raed0532 r57be490  
    11import json 
    22import os 
     3import copy 
    34from collections import defaultdict 
    45 
     
    2122 
    2223from sas.sascalc.fit.BumpsFitting import BumpsFit as Fit 
     24from sas.sascalc.fit.pagestate import PageState 
    2325 
    2426import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    4547from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
    4648from sas.qtgui.Perspectives.Fitting.MultiConstraint import MultiConstraint 
     49from sas.qtgui.Perspectives.Fitting.ReportPageLogic import ReportPageLogic 
     50 
    4751 
    4852 
     
    506510        # Signals from other widgets 
    507511        self.communicate.customModelDirectoryChanged.connect(self.onCustomModelChange) 
     512        self.communicate.saveAnalysisSignal.connect(self.savePageState) 
     513        #self.communicate.saveReportSignal.connect(self.saveReport) 
    508514 
    509515    def modelName(self): 
     
    26332639            self.page_stack.pop() 
    26342640 
     2641    def getReport(self): 
     2642        """ 
     2643        Create and return HTML report with parameters and charts 
     2644        """ 
     2645        index = None 
     2646        if self.all_data: 
     2647            index = self.all_data[self.data_index] 
     2648        report_logic = ReportPageLogic(self, 
     2649                                       kernel_module=self.kernel_module, 
     2650                                       data=self.data, 
     2651                                       index=index, 
     2652                                       model=self._model_model) 
     2653 
     2654        return report_logic.reportList() 
     2655 
     2656    def savePageState(self): 
     2657        """ 
     2658        Create and serialize local PageState 
     2659        """ 
     2660        from sas.sascalc.fit.pagestate import Reader 
     2661        model = self.kernel_module 
     2662 
     2663        # Old style PageState object 
     2664        state = PageState(model=model, data=self.data) 
     2665 
     2666        # Add parameter data to the state 
     2667        self.getCurrentFitState(state) 
     2668 
     2669        # Create the filewriter, aptly named 'Reader' 
     2670        state_reader = Reader(self.loadPageStateCallback) 
     2671        filepath = self.saveAsAnalysisFile() 
     2672        if filepath is None: 
     2673            return 
     2674        state_reader.write(filename=filepath, fitstate=state) 
     2675        pass 
     2676 
     2677    def saveAsAnalysisFile(self): 
     2678        """ 
     2679        Show the save as... dialog and return the chosen filepath 
     2680        """ 
     2681        default_name = "FitPage"+str(self.tab_id)+".fitv" 
     2682 
     2683        wildcard = "fitv files (*.fitv)" 
     2684        kwargs = { 
     2685            'caption'   : 'Save As', 
     2686            'directory' : default_name, 
     2687            'filter'    : wildcard, 
     2688            'parent'    : None, 
     2689        } 
     2690        # Query user for filename. 
     2691        filename_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 
     2692        filename = filename_tuple[0] 
     2693        return filename 
     2694 
     2695    def loadPageStateCallback(self,state=None, datainfo=None, format=None): 
     2696        """ 
     2697        This is a callback method called from the CANSAS reader. 
     2698        We need the instance of this reader only for writing out a file, 
     2699        so there's nothing here. 
     2700        Until Load Analysis is implemented, that is. 
     2701        """ 
     2702        pass 
     2703 
     2704    def loadPageState(self, pagestate=None): 
     2705        """ 
     2706        Load the PageState object and update the current widget 
     2707        """ 
     2708        pass 
     2709 
     2710    def getCurrentFitState(self, state=None): 
     2711        """ 
     2712        Store current state for fit_page 
     2713        """ 
     2714        # save model option 
     2715        #if self.model is not None: 
     2716        #    self.disp_list = self.getDispParamList() 
     2717        #    state.disp_list = copy.deepcopy(self.disp_list) 
     2718        #    #state.model = self.model.clone() 
     2719 
     2720        # Comboboxes 
     2721        state.categorycombobox = self.cbCategory.currentText() 
     2722        state.formfactorcombobox = self.cbModel.currentText() 
     2723        if self.cbStructureFactor.isEnabled(): 
     2724            state.structureCombobox = self.cbStructureFactor.currentText() 
     2725        state.tcChi = self.chi2 
     2726 
     2727        state.enable2D = self.is2D 
     2728 
     2729        #state.weights = copy.deepcopy(self.weights) 
     2730        # save data 
     2731        state.data = copy.deepcopy(self.data) 
     2732 
     2733        # save plotting range 
     2734        state.qmin = self.q_range_min 
     2735        state.qmax = self.q_range_max 
     2736        state.npts = self.npts 
     2737 
     2738        #    self.state.enable_disp = self.enable_disp.GetValue() 
     2739        #    self.state.disable_disp = self.disable_disp.GetValue() 
     2740 
     2741        #    self.state.enable_smearer = \ 
     2742        #                        copy.deepcopy(self.enable_smearer.GetValue()) 
     2743        #    self.state.disable_smearer = \ 
     2744        #                        copy.deepcopy(self.disable_smearer.GetValue()) 
     2745 
     2746        #self.state.pinhole_smearer = \ 
     2747        #                        copy.deepcopy(self.pinhole_smearer.GetValue()) 
     2748        #self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 
     2749        #self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue()) 
     2750        #self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue()) 
     2751        #self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 
     2752        #self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 
     2753 
     2754        p = self.model_parameters 
     2755        # save checkbutton state and txtcrtl values 
     2756        state.parameters = FittingUtilities.getStandardParam() 
     2757        state.orientation_params_disp = FittingUtilities.getOrientationParam() 
     2758 
     2759        #self._copy_parameters_state(self.orientation_params_disp, self.state.orientation_params_disp) 
     2760        #self._copy_parameters_state(self.parameters, self.state.parameters) 
     2761        #self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 
     2762        #self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
     2763 
     2764 
Note: See TracChangeset for help on using the changeset viewer.