Changeset b768e92 in sasview for src/sas/sasgui/perspectives/fitting
- Timestamp:
- Jun 2, 2016 10:14:35 AM (9 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ec30905
- Parents:
- 6afc14b (diff), 70305bd2 (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. - Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/__init__.py
r9e531f2 ra7c4ad2 39 39 data_files = [] 40 40 path = os.path.dirname(__file__) 41 #p_path = os.path.join(path, 'plugin_models')42 #for f in findall(p_path):43 #data_files.append(('plugin_models', [f]))41 p_path = os.path.join(path, 'plugin_models') 42 for f in findall(p_path): 43 data_files.append(('plugin_models', [f])) 44 44 # path = get_data_path(media="media") 45 45 for f in findall(path): -
src/sas/sasgui/perspectives/fitting/fitpage.py
rcb4ef58 r934ce649 1330 1330 qmin=float(self.qmin_x), 1331 1331 qmax=float(self.qmax_x), 1332 enable_smearer=enable_smearer, 1333 draw=True) 1332 enable_smearer=enable_smearer) 1334 1333 if flag: 1335 1334 #self.compute_chisqr(smearer= temp_smearer) … … 2606 2605 qmin=float(self.qmin_x), 2607 2606 qmax=float(self.qmax_x), 2608 enable_smearer=enable_smearer, 2609 draw=True) 2607 enable_smearer=enable_smearer) 2610 2608 2611 2609 self.state.enable_smearer = self.enable_smearer.GetValue() -
src/sas/sasgui/perspectives/fitting/fitpanel.py
rf60251f r05228b0 17 17 import models 18 18 _BOX_WIDTH = 80 19 20 19 21 20 class FitPanel(nb, PanelBase): … … 154 153 """ 155 154 """ 156 from bumps.options import FIT_CONFIG157 current = FIT_CONFIG.selected_name158 self.parent.SetTitle(self.window_name + " - Active Fitting Optimizer: " + current)159 155 pos = self.GetSelection() 160 156 if pos != -1: -
src/sas/sasgui/perspectives/fitting/fitting.py
r86b049b r934ce649 19 19 import time 20 20 from copy import deepcopy 21 import models21 import traceback 22 22 23 23 from sas.sascalc.dataloader.loader import Loader … … 46 46 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 47 47 48 from . import models 49 48 50 MAX_NBR_DATA = 4 49 51 … … 56 58 ON_MAC = True 57 59 58 60 import bumps.options 61 from bumps.gui.fit_dialog import show_fit_config 62 try: 63 from bumps.gui.fit_dialog import EVT_FITTER_CHANGED 64 except ImportError: 65 # CRUFT: bumps 0.7.5.8 and below 66 EVT_FITTER_CHANGED = None # type: wx.PyCommandEvent 59 67 60 68 class Plugin(PluginBase): … … 254 262 msg += "and try it again." 255 263 wx.MessageBox(msg, 'Info') 256 # wx.PostEvent(self.parent, StatusEvent(status=msg, type='stop',257 # info='warning'))264 #evt = StatusEvent(status=msg, type='stop', info='warning') 265 #wx.PostEvent(self.parent, evt) 258 266 else: 259 267 self.delete_menu.Delete(event_id) … … 262 270 self.edit_menu.DeleteItem(item) 263 271 msg = "The custom model, %s, has been deleted." % label 264 wx.PostEvent(self.parent, StatusEvent(status=msg,265 type='stop', info='info'))272 evt = StatusEvent(status=msg, type='stop', info='info') 273 wx.PostEvent(self.parent, evt) 266 274 break 267 275 except: … … 501 509 self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event) 502 510 self.parent.Bind(EVT_SLICER_PARS_UPDATE, self._onEVT_SLICER_PANEL) 511 512 # CRUFT: EVT_FITTER_CHANGED is not None for bumps 0.7.5.9 and above 513 if EVT_FITTER_CHANGED is not None: 514 self.parent.Bind(EVT_FITTER_CHANGED, self.on_fitter_changed) 515 self._set_fitter_label(bumps.options.FIT_CONFIG) 516 503 517 #self.parent._mgr.Bind(wx.aui.EVT_AUI_PANE_CLOSE,self._onclearslicer) 504 518 #Create reader when fitting panel are created … … 567 581 except: 568 582 msg = "Fitting: cannot deal with the theory received" 583 evt = StatusEvent(status=msg, info="error") 569 584 logging.error("set_theory " + msg + "\n" + str(sys.exc_value)) 570 wx.PostEvent(self.parent, 571 StatusEvent(status=msg, info="error")) 585 wx.PostEvent(self.parent, evt) 572 586 573 587 def set_state(self, state=None, datainfo=None, format=None): … … 763 777 Open the bumps options panel. 764 778 """ 765 try: 766 from bumps.gui.fit_dialog import show_fit_config 767 show_fit_config(self.parent, help=self.on_help) 768 except ImportError: 769 # CRUFT: Bumps 0.7.5.6 and earlier do not have the help button 770 from bumps.gui.fit_dialog import OpenFitOptions 771 OpenFitOptions() 779 show_fit_config(self.parent, help=self.on_help) 780 781 def on_fitter_changed(self, event): 782 self._set_fitter_label(event.config) 783 784 def _set_fitter_label(self, config): 785 self.fit_panel.parent.SetTitle(self.fit_panel.window_name 786 + " - Active Fitting Optimizer: " 787 + config.selected_name) 772 788 773 789 def on_help(self, algorithm_id): … … 954 970 if not page.param_toFit: 955 971 msg = "No fitting parameters for %s" % page.window_caption 956 wx.PostEvent(page.parent.parent, 957 StatusEvent(status=msg, info="error", 958 type="stop")) 972 evt = StatusEvent(status=msg, info="error", type="stop") 973 wx.PostEvent(page.parent.parent, evt) 959 974 return False 960 975 if not page._update_paramv_on_fit(): … … 962 977 msg += " invalid in %s" % \ 963 978 page.window_caption 964 wx.PostEvent(page.parent.parent, 965 StatusEvent(status=msg, info="error", 966 type="stop")) 979 evt = StatusEvent(status=msg, info="error", type="stop") 980 wx.PostEvent(page.parent.parent, evt) 967 981 return False 968 982 … … 985 999 except KeyboardInterrupt: 986 1000 msg = "Fitting terminated" 987 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",988 type="stop"))1001 evt = StatusEvent(status=msg, info="info", type="stop") 1002 wx.PostEvent(self.parent, evt) 989 1003 return True 990 1004 except: 991 1005 raise 992 1006 msg = "Fitting error: %s" % str(sys.exc_value) 993 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error",994 type="stop"))1007 evt = StatusEvent(status=msg, info="error", type="stop") 1008 wx.PostEvent(self.parent, evt) 995 1009 return False 996 1010 ## If a thread is already started, stop it … … 1087 1101 # add data associated to the page created 1088 1102 if page != None: 1089 wx.PostEvent(self.parent, StatusEvent(status="Page Created",1090 info="info"))1103 evt = StatusEvent(status="Page Created", info="info") 1104 wx.PostEvent(self.parent, evt) 1091 1105 else: 1092 1106 msg = "Page was already Created" 1093 wx.PostEvent(self.parent, StatusEvent(status=msg,1094 info="warning"))1107 evt = StatusEvent(status=msg, info="warning") 1108 wx.PostEvent(self.parent, evt) 1095 1109 except: 1096 1110 msg = "Creating Fit page: %s" % sys.exc_value … … 1254 1268 msg = "Fit completed on %s \n" % str_time 1255 1269 msg += "Duration time: %s s.\n" % str(elapsed) 1256 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1257 type="stop"))1270 evt = StatusEvent(status=msg, info="info", type="stop") 1271 wx.PostEvent(self.parent, evt) 1258 1272 1259 1273 if batch_outputs is None: … … 1405 1419 batch_inputs=batch_inputs) 1406 1420 1407 wx.PostEvent(self.parent, StatusEvent(status=msg, error="info",1408 type="stop"))1421 evt = StatusEvent(status=msg, error="info", type="stop") 1422 wx.PostEvent(self.parent, evt) 1409 1423 # Remove parameters that are not shown 1410 1424 cpage = self.fit_panel.get_page_by_id(uid) … … 1485 1499 msg = "Fit completed on %s \n" % str_time 1486 1500 msg += "Duration time: %s s.\n" % str(elapsed) 1487 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1488 type="stop"))1501 evt = StatusEvent(status=msg, info="info", type="stop") 1502 wx.PostEvent(self.parent, evt) 1489 1503 wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 1490 1504 wx.CallAfter(self._update_fit_button, page_id) … … 1510 1524 not numpy.all(numpy.isfinite(res.pvec)): 1511 1525 msg = "Fitting did not converge!!!" 1512 wx.PostEvent(self.parent, 1513 StatusEvent(status=msg, 1514 info="warning", 1515 type="stop")) 1526 evt = StatusEvent(status=msg, info="warning", type="stop") 1527 wx.PostEvent(self.parent, evt) 1516 1528 wx.CallAfter(self._update_fit_button, page_id) 1517 1529 else: … … 1537 1549 except KeyboardInterrupt: 1538 1550 msg = "Singular point: Fitting Stoped." 1539 wx.PostEvent(self.parent, StatusEvent(status=msg, 1540 info="info", 1541 type="stop")) 1551 evt = StatusEvent(status=msg, info="info", type="stop") 1552 wx.PostEvent(self.parent, evt) 1542 1553 except: 1543 1554 msg = "Singular point: Fitting Error occurred." 1544 wx.PostEvent(self.parent, StatusEvent(status=msg, 1545 info="error", 1546 type="stop")) 1555 evt = StatusEvent(status=msg, info="error", type="stop") 1556 wx.PostEvent(self.parent, evt) 1547 1557 1548 1558 except: … … 1550 1560 % sys.exc_value) 1551 1561 #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 1552 wx.PostEvent(self.parent, StatusEvent(status=msg, info="warning",1553 type="stop"))1562 evt = StatusEvent(status=msg, info="warning", type="stop") 1563 wx.PostEvent(self.parent, evt) 1554 1564 1555 1565 def _update_fit_button(self, page_id): … … 1588 1598 ## post a message to status bar 1589 1599 msg = "Set Chain Fitting: %s" % str(not self.batch_reset_flag) 1590 wx.PostEvent(self.parent, 1591 StatusEvent(status=msg)) 1600 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1592 1601 1593 1602 … … 1735 1744 raise 1736 1745 1746 def _calc_exception(self, etype, value, tb): 1747 """ 1748 Handle exception from calculator by posting it as an error. 1749 """ 1750 logging.error("".join(traceback.format_exception(etype, value, tb))) 1751 msg = traceback.format_exception(etype, value, tb, limit=1) 1752 evt = StatusEvent(status="".join(msg), type="stop", info="error") 1753 wx.PostEvent(self.parent, evt) 1754 1737 1755 def _update2D(self, output, time=None): 1738 1756 """ 1739 1757 Update the output of plotting model 1740 1758 """ 1741 wx.PostEvent(self.parent, StatusEvent(status="Plot \ 1742 #updating ... ", type="update")) 1743 #self.ready_fit() 1759 msg = "Plot updating ... " 1760 wx.PostEvent(self.parent, StatusEvent(msg, type="update")) 1744 1761 1745 1762 def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, … … 1847 1864 time.sleep(0.1) 1848 1865 self.calc_2D = Calc2D(model=model, 1849 data=data, 1850 page_id=page_id, 1851 smearer=smearer, 1852 qmin=qmin, 1853 qmax=qmax, 1854 weight=weight, 1855 fid=fid, 1856 toggle_mode_on=toggle_mode_on, 1857 state=state, 1858 completefn=self._complete2D, 1859 update_chisqr=update_chisqr, source=source) 1866 data=data, 1867 page_id=page_id, 1868 smearer=smearer, 1869 qmin=qmin, 1870 qmax=qmax, 1871 weight=weight, 1872 fid=fid, 1873 toggle_mode_on=toggle_mode_on, 1874 state=state, 1875 completefn=self._complete2D, 1876 update_chisqr=update_chisqr, 1877 exception_handler=self._calc_exception, 1878 source=source) 1860 1879 self.calc_2D.queue() 1861 1880 except: … … 1912 1931 #updatefn = self._update1D, 1913 1932 update_chisqr=update_chisqr, 1933 exception_handler=self._calc_exception, 1914 1934 source=source) 1915 1935 self.calc_1D.queue() -
src/sas/sasgui/perspectives/fitting/model_thread.py
rd85c194 r934ce649 25 25 source='model', 26 26 yieldtime=0.04, 27 worktime=0.04 27 worktime=0.04, 28 exception_handler=None, 28 29 ): 29 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime) 30 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 31 exception_handler=exception_handler) 30 32 self.qmin = qmin 31 33 self.qmax = qmax … … 133 135 updatefn=None, 134 136 yieldtime=0.01, 135 worktime=0.01 137 worktime=0.01, 138 exception_handler=None, 136 139 ): 137 140 """ 138 141 """ 139 CalcThread.__init__(self, completefn, 140 updatefn, 141 yieldtime, 142 worktime) 142 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 143 exception_handler=exception_handler) 143 144 self.fid = fid 144 145 self.data = data -
src/sas/sasgui/perspectives/fitting/models.py
rcb4ef58 r6afc14b 147 147 try: 148 148 import compileall 149 compileall.compile_dir(dir=dir, ddir=dir, force= 1,149 compileall.compile_dir(dir=dir, ddir=dir, force=0, 150 150 quiet=report_problem) 151 151 except:
Note: See TracChangeset
for help on using the changeset viewer.