Changeset 934ce649 in sasview for src/sas/sasgui/perspectives/fitting
- Timestamp:
- May 23, 2016 6:48:46 PM (8 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b6f563b4
- Parents:
- 52b7fd9
- Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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/fitting.py
r243fbc0 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 … … 45 45 from sas.sasgui.guiframe.gui_manager import MDIFrame 46 46 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 47 48 from . import models 47 49 48 50 MAX_NBR_DATA = 4 … … 260 262 msg += "and try it again." 261 263 wx.MessageBox(msg, 'Info') 262 # wx.PostEvent(self.parent, StatusEvent(status=msg, type='stop',263 # info='warning'))264 #evt = StatusEvent(status=msg, type='stop', info='warning') 265 #wx.PostEvent(self.parent, evt) 264 266 else: 265 267 self.delete_menu.Delete(event_id) … … 268 270 self.edit_menu.DeleteItem(item) 269 271 msg = "The custom model, %s, has been deleted." % label 270 wx.PostEvent(self.parent, StatusEvent(status=msg,271 type='stop', info='info'))272 evt = StatusEvent(status=msg, type='stop', info='info') 273 wx.PostEvent(self.parent, evt) 272 274 break 273 275 except: … … 579 581 except: 580 582 msg = "Fitting: cannot deal with the theory received" 583 evt = StatusEvent(status=msg, info="error") 581 584 logging.error("set_theory " + msg + "\n" + str(sys.exc_value)) 582 wx.PostEvent(self.parent, 583 StatusEvent(status=msg, info="error")) 585 wx.PostEvent(self.parent, evt) 584 586 585 587 def set_state(self, state=None, datainfo=None, format=None): … … 968 970 if not page.param_toFit: 969 971 msg = "No fitting parameters for %s" % page.window_caption 970 wx.PostEvent(page.parent.parent, 971 StatusEvent(status=msg, info="error", 972 type="stop")) 972 evt = StatusEvent(status=msg, info="error", type="stop") 973 wx.PostEvent(page.parent.parent, evt) 973 974 return False 974 975 if not page._update_paramv_on_fit(): … … 976 977 msg += " invalid in %s" % \ 977 978 page.window_caption 978 wx.PostEvent(page.parent.parent, 979 StatusEvent(status=msg, info="error", 980 type="stop")) 979 evt = StatusEvent(status=msg, info="error", type="stop") 980 wx.PostEvent(page.parent.parent, evt) 981 981 return False 982 982 … … 999 999 except KeyboardInterrupt: 1000 1000 msg = "Fitting terminated" 1001 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1002 type="stop"))1001 evt = StatusEvent(status=msg, info="info", type="stop") 1002 wx.PostEvent(self.parent, evt) 1003 1003 return True 1004 1004 except: 1005 1005 raise 1006 1006 msg = "Fitting error: %s" % str(sys.exc_value) 1007 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error",1008 type="stop"))1007 evt = StatusEvent(status=msg, info="error", type="stop") 1008 wx.PostEvent(self.parent, evt) 1009 1009 return False 1010 1010 ## If a thread is already started, stop it … … 1101 1101 # add data associated to the page created 1102 1102 if page != None: 1103 wx.PostEvent(self.parent, StatusEvent(status="Page Created",1104 info="info"))1103 evt = StatusEvent(status="Page Created", info="info") 1104 wx.PostEvent(self.parent, evt) 1105 1105 else: 1106 1106 msg = "Page was already Created" 1107 wx.PostEvent(self.parent, StatusEvent(status=msg,1108 info="warning"))1107 evt = StatusEvent(status=msg, info="warning") 1108 wx.PostEvent(self.parent, evt) 1109 1109 except: 1110 1110 msg = "Creating Fit page: %s" % sys.exc_value … … 1268 1268 msg = "Fit completed on %s \n" % str_time 1269 1269 msg += "Duration time: %s s.\n" % str(elapsed) 1270 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1271 type="stop"))1270 evt = StatusEvent(status=msg, info="info", type="stop") 1271 wx.PostEvent(self.parent, evt) 1272 1272 1273 1273 if batch_outputs is None: … … 1419 1419 batch_inputs=batch_inputs) 1420 1420 1421 wx.PostEvent(self.parent, StatusEvent(status=msg, error="info",1422 type="stop"))1421 evt = StatusEvent(status=msg, error="info", type="stop") 1422 wx.PostEvent(self.parent, evt) 1423 1423 # Remove parameters that are not shown 1424 1424 cpage = self.fit_panel.get_page_by_id(uid) … … 1499 1499 msg = "Fit completed on %s \n" % str_time 1500 1500 msg += "Duration time: %s s.\n" % str(elapsed) 1501 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1502 type="stop"))1501 evt = StatusEvent(status=msg, info="info", type="stop") 1502 wx.PostEvent(self.parent, evt) 1503 1503 wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 1504 1504 wx.CallAfter(self._update_fit_button, page_id) … … 1524 1524 not numpy.all(numpy.isfinite(res.pvec)): 1525 1525 msg = "Fitting did not converge!!!" 1526 wx.PostEvent(self.parent, 1527 StatusEvent(status=msg, 1528 info="warning", 1529 type="stop")) 1526 evt = StatusEvent(status=msg, info="warning", type="stop") 1527 wx.PostEvent(self.parent, evt) 1530 1528 wx.CallAfter(self._update_fit_button, page_id) 1531 1529 else: … … 1551 1549 except KeyboardInterrupt: 1552 1550 msg = "Singular point: Fitting Stoped." 1553 wx.PostEvent(self.parent, StatusEvent(status=msg, 1554 info="info", 1555 type="stop")) 1551 evt = StatusEvent(status=msg, info="info", type="stop") 1552 wx.PostEvent(self.parent, evt) 1556 1553 except: 1557 1554 msg = "Singular point: Fitting Error occurred." 1558 wx.PostEvent(self.parent, StatusEvent(status=msg, 1559 info="error", 1560 type="stop")) 1555 evt = StatusEvent(status=msg, info="error", type="stop") 1556 wx.PostEvent(self.parent, evt) 1561 1557 1562 1558 except: … … 1564 1560 % sys.exc_value) 1565 1561 #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 1566 wx.PostEvent(self.parent, StatusEvent(status=msg, info="warning",1567 type="stop"))1562 evt = StatusEvent(status=msg, info="warning", type="stop") 1563 wx.PostEvent(self.parent, evt) 1568 1564 1569 1565 def _update_fit_button(self, page_id): … … 1602 1598 ## post a message to status bar 1603 1599 msg = "Set Chain Fitting: %s" % str(not self.batch_reset_flag) 1604 wx.PostEvent(self.parent, 1605 StatusEvent(status=msg)) 1600 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1606 1601 1607 1602 … … 1749 1744 raise 1750 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 1751 1755 def _update2D(self, output, time=None): 1752 1756 """ 1753 1757 Update the output of plotting model 1754 1758 """ 1755 wx.PostEvent(self.parent, StatusEvent(status="Plot \ 1756 #updating ... ", type="update")) 1757 #self.ready_fit() 1759 msg = "Plot updating ... " 1760 wx.PostEvent(self.parent, StatusEvent(msg, type="update")) 1758 1761 1759 1762 def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, … … 1861 1864 time.sleep(0.1) 1862 1865 self.calc_2D = Calc2D(model=model, 1863 data=data, 1864 page_id=page_id, 1865 smearer=smearer, 1866 qmin=qmin, 1867 qmax=qmax, 1868 weight=weight, 1869 fid=fid, 1870 toggle_mode_on=toggle_mode_on, 1871 state=state, 1872 completefn=self._complete2D, 1873 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) 1874 1879 self.calc_2D.queue() 1875 1880 except: … … 1926 1931 #updatefn = self._update1D, 1927 1932 update_chisqr=update_chisqr, 1933 exception_handler=self._calc_exception, 1928 1934 source=source) 1929 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
Note: See TracChangeset
for help on using the changeset viewer.