Changeset 53b8266 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Sep 23, 2017 3:35:45 PM (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:
- fca1f50, 72d3f1e
- Parents:
- 835937b5 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
raf1187a r53b8266 1872 1872 if models.name != "NoStructure": 1873 1873 mlist.append((models.name, models)) 1874 1875 1874 # Sort the models 1876 1875 mlist_sorted = sorted(mlist) … … 2820 2819 def _on_mag_angle_help(self, event): 2821 2820 """ 2822 Bring up Magnetic Angle definition bmpimage whenever the ? button2821 Bring up Magnetic Angle definition.png image whenever the ? button 2823 2822 is clicked. Calls DocumentationWindow with the path of the location 2824 2823 within the documentation tree (after /doc/ ....". When using old … … 2834 2833 """ 2835 2834 2836 _TreeLocation = "_images/M_angles_pic. bmp"2835 _TreeLocation = "_images/M_angles_pic.png" 2837 2836 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2838 2837 "Magnetic Angle Defintions") … … 2840 2839 def _on_mag_help(self, event): 2841 2840 """ 2842 Bring up Magnetic Angle definition bmpimage whenever the ? button2841 Bring up Magnetic Angle definition.png image whenever the ? button 2843 2842 is clicked. Calls DocumentationWindow with the path of the location 2844 2843 within the documentation tree (after /doc/ ....". When using old … … 2960 2959 return False 2961 2960 2961 2962 def _get_copy_params_details(self): 2963 """ 2964 Combines polydisperse parameters with self.parameters so that they can 2965 be written to the clipboard (for Excel or LaTeX). Also returns a list of 2966 the names of parameters that have been fitted 2967 2968 :returns: all_params - A list of all parameters, in the format of 2969 self.parameters 2970 :returns: fitted_par_names - A list of the names of parameters that have 2971 been fitted 2972 """ 2973 # Names of params that are being fitted 2974 fitted_par_names = [param[1] for param in self.param_toFit] 2975 # Names of params with associated polydispersity 2976 disp_params = [param[1].split('.')[0] for param in self.fittable_param] 2977 2978 # Create array of all parameters 2979 all_params = copy.copy(self.parameters) 2980 for param in self.parameters: 2981 if param[1] in disp_params: 2982 # Polydisperse params aren't in self.parameters, so need adding 2983 # to all_params 2984 name = param[1] + ".width" 2985 index = all_params.index(param) + 1 2986 to_insert = [] 2987 if name in fitted_par_names: 2988 # Param is fitted, so already has a param list in self.param_toFit 2989 to_insert = self.param_toFit[fitted_par_names.index(name)] 2990 else: 2991 # Param isn't fitted, so mockup a param list 2992 to_insert = [None, name, self.model.getParam(name), None, None] 2993 all_params.insert(index, to_insert) 2994 return all_params, fitted_par_names 2995 2962 2996 def get_copy_excel(self): 2963 2997 """ … … 2973 3007 Get the string copies of the param names and values in the tap 2974 3008 """ 3009 if not self.parameters: 3010 # Do nothing if parameters doesn't exist 3011 return False 3012 2975 3013 content = '' 2976 2977 3014 crlf = chr(13) + chr(10) 2978 3015 tab = chr(9) 2979 3016 2980 # Do it if params exist 2981 if self.parameters: 2982 2983 for param in self.parameters: 2984 content += param[1] # parameter name 3017 all_params, fitted_param_names = self._get_copy_params_details() 3018 3019 # Construct row of parameter names 3020 for param in all_params: 3021 name = param[1] # Parameter name 3022 content += name 3023 content += tab 3024 if name in fitted_param_names: 3025 # Only print errors for fitted parameters 3026 content += name + "_err" 2985 3027 content += tab 2986 content += param[1] + "_err" 2987 content += tab 2988 2989 content += crlf 2990 2991 # row of values and errors... 2992 for param in self.parameters: 2993 content += param[2].GetValue() # value 2994 content += tab 2995 content += param[4].GetValue() # error 2996 content += tab 2997 2998 return content 2999 else: 3000 return False 3028 3029 content += crlf 3030 3031 # Construct row of parameter values and errors 3032 for param in all_params: 3033 value = param[2] 3034 if hasattr(value, 'GetValue'): 3035 # param[2] is a text box 3036 value = value.GetValue() 3037 else: 3038 # param[2] is a float (from our self._get_copy_params_details) 3039 value = str(value) 3040 content += value 3041 content += tab 3042 if param[1] in fitted_param_names: 3043 # Only print errors for fitted parameters 3044 content += param[4].GetValue() 3045 content += tab 3046 3047 return content 3001 3048 3002 3049 def get_copy_latex(self): … … 3013 3060 Get the string copies of the param names and values in the tap 3014 3061 """ 3062 if not self.parameters: 3063 # Do nothing if self.parameters doesn't exist 3064 return False 3065 3015 3066 content = '\\begin{table}' 3016 3067 content += '\\begin{tabular}[h]' … … 3019 3070 tab = chr(9) 3020 3071 3021 # Do it if params exist 3022 if self.parameters: 3023 3024 content += '{|' 3025 for param in self.parameters: 3026 content += 'l|l|' 3027 content += '}\hline' 3028 content += crlf 3029 3030 for index, param in enumerate(self.parameters): 3031 content += param[1].replace('_', '\_') # parameter name 3072 all_params, fitted_param_names = self._get_copy_params_details() 3073 3074 content += '{|' 3075 for param in all_params: 3076 content += 'l|l|' 3077 content += '}\hline' 3078 content += crlf 3079 3080 # Construct row of parameter names 3081 for index, param in enumerate(all_params): 3082 name = param[1] # Parameter name 3083 content += name.replace('_', '\_') # Escape underscores 3084 if name in fitted_param_names: 3085 # Only print errors for fitted parameters 3032 3086 content += ' & ' 3033 content += param[1].replace('_', '\_') + "\_err" 3034 if index < len(self.parameters) - 1: 3035 content += ' & ' 3036 content += '\\\\ \\hline' 3037 content += crlf 3038 3039 # row of values and errors... 3040 for index, param in enumerate(self.parameters): 3041 content += param[2].GetValue() # parameter value 3087 content += name.replace('_', '\_') + "\_err" 3088 if index < len(all_params) - 1: 3042 3089 content += ' & ' 3043 content += param[4].GetValue() # parameter error 3044 if index < len(self.parameters) - 1: 3045 content += ' & ' 3046 content += '\\\\ \\hline' 3047 content += crlf 3048 3049 content += '\\end{tabular}' 3050 content += '\\end{table}' 3051 return content 3052 else: 3053 return False 3090 3091 content += '\\\\ \\hline' 3092 content += crlf 3093 3094 # Construct row of values and errors 3095 for index, param in enumerate(all_params): 3096 value = param[2] 3097 if hasattr(value, "GetValue"): 3098 # value is a text box 3099 value = value.GetValue() 3100 else: 3101 # value is a float (from self._get_copy_params_details) 3102 value = str(value) 3103 content += value 3104 if param[1] in fitted_param_names: 3105 # Only print errors for fitted params 3106 content += ' & ' 3107 content += param[4].GetValue() 3108 if index < len(all_params) - 1: 3109 content += ' & ' 3110 3111 content += '\\\\ \\hline' 3112 content += crlf 3113 content += '\\end{tabular}' 3114 content += '\\end{table}' 3115 3116 return content 3054 3117 3055 3118 def set_clipboard(self, content=None):
Note: See TracChangeset
for help on using the changeset viewer.