Changes in src/sas/sasgui/perspectives/fitting/basepage.py [a0373d5:ee4b3cb] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
ra0373d5 ree4b3cb 17 17 from wx.lib.scrolledpanel import ScrolledPanel 18 18 19 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 20 19 import sasmodels.sasview_model 21 20 from sas.sasgui.guiframe.panel_base import PanelBase 22 from sas.sasgui.guiframe.utils import format_number, check_float, IdList , check_int21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList 23 22 from sas.sasgui.guiframe.events import PanelOnFocusEvent 24 23 from sas.sasgui.guiframe.events import StatusEvent … … 627 626 self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked, 628 627 id=self.disp_help_bt.GetId()) 629 self.disp_help_bt.SetToolTipString("Help for polydispersion.")628 self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 630 629 631 630 self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, … … 1124 1123 state.disp_cb_dict[item]) 1125 1124 # Create the dispersion objects 1126 disp_model = POLYDISPERSITY_MODELS['array']() 1125 from sas.models.dispersion_models import ArrayDispersion 1126 disp_model = ArrayDispersion() 1127 1127 if hasattr(state, "values") and \ 1128 1128 self.disp_cb_dict[item].GetValue() == True: … … 2281 2281 continue 2282 2282 2283 value_ctrl = item[2] 2284 if not value_ctrl.IsEnabled(): 2285 # ArrayDispersion disables PD, Min, Max, Npts, Nsigs 2283 name = str(item[1]) 2284 if name.endswith(".npts") or name.endswith(".nsigmas"): 2286 2285 continue 2287 2286 2288 name = item[1] 2287 # Check that min, max and value are floats 2288 value_ctrl, min_ctrl, max_ctrl = item[2], item[5], item[6] 2289 min_str = min_ctrl.GetValue().strip() 2290 max_str = max_ctrl.GetValue().strip() 2289 2291 value_str = value_ctrl.GetValue().strip() 2290 if name.endswith(".npts"): 2291 validity = check_int(value_ctrl) 2292 if not validity: 2293 continue 2294 value = int(value_str) 2295 2296 elif name.endswith(".nsigmas"): 2297 validity = check_float(value_ctrl) 2298 if not validity: 2299 continue 2300 value = float(value_str) 2301 2302 else: # value or polydispersity 2303 2304 # Check that min, max and value are floats 2305 min_ctrl, max_ctrl = item[5], item[6] 2306 min_str = min_ctrl.GetValue().strip() 2307 max_str = max_ctrl.GetValue().strip() 2308 validity = check_float(value_ctrl) 2309 if min_str != "": 2310 validity = validity and check_float(min_ctrl) 2311 if max_str != "": 2312 validity = validity and check_float(max_ctrl) 2313 if not validity: 2314 continue 2315 2316 # Check that min is less than max 2317 low = -numpy.inf if min_str == "" else float(min_str) 2318 high = numpy.inf if max_str == "" else float(max_str) 2319 if high < low: 2320 min_ctrl.SetBackgroundColour("pink") 2321 min_ctrl.Refresh() 2322 max_ctrl.SetBackgroundColour("pink") 2323 max_ctrl.Refresh() 2324 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2325 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2326 continue 2327 2328 # Force value between min and max 2329 value = float(value_str) 2330 if value < low: 2331 value = low 2332 value_ctrl.SetValue(format_number(value)) 2333 elif value > high: 2334 value = high 2335 value_ctrl.SetValue(format_number(value)) 2336 2337 if name not in self.model.details.keys(): 2338 self.model.details[name] = ["", None, None] 2339 old_low, old_high = self.model.details[name][1:3] 2340 if old_low != low or old_high != high: 2341 # The configuration has changed but it won't change the 2342 # computed curve so no need to set is_modified to True 2343 #is_modified = True 2344 self.model.details[name][1:3] = low, high 2292 validity = check_float(value_ctrl) 2293 if min_str != "": 2294 validity = validity and check_float(min_ctrl) 2295 if max_str != "": 2296 validity = validity and check_float(max_ctrl) 2297 if not validity: 2298 continue 2299 2300 # Check that min is less than max 2301 low = -numpy.inf if min_str == "" else float(min_str) 2302 high = numpy.inf if max_str == "" else float(max_str) 2303 if high < low: 2304 min_ctrl.SetBackgroundColour("pink") 2305 min_ctrl.Refresh() 2306 max_ctrl.SetBackgroundColour("pink") 2307 max_ctrl.Refresh() 2308 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2309 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2310 continue 2311 2312 # Force value between min and max 2313 value = float(value_str) 2314 if value < low: 2315 value = low 2316 value_ctrl.SetValue(format_number(value)) 2317 elif value > high: 2318 value = high 2319 value_ctrl.SetValue(format_number(value)) 2345 2320 2346 2321 # Update value in model if it has changed … … 2348 2323 self.model.setParam(name, value) 2349 2324 is_modified = True 2325 2326 if name not in self.model.details.keys(): 2327 self.model.details[name] = ["", None, None] 2328 old_low, old_high = self.model.details[name][1:3] 2329 if old_low != low or old_high != high: 2330 # The configuration has changed but it won't change the 2331 # computed curve so no need to set is_modified to True 2332 #is_modified = True 2333 self.model.details[name][1:3] = low, high 2350 2334 2351 2335 return is_modified … … 2703 2687 :param disp_function: dispersion distr. function 2704 2688 """ 2689 # List of the poly_model name in the combobox 2690 list = ["RectangleDispersion", "ArrayDispersion", 2691 "LogNormalDispersion", "GaussianDispersion", 2692 "SchulzDispersion"] 2693 2705 2694 # Find the selection 2706 if disp_func is not None: 2707 try: 2708 return POLYDISPERSITY_MODELS.values().index(disp_func.__class__) 2709 except ValueError: 2710 pass # Fall through to default class 2711 return POLYDISPERSITY_MODELS.keys().index('gaussian') 2695 try: 2696 selection = list.index(disp_func.__class__.__name__) 2697 return selection 2698 except: 2699 return 3 2712 2700 2713 2701 def on_reset_clicked(self, event):
Note: See TracChangeset
for help on using the changeset viewer.