Changeset 9804394 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Sep 21, 2017 5:45:03 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:
- e3ad3c8
- Parents:
- f73b47c (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
ra1b8fee rf80b416e 254 254 if not hasattr(self, "model_view"): 255 255 return 256 toggle_mode_on = self.model_view.IsEnabled() 256 toggle_mode_on = self.model_view.IsEnabled() or self.data is None 257 257 if toggle_mode_on: 258 258 if self.enable2D and not check_data_validity(self.data): … … 1841 1841 if models.name != "NoStructure": 1842 1842 mlist.append((models.name, models)) 1843 1844 1843 # Sort the models 1845 1844 mlist_sorted = sorted(mlist) … … 2789 2788 def _on_mag_angle_help(self, event): 2790 2789 """ 2791 Bring up Magnetic Angle definition bmpimage whenever the ? button2790 Bring up Magnetic Angle definition.png image whenever the ? button 2792 2791 is clicked. Calls DocumentationWindow with the path of the location 2793 2792 within the documentation tree (after /doc/ ....". When using old … … 2803 2802 """ 2804 2803 2805 _TreeLocation = "_images/M_angles_pic. bmp"2804 _TreeLocation = "_images/M_angles_pic.png" 2806 2805 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2807 2806 "Magnetic Angle Defintions") … … 2809 2808 def _on_mag_help(self, event): 2810 2809 """ 2811 Bring up Magnetic Angle definition bmpimage whenever the ? button2810 Bring up Magnetic Angle definition.png image whenever the ? button 2812 2811 is clicked. Calls DocumentationWindow with the path of the location 2813 2812 within the documentation tree (after /doc/ ....". When using old … … 2929 2928 return False 2930 2929 2930 2931 def _get_copy_params_details(self): 2932 """ 2933 Combines polydisperse parameters with self.parameters so that they can 2934 be written to the clipboard (for Excel or LaTeX). Also returns a list of 2935 the names of parameters that have been fitted 2936 2937 :returns: all_params - A list of all parameters, in the format of 2938 self.parameters 2939 :returns: fitted_par_names - A list of the names of parameters that have 2940 been fitted 2941 """ 2942 # Names of params that are being fitted 2943 fitted_par_names = [param[1] for param in self.param_toFit] 2944 # Names of params with associated polydispersity 2945 disp_params = [param[1].split('.')[0] for param in self.fittable_param] 2946 2947 # Create array of all parameters 2948 all_params = copy.copy(self.parameters) 2949 for param in self.parameters: 2950 if param[1] in disp_params: 2951 # Polydisperse params aren't in self.parameters, so need adding 2952 # to all_params 2953 name = param[1] + ".width" 2954 index = all_params.index(param) + 1 2955 to_insert = [] 2956 if name in fitted_par_names: 2957 # Param is fitted, so already has a param list in self.param_toFit 2958 to_insert = self.param_toFit[fitted_par_names.index(name)] 2959 else: 2960 # Param isn't fitted, so mockup a param list 2961 to_insert = [None, name, self.model.getParam(name), None, None] 2962 all_params.insert(index, to_insert) 2963 return all_params, fitted_par_names 2964 2931 2965 def get_copy_excel(self): 2932 2966 """ … … 2942 2976 Get the string copies of the param names and values in the tap 2943 2977 """ 2978 if not self.parameters: 2979 # Do nothing if parameters doesn't exist 2980 return False 2981 2944 2982 content = '' 2945 2946 2983 crlf = chr(13) + chr(10) 2947 2984 tab = chr(9) 2948 2985 2949 # Do it if params exist 2950 if self.parameters: 2951 2952 for param in self.parameters: 2953 content += param[1] # parameter name 2986 all_params, fitted_param_names = self._get_copy_params_details() 2987 2988 # Construct row of parameter names 2989 for param in all_params: 2990 name = param[1] # Parameter name 2991 content += name 2992 content += tab 2993 if name in fitted_param_names: 2994 # Only print errors for fitted parameters 2995 content += name + "_err" 2954 2996 content += tab 2955 content += param[1] + "_err" 2956 content += tab 2957 2958 content += crlf 2959 2960 # row of values and errors... 2961 for param in self.parameters: 2962 content += param[2].GetValue() # value 2963 content += tab 2964 content += param[4].GetValue() # error 2965 content += tab 2966 2967 return content 2968 else: 2969 return False 2997 2998 content += crlf 2999 3000 # Construct row of parameter values and errors 3001 for param in all_params: 3002 value = param[2] 3003 if hasattr(value, 'GetValue'): 3004 # param[2] is a text box 3005 value = value.GetValue() 3006 else: 3007 # param[2] is a float (from our self._get_copy_params_details) 3008 value = str(value) 3009 content += value 3010 content += tab 3011 if param[1] in fitted_param_names: 3012 # Only print errors for fitted parameters 3013 content += param[4].GetValue() 3014 content += tab 3015 3016 return content 2970 3017 2971 3018 def get_copy_latex(self): … … 2982 3029 Get the string copies of the param names and values in the tap 2983 3030 """ 3031 if not self.parameters: 3032 # Do nothing if self.parameters doesn't exist 3033 return False 3034 2984 3035 content = '\\begin{table}' 2985 3036 content += '\\begin{tabular}[h]' … … 2988 3039 tab = chr(9) 2989 3040 2990 # Do it if params exist 2991 if self.parameters: 2992 2993 content += '{|' 2994 for param in self.parameters: 2995 content += 'l|l|' 2996 content += '}\hline' 2997 content += crlf 2998 2999 for index, param in enumerate(self.parameters): 3000 content += param[1].replace('_', '\_') # parameter name 3041 all_params, fitted_param_names = self._get_copy_params_details() 3042 3043 content += '{|' 3044 for param in all_params: 3045 content += 'l|l|' 3046 content += '}\hline' 3047 content += crlf 3048 3049 # Construct row of parameter names 3050 for index, param in enumerate(all_params): 3051 name = param[1] # Parameter name 3052 content += name.replace('_', '\_') # Escape underscores 3053 if name in fitted_param_names: 3054 # Only print errors for fitted parameters 3001 3055 content += ' & ' 3002 content += param[1].replace('_', '\_') + "\_err" 3003 if index < len(self.parameters) - 1: 3004 content += ' & ' 3005 content += '\\\\ \\hline' 3006 content += crlf 3007 3008 # row of values and errors... 3009 for index, param in enumerate(self.parameters): 3010 content += param[2].GetValue() # parameter value 3056 content += name.replace('_', '\_') + "\_err" 3057 if index < len(all_params) - 1: 3011 3058 content += ' & ' 3012 content += param[4].GetValue() # parameter error 3013 if index < len(self.parameters) - 1: 3014 content += ' & ' 3015 content += '\\\\ \\hline' 3016 content += crlf 3017 3018 content += '\\end{tabular}' 3019 content += '\\end{table}' 3020 return content 3021 else: 3022 return False 3059 3060 content += '\\\\ \\hline' 3061 content += crlf 3062 3063 # Construct row of values and errors 3064 for index, param in enumerate(all_params): 3065 value = param[2] 3066 if hasattr(value, "GetValue"): 3067 # value is a text box 3068 value = value.GetValue() 3069 else: 3070 # value is a float (from self._get_copy_params_details) 3071 value = str(value) 3072 content += value 3073 if param[1] in fitted_param_names: 3074 # Only print errors for fitted params 3075 content += ' & ' 3076 content += param[4].GetValue() 3077 if index < len(all_params) - 1: 3078 content += ' & ' 3079 3080 content += '\\\\ \\hline' 3081 content += crlf 3082 content += '\\end{tabular}' 3083 content += '\\end{table}' 3084 3085 return content 3023 3086 3024 3087 def set_clipboard(self, content=None):
Note: See TracChangeset
for help on using the changeset viewer.