Changes in src/sas/qtgui/Perspectives/Fitting/FittingWidget.py [d4ba565:bb477f5] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rd4ba565 rbb477f5 569 569 menu.exec_(self.lstParams.viewport().mapToGlobal(position)) 570 570 except AttributeError as ex: 571 logg ing.error("Error generating context menu: %s" % ex)571 logger.error("Error generating context menu: %s" % ex) 572 572 return 573 573 … … 1456 1456 self.communicate.statusBarUpdateSignal.emit(msg) 1457 1457 msg += results.mesg 1458 logg ing.error(msg)1458 logger.error(msg) 1459 1459 return 1460 1460 … … 1499 1499 if self.calc_fit._interrupting: 1500 1500 msg = "Fitting cancelled by user after: %s s." % GuiUtils.formatNumber(elapsed) 1501 logg ing.warning("\n"+msg+"\n")1501 logger.warning("\n"+msg+"\n") 1502 1502 else: 1503 1503 msg = "Fitting completed successfully in: %s s." % GuiUtils.formatNumber(elapsed) … … 1841 1841 data_to_show = self.data if self.data_is_loaded else self.model_data 1842 1842 if data_to_show is not None: 1843 self.communicate.plotRequestedSignal.emit([data_to_show] )1843 self.communicate.plotRequestedSignal.emit([data_to_show], self.tab_id) 1844 1844 1845 1845 def onOptionsUpdate(self): … … 2052 2052 kernel_module = generate.load_kernel_module(name) 2053 2053 except ModuleNotFoundError as ex: 2054 logg ing.error("Can't find the model "+ str(ex))2054 logger.error("Can't find the model "+ str(ex)) 2055 2055 return 2056 2056 … … 2102 2102 return 2103 2103 2104 product_params = None 2105 2104 2106 if self.kernel_module is None: 2105 2107 # Structure factor is the only selected model; build it and show all its params … … 2107 2109 s_params = self.kernel_module._model_info.parameters 2108 2110 s_params_orig = s_params 2109 2110 2111 else: 2111 2112 s_kernel = self.models[structure_factor]() … … 2124 2125 if "radius_effective_mode" in all_param_names: 2125 2126 # Show all parameters 2127 # In this case, radius_effective is NOT pruned by sasmodels.product 2126 2128 s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len]) 2127 2129 s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters) 2130 product_params = modelinfo.ParameterTable( 2131 self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 2128 2132 else: 2129 2133 # Ensure radius_effective is not displayed 2130 2134 s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 2131 2135 if "radius_effective" in all_param_names: 2136 # In this case, radius_effective is NOT pruned by sasmodels.product 2132 2137 s_params = modelinfo.ParameterTable(all_params[p_pars_len+1:p_pars_len+s_pars_len]) 2138 product_params = modelinfo.ParameterTable( 2139 self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 2133 2140 else: 2141 # In this case, radius_effective is pruned by sasmodels.product 2134 2142 s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 2143 product_params = modelinfo.ParameterTable( 2144 self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len-1:]) 2135 2145 2136 2146 # Add heading row … … 2140 2150 # Any renamed parameters are stored as data in the relevant item, for later handling 2141 2151 FittingUtilities.addSimpleParametersToModel( 2142 s_params, 2143 self.is2D, 2144 s_params_orig, 2145 self._model_model, 2146 self.lstParams) 2152 parameters=s_params, 2153 is2D=self.is2D, 2154 parameters_original=s_params_orig, 2155 model=self._model_model, 2156 view=self.lstParams) 2157 2158 # Insert product-only params into QModel 2159 if product_params: 2160 prod_rows = FittingUtilities.addSimpleParametersToModel( 2161 parameters=product_params, 2162 is2D=self.is2D, 2163 parameters_original=None, 2164 model=self._model_model, 2165 view=self.lstParams, 2166 row_num=2) 2167 2168 # Since this all happens after shells are dealt with and we've inserted rows, fix this counter 2169 self._n_shells_row += len(prod_rows) 2147 2170 2148 2171 def haveParamsToFit(self): … … 2264 2287 fitted_data.symbol = "Line" 2265 2288 self.createTheoryIndex(fitted_data) 2289 # Switch to the theory tab for user's glee 2290 self.communicate.changeDataExplorerTabSignal.emit(1) 2266 2291 2267 2292 def updateModelIndex(self, fitted_data): … … 2399 2424 2400 2425 if self.data_is_loaded: 2426 # delete any plots associated with the data that were not updated (e.g. to remove beta(Q), S_eff(Q)) 2401 2427 GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 2428 pass 2402 2429 else: 2403 2430 # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) … … 2405 2432 2406 2433 # Create plots for intermediate product data 2407 pq_data, sq_data = self.logic.new1DProductPlots(return_data, self.tab_id) 2408 if pq_data is not None: 2409 pq_data.symbol = "Line" 2410 self.createNewIndex(pq_data) 2411 # self.communicate.plotUpdateSignal.emit([pq_data]) 2412 new_plots.append(pq_data) 2413 if sq_data is not None: 2414 sq_data.symbol = "Line" 2415 self.createNewIndex(sq_data) 2416 # self.communicate.plotUpdateSignal.emit([sq_data]) 2417 new_plots.append(sq_data) 2434 plots = self.logic.new1DProductPlots(return_data, self.tab_id) 2435 for plot in plots: 2436 plot.symbol = "Line" 2437 self.createNewIndex(plot) 2438 new_plots.append(plot) 2418 2439 2419 2440 for plot in new_plots: … … 2494 2515 """ 2495 2516 # TODO: remimplement thread cancellation 2496 logg ing.error("".join(traceback.format_exception(etype, value, tb)))2517 logger.error("".join(traceback.format_exception(etype, value, tb))) 2497 2518 2498 2519 def setTableProperties(self, table): … … 2676 2697 2677 2698 if not datafile: 2678 logg ing.info("No weight data chosen.")2699 logger.info("No weight data chosen.") 2679 2700 raise IOError 2680 2701 … … 2792 2813 self._n_shells_row = shell_row - 1 2793 2814 2794 # Set the index to the state-kept value 2795 func.setCurrentIndex(self.current_shell_displayed 2796 if self.current_shell_displayed < func.count() else 0) 2815 # Get the default number of shells for the model 2816 kernel_pars = self.kernel_module._model_info.parameters.kernel_parameters 2817 shell_par = None 2818 for par in kernel_pars: 2819 if par.name == param_name: 2820 shell_par = par 2821 break 2822 if not shell_par: 2823 logger.error("Could not find %s in kernel parameters.", param_name) 2824 default_shell_count = shell_par.default 2825 2826 # Add default number of shells to the model 2827 func.setCurrentIndex(default_shell_count) 2797 2828 2798 2829 def modifyShellsInList(self, index): … … 2816 2847 self._num_shell_params = len(new_rows) 2817 2848 self.current_shell_displayed = index 2849 2850 # Change 'n' in the parameter model, thereby updating the underlying model 2851 self._model_model.item(self._n_shells_row, 1).setText(str(index)) 2818 2852 2819 2853 # Update relevant models … … 3105 3139 param_value = str(self._model_model.item(row, 1).text()) 3106 3140 param_error = None 3141 param_min = None 3142 param_max = None 3107 3143 column_offset = 0 3108 3144 if self.has_error_column: 3109 3145 param_error = str(self._model_model.item(row, 2).text()) 3110 3146 column_offset = 1 3111 param_min = str(self._model_model.item(row, 2+column_offset).text()) 3112 param_max = str(self._model_model.item(row, 3+column_offset).text()) 3147 3148 try: 3149 param_min = str(self._model_model.item(row, 2+column_offset).text()) 3150 param_max = str(self._model_model.item(row, 3+column_offset).text()) 3151 except: 3152 pass 3153 3113 3154 param_list.append([param_name, param_checked, param_value, param_error, param_min, param_max]) 3114 3155 … … 3200 3241 3201 3242 # limits 3202 limit_lo = item[3] 3203 context[name].append(limit_lo) 3204 limit_hi = item[4] 3205 context[name].append(limit_hi) 3243 try: 3244 limit_lo = item[3] 3245 context[name].append(limit_lo) 3246 limit_hi = item[4] 3247 context[name].append(limit_hi) 3248 except: 3249 pass 3206 3250 3207 3251 # Polydisp … … 3262 3306 ioffset = 1 3263 3307 # min/max 3264 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3265 self._model_model.item(row, 2+ioffset).setText(param_repr) 3266 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3267 self._model_model.item(row, 3+ioffset).setText(param_repr) 3308 try: 3309 param_repr = GuiUtils.formatNumber(param_dict[param_name][2+ioffset], high=True) 3310 self._model_model.item(row, 2+ioffset).setText(param_repr) 3311 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3312 self._model_model.item(row, 3+ioffset).setText(param_repr) 3313 except: 3314 pass 3315 3268 3316 self.setFocus() 3317 3269 3318 3270 3319
Note: See TracChangeset
for help on using the changeset viewer.