Changes in / [5c1c486:7b3f154] in sasview
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
rb76e65a ra1b8fee 2929 2929 return False 2930 2930 2931 2932 def _get_copy_params_details(self):2933 """2934 Combines polydisperse parameters with self.parameters so that they can2935 be written to the clipboard (for Excel or LaTeX). Also returns a list of2936 the names of parameters that have been fitted2937 2938 :returns: all_params - A list of all parameters, in the format of2939 self.parameters2940 :returns: fitted_par_names - A list of the names of parameters that have2941 been fitted2942 """2943 # Names of params that are being fitted2944 fitted_par_names = [param[1] for param in self.param_toFit]2945 # Names of params with associated polydispersity2946 disp_params = [param[1].split('.')[0] for param in self.fittable_param]2947 2948 # Create array of all parameters2949 all_params = copy.copy(self.parameters)2950 for param in self.parameters:2951 if param[1] in disp_params:2952 # Polydisperse params aren't in self.parameters, so need adding2953 # to all_params2954 name = param[1] + ".width"2955 index = all_params.index(param) + 12956 to_insert = []2957 if name in fitted_par_names:2958 # Param is fitted, so already has a param list in self.param_toFit2959 to_insert = self.param_toFit[fitted_par_names.index(name)]2960 else:2961 # Param isn't fitted, so mockup a param list2962 to_insert = [None, name, self.model.getParam(name), None, None]2963 all_params.insert(index, to_insert)2964 return all_params, fitted_par_names2965 2966 2931 def get_copy_excel(self): 2967 2932 """ … … 2977 2942 Get the string copies of the param names and values in the tap 2978 2943 """ 2979 if not self.parameters:2980 # Do nothing if parameters doesn't exist2981 return False2982 2983 2944 content = '' 2945 2984 2946 crlf = chr(13) + chr(10) 2985 2947 tab = chr(9) 2986 2948 2987 all_params, fitted_param_names = self._get_copy_params_details() 2988 2989 # Construct row of parameter names 2990 for param in all_params: 2991 name = param[1] # Parameter name 2992 content += name 2993 content += tab 2994 if name in fitted_param_names: 2995 # Only print errors for fitted parameters 2996 content += name + "_err" 2949 # Do it if params exist 2950 if self.parameters: 2951 2952 for param in self.parameters: 2953 content += param[1] # parameter name 2997 2954 content += tab 2998 2999 content += crlf 3000 3001 # Construct row of parameter values and errors 3002 for param in all_params: 3003 value = param[2] 3004 if hasattr(value, 'GetValue'): 3005 # param[2] is a text box 3006 value = value.GetValue() 3007 else: 3008 # param[2] is a float (from our self._get_copy_params_details) 3009 value = str(value) 3010 content += value 3011 content += tab 3012 if param[1] in fitted_param_names: 3013 # Only print errors for fitted parameters 3014 content += param[4].GetValue() 3015 content += tab 3016 3017 return content 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 3018 2970 3019 2971 def get_copy_latex(self): … … 3030 2982 Get the string copies of the param names and values in the tap 3031 2983 """ 3032 if not self.parameters:3033 # Do nothing if self.parameters doesn't exist3034 return False3035 3036 2984 content = '\\begin{table}' 3037 2985 content += '\\begin{tabular}[h]' … … 3040 2988 tab = chr(9) 3041 2989 3042 all_params, fitted_param_names = self._get_copy_params_details() 3043 3044 content += '{|' 3045 for param in all_params: 3046 content += 'l|l|' 3047 content += '}\hline' 3048 content += crlf 3049 3050 # Construct row of parameter names 3051 for index, param in enumerate(all_params): 3052 name = param[1] # Parameter name 3053 content += name.replace('_', '\_') # Escape underscores 3054 if name in fitted_param_names: 3055 # Only print errors for fitted parameters 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 3056 3001 content += ' & ' 3057 content += name.replace('_', '\_') + "\_err" 3058 if index < len(all_params) - 1: 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 3059 3011 content += ' & ' 3060 3061 content += '\\\\ \\hline' 3062 content += crlf 3063 3064 # Construct row of values and errors 3065 for index, param in enumerate(all_params): 3066 value = param[2] 3067 if hasattr(value, "GetValue"): 3068 # value is a text box 3069 value = value.GetValue() 3070 else: 3071 # value is a float (from self._get_copy_params_details) 3072 value = str(value) 3073 content += value 3074 if param[1] in fitted_param_names: 3075 # Only print errors for fitted params 3076 content += ' & ' 3077 content += param[4].GetValue() 3078 if index < len(all_params) - 1: 3079 content += ' & ' 3080 3081 content += '\\\\ \\hline' 3082 content += crlf 3083 content += '\\end{tabular}' 3084 content += '\\end{table}' 3085 3086 return 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 3087 3023 3088 3024 def set_clipboard(self, content=None): -
src/sas/sasgui/perspectives/fitting/fitpage.py
r0b6f83c r9a5097c 289 289 self.btFitHelp.SetToolTipString("General fitting help.") 290 290 self.btFitHelp.Bind(wx.EVT_BUTTON, self._onFitHelp) 291 291 292 292 # Resolution Smearing Help button (for now use same technique as 293 293 # used for dI help to get tiniest possible button that works … … 303 303 self.btSmearHelp.SetToolTipString("Resolution smearing help.") 304 304 self.btSmearHelp.Bind(wx.EVT_BUTTON, self._onSmearHelp) 305 305 306 306 # textcntrl for custom resolution 307 307 self.smear_pinhole_percent = ModelTextCtrl(self, wx.ID_ANY, … … 564 564 sizer.Add(self.draw_button, 0, 0) 565 565 sizer.Add((-1, 5)) 566 566 567 567 sizer.Add(self.tcChi, 0, 0) 568 568 sizer.Add(self.Npts_fit, 0, 0) … … 570 570 sizer.Add(self.btFit, 0, 0) 571 571 sizer.Add(self.btFitHelp, 0, 0) 572 572 573 573 boxsizer_range.Add(sizer_chi2) 574 574 boxsizer_range.Add(sizer) … … 2181 2181 self.save_current_state() 2182 2182 2183 if not self.is_mac:2184 self.Layout()2185 self.Refresh()2186 2183 # plot model ( when drawing, do not update chisqr value again) 2187 2184 self._draw_model(update_chisqr=False, source='fit') … … 2778 2775 else: 2779 2776 return cmp(a.lower(), b.lower()) 2780 2777 2781 2778 # keys obtained now from ordered dict, so commenting alphabetical 2782 2779 # ordering keys.sort(custom_compare) -
src/sas/sasgui/perspectives/fitting/fitpanel.py
r6f9abd3 r67b0a99 501 501 if data is None: 502 502 return None 503 focused_page = self.GetPage(self.GetSelection())504 503 for page in self.opened_pages.values(): 505 504 # check if the selected data existing in the fitpanel 506 505 pos = self.GetPageIndex(page) 507 506 if not check_data_validity(page.get_data()) and not page.batch_on: 508 if page.model is not None and page != focused_page:509 # Page has an active theory and is in background - don't510 # send data here.511 continue512 507 # make sure data get placed in 1D empty tab if data is 1D 513 508 # else data get place on 2D tab empty tab -
src/sas/sasgui/perspectives/fitting/fitting.py
r2d9526d r2d9526d 1326 1326 1327 1327 is_data2d = issubclass(data.__class__, Data2D) 1328 # Check consistency of arrays1328 #check consistency of arrays 1329 1329 if not is_data2d: 1330 1330 if len(res.theory) == len(res.index[res.index]) and \ … … 1337 1337 new_theory[res.index == False] = np.nan 1338 1338 correct_result = True 1339 # Get all fittable parameters of the current model1339 #get all fittable parameters of the current model 1340 1340 param_list = model.getParamList() 1341 1341 for param in model.getDispParamList(): 1342 if '.' in param and param in param_list: 1343 # Ensure polydispersity results are displayed 1344 p1, p2 = param.split('.') 1345 if not model.is_fittable(p1) and not (p2 == 'width' and param in res.param_list)\ 1346 and param in param_list: 1347 param_list.remove(param) 1348 elif not model.is_fittable(param) and \ 1342 if not model.is_fittable(param) and \ 1349 1343 param in param_list: 1350 1344 param_list.remove(param) … … 1367 1361 batch_outputs["Chi2"].append(ERROR) 1368 1362 for param in param_list: 1369 # Save value of fixed parameters1363 # save value of fixed parameters 1370 1364 if param not in res.param_list: 1371 1365 batch_outputs[str(param)].append(ERROR) 1372 1366 else: 1373 # Save only fitted values1367 #save only fitted values 1374 1368 batch_outputs[param].append(ERROR) 1375 1369 batch_inputs["error on %s" % str(param)].append(ERROR) -
test/corfunc/test/utest_corfunc.py
r968d67e r253eb6c6 17 17 upperq=(0.15, 0.24)) 18 18 self.extrapolation = None 19 self.transformation = None20 19 21 20 def extrapolate(self):
Note: See TracChangeset
for help on using the changeset viewer.