Ignore:
Timestamp:
Sep 22, 2017 10:29:48 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ab0b93f
Parents:
1386b2f (diff), d76c43a (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 Kienzle <pkienzle@…> (09/22/17 10:28:48)
git-committer:
Paul Kienzle <pkienzle@…> (09/22/17 10:29:48)
Message:

Merge branch 'master' into ticket-853-fit-gui-to-calc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r277257f r69363c7  
    18811881            if models.name != "NoStructure": 
    18821882                mlist.append((models.name, models)) 
    1883  
    18841883        # Sort the models 
    18851884        mlist_sorted = sorted(mlist) 
     
    28232822    def _on_mag_angle_help(self, event): 
    28242823        """ 
    2825         Bring up Magnetic Angle definition bmp image whenever the ? button 
     2824        Bring up Magnetic Angle definition.png image whenever the ? button 
    28262825        is clicked. Calls DocumentationWindow with the path of the location 
    28272826        within the documentation tree (after /doc/ ....". When using old 
     
    28372836        """ 
    28382837 
    2839         _TreeLocation = "_images/M_angles_pic.bmp" 
     2838        _TreeLocation = "_images/M_angles_pic.png" 
    28402839        _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 
    28412840                                          "Magnetic Angle Defintions") 
     
    28432842    def _on_mag_help(self, event): 
    28442843        """ 
    2845         Bring up Magnetic Angle definition bmp image whenever the ? button 
     2844        Bring up Magnetic Angle definition.png image whenever the ? button 
    28462845        is clicked. Calls DocumentationWindow with the path of the location 
    28472846        within the documentation tree (after /doc/ ....". When using old 
     
    29632962            return False 
    29642963 
     2964 
     2965    def _get_copy_params_details(self): 
     2966        """ 
     2967        Combines polydisperse parameters with self.parameters so that they can 
     2968        be written to the clipboard (for Excel or LaTeX). Also returns a list of 
     2969        the names of parameters that have been fitted 
     2970 
     2971        :returns: all_params - A list of all parameters, in the format of 
     2972        self.parameters 
     2973        :returns: fitted_par_names - A list of the names of parameters that have 
     2974        been fitted 
     2975        """ 
     2976        # Names of params that are being fitted 
     2977        fitted_par_names = [param[1] for param in self.param_toFit] 
     2978        # Names of params with associated polydispersity 
     2979        disp_params = [param[1].split('.')[0] for param in self.fittable_param] 
     2980 
     2981        # Create array of all parameters 
     2982        all_params = copy.copy(self.parameters) 
     2983        for param in self.parameters: 
     2984            if param[1] in disp_params: 
     2985                # Polydisperse params aren't in self.parameters, so need adding 
     2986                # to all_params 
     2987                name = param[1] + ".width" 
     2988                index = all_params.index(param) + 1 
     2989                to_insert = [] 
     2990                if name in fitted_par_names: 
     2991                    # Param is fitted, so already has a param list in self.param_toFit 
     2992                    to_insert = self.param_toFit[fitted_par_names.index(name)] 
     2993                else: 
     2994                    # Param isn't fitted, so mockup a param list 
     2995                    to_insert = [None, name, self.model.getParam(name), None, None] 
     2996                all_params.insert(index, to_insert) 
     2997        return all_params, fitted_par_names 
     2998 
    29652999    def get_copy_excel(self): 
    29663000        """ 
     
    29763010        Get the string copies of the param names and values in the tap 
    29773011        """ 
     3012        if not self.parameters: 
     3013            # Do nothing if parameters doesn't exist 
     3014            return False 
     3015 
    29783016        content = '' 
    2979  
    29803017        crlf = chr(13) + chr(10) 
    29813018        tab = chr(9) 
    29823019 
    2983         # Do it if params exist 
    2984         if self.parameters: 
    2985  
    2986             for param in self.parameters: 
    2987                 content += param[1]  # parameter name 
     3020        all_params, fitted_param_names = self._get_copy_params_details() 
     3021 
     3022        # Construct row of parameter names 
     3023        for param in all_params: 
     3024            name = param[1] # Parameter name 
     3025            content += name 
     3026            content += tab 
     3027            if name in fitted_param_names: 
     3028                # Only print errors for fitted parameters 
     3029                content += name + "_err" 
    29883030                content += tab 
    2989                 content += param[1] + "_err" 
     3031 
     3032        content += crlf 
     3033 
     3034        # Construct row of parameter values and errors 
     3035        for param in all_params: 
     3036            value = param[2] 
     3037            if hasattr(value, 'GetValue'): 
     3038                # param[2] is a text box 
     3039                value = value.GetValue() 
     3040            else: 
     3041                # param[2] is a float (from our self._get_copy_params_details) 
     3042                value = str(value) 
     3043            content += value 
     3044            content += tab 
     3045            if param[1] in fitted_param_names: 
     3046                # Only print errors for fitted parameters 
     3047                content += param[4].GetValue() 
    29903048                content += tab 
    29913049 
    2992             content += crlf 
    2993  
    2994             # row of values and errors... 
    2995             for param in self.parameters: 
    2996                 content += param[2].GetValue()  # value 
    2997                 content += tab 
    2998                 content += param[4].GetValue()  # error 
    2999                 content += tab 
    3000  
    3001             return content 
    3002         else: 
    3003             return False 
     3050        return content 
    30043051 
    30053052    def get_copy_latex(self): 
     
    30163063        Get the string copies of the param names and values in the tap 
    30173064        """ 
     3065        if not self.parameters: 
     3066            # Do nothing if self.parameters doesn't exist 
     3067            return False 
     3068 
    30183069        content = r'\begin{table}' 
    30193070        content += r'\begin{tabular}[h]' 
     
    30223073        tab = chr(9) 
    30233074 
    3024         # Do it if params exist 
    3025         if self.parameters: 
    3026  
    3027             content += '{|' 
    3028             for param in self.parameters: 
    3029                 content += 'l|l|' 
    3030             content += r'}\hline' 
    3031             content += crlf 
    3032  
    3033             for index, param in enumerate(self.parameters): 
    3034                 content += param[1].replace('_', r'\_')  # parameter name 
     3075        all_params, fitted_param_names = self._get_copy_params_details() 
     3076 
     3077        content += '{|' 
     3078        for param in all_params: 
     3079            content += 'l|l|' 
     3080        content += r'}\hline' 
     3081        content += crlf 
     3082 
     3083        # Construct row of parameter names 
     3084        for index, param in enumerate(all_params): 
     3085            name = param[1] # Parameter name 
     3086            content += name.replace('_', r'\_')  # Escape underscores 
     3087            if name in fitted_param_names: 
     3088                # Only print errors for fitted parameters 
    30353089                content += ' & ' 
    3036                 content += param[1].replace('_', r'\_') + r'\_err' 
    3037                 if index < len(self.parameters) - 1: 
    3038                     content += ' & ' 
    3039             content += r'\\ \hline' 
    3040             content += crlf 
    3041  
    3042             # row of values and errors... 
    3043             for index, param in enumerate(self.parameters): 
    3044                 content += param[2].GetValue()  # parameter value 
     3090                content += name.replace('_', r'\_') + r"\_err" 
     3091            if index < len(all_params) - 1: 
    30453092                content += ' & ' 
    3046                 content += param[4].GetValue()  # parameter error 
    3047                 if index < len(self.parameters) - 1: 
    3048                     content += ' & ' 
    3049             content += r'\\ \hline' 
    3050             content += crlf 
    3051  
    3052             content += r'\end{tabular}' 
    3053             content += r'\end{table}' 
    3054             return content 
    3055         else: 
    3056             return False 
     3093 
     3094        content += r'\\ \hline' 
     3095        content += crlf 
     3096 
     3097        # Construct row of values and errors 
     3098        for index, param in enumerate(all_params): 
     3099            value = param[2] 
     3100            if hasattr(value, "GetValue"): 
     3101                # value is a text box 
     3102                value = value.GetValue() 
     3103            else: 
     3104                # value is a float (from self._get_copy_params_details) 
     3105                value = str(value) 
     3106            content += value 
     3107            if param[1] in fitted_param_names: 
     3108                # Only print errors for fitted params 
     3109                content += ' & ' 
     3110                content += param[4].GetValue() 
     3111            if index < len(all_params) - 1: 
     3112                content += ' & ' 
     3113 
     3114        content += r'\\ \hline' 
     3115        content += crlf 
     3116        content += r'\end{tabular}' 
     3117        content += r'\end{table}' 
     3118 
     3119        return content 
    30573120 
    30583121    def set_clipboard(self, content=None): 
Note: See TracChangeset for help on using the changeset viewer.