Changeset 69363c7 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Sep 22, 2017 10:29:48 AM (7 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r277257f r69363c7 1881 1881 if models.name != "NoStructure": 1882 1882 mlist.append((models.name, models)) 1883 1884 1883 # Sort the models 1885 1884 mlist_sorted = sorted(mlist) … … 2823 2822 def _on_mag_angle_help(self, event): 2824 2823 """ 2825 Bring up Magnetic Angle definition bmpimage whenever the ? button2824 Bring up Magnetic Angle definition.png image whenever the ? button 2826 2825 is clicked. Calls DocumentationWindow with the path of the location 2827 2826 within the documentation tree (after /doc/ ....". When using old … … 2837 2836 """ 2838 2837 2839 _TreeLocation = "_images/M_angles_pic. bmp"2838 _TreeLocation = "_images/M_angles_pic.png" 2840 2839 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2841 2840 "Magnetic Angle Defintions") … … 2843 2842 def _on_mag_help(self, event): 2844 2843 """ 2845 Bring up Magnetic Angle definition bmpimage whenever the ? button2844 Bring up Magnetic Angle definition.png image whenever the ? button 2846 2845 is clicked. Calls DocumentationWindow with the path of the location 2847 2846 within the documentation tree (after /doc/ ....". When using old … … 2963 2962 return False 2964 2963 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 2965 2999 def get_copy_excel(self): 2966 3000 """ … … 2976 3010 Get the string copies of the param names and values in the tap 2977 3011 """ 3012 if not self.parameters: 3013 # Do nothing if parameters doesn't exist 3014 return False 3015 2978 3016 content = '' 2979 2980 3017 crlf = chr(13) + chr(10) 2981 3018 tab = chr(9) 2982 3019 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" 2988 3030 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() 2990 3048 content += tab 2991 3049 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 3004 3051 3005 3052 def get_copy_latex(self): … … 3016 3063 Get the string copies of the param names and values in the tap 3017 3064 """ 3065 if not self.parameters: 3066 # Do nothing if self.parameters doesn't exist 3067 return False 3068 3018 3069 content = r'\begin{table}' 3019 3070 content += r'\begin{tabular}[h]' … … 3022 3073 tab = chr(9) 3023 3074 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 3035 3089 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: 3045 3092 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 3057 3120 3058 3121 def set_clipboard(self, content=None):
Note: See TracChangeset
for help on using the changeset viewer.