Changeset a9807efa in sasview for src/sans/perspectives
- Timestamp:
- Aug 28, 2014 11:42:48 AM (10 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:
- 72c969b
- Parents:
- c915053 (diff), f4167637 (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/sans/perspectives
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/perspectives/fitting/fitting.py
rbf5e985 ra9807efa 1962 1962 if (self.calc_2D is not None) and self.calc_2D.isrunning(): 1963 1963 self.calc_2D.stop() 1964 ## stop just raises a flag to tell the thread to kill 1965 ## itself -- see the fix in Calc1D implemented to fix 1966 ## an actual problem. Seems the fix should also go here 1967 ## and may be the cause of other noted instabilities 1968 ## 1969 ## -PDB August 12, 2014 1970 while self.calc_2D.isrunning(): 1971 time.sleep(0.1) 1964 1972 self.calc_2D = Calc2D(model=model, 1965 1973 data=data, … … 1999 2007 if (self.calc_1D is not None) and self.calc_1D.isrunning(): 2000 2008 self.calc_1D.stop() 2009 ## stop just raises the flag -- the thread is supposed to 2010 ## then kill itself but cannot. Paul Kienzle came up with 2011 ## this fix to prevent threads from stepping on each other 2012 ## which was causing a simple custom model to crash Sasview. 2013 ## We still don't know why the fit sometimes lauched a second 2014 ## thread -- something which should also be investigated. 2015 ## The thread approach was implemented in order to be able 2016 ## to lauch a computation in a separate thread from the GUI so 2017 ## that the GUI can still respond to user input including 2018 ## a request to stop the computation. 2019 ## It seems thus that the whole thread approach used here 2020 ## May need rethinking 2021 ## 2022 ## -PDB August 12, 2014 2023 while self.calc_1D.isrunning(): 2024 time.sleep(0.1) 2001 2025 self.calc_1D = Calc1D(data=data, 2002 2026 model=model, -
src/sans/perspectives/pr/pr.py
r5777106 rf4167637 724 724 if self.calc_thread != None and self.calc_thread.isrunning(): 725 725 self.calc_thread.stop() 726 ## stop just raises the flag -- the thread is supposed to 727 ## then kill itself but cannot. Paul Kienzle came up with 728 ## this fix to prevent threads from stepping on each other 729 ## in Calc1D of fitting.py which was causing a simple custom model 730 ## to crash Sasview. See rest of notes under Calc1D. 731 ## 732 ## -PDB August 13, 2014 733 while self.calc_thread.isrunning(): 734 time.sleep(0.1) 726 735 727 736 pr = self.pr.clone() … … 1143 1152 self.estimation_thread.isrunning(): 1144 1153 self.estimation_thread.stop() 1154 ## stop just raises the flag -- the thread is supposed to 1155 ## then kill itself but cannot. Paul Kienzle came up with 1156 ## this fix to prevent threads from stepping on each other 1157 ## in Calc1D of fitting.py which was causing a simple custom model 1158 ## to crash Sasview. See rest of notes under Calc1D. 1159 ## 1160 ## -PDB August 13, 2014 1161 while self.estimation_thread.isrunning(): 1162 time.sleep(0.1) 1163 1145 1164 1146 1165 pr = self.pr.clone() … … 1161 1180 if self.estimation_thread != None and self.estimation_thread.isrunning(): 1162 1181 self.estimation_thread.stop() 1163 1182 ## stop just raises the flag -- the thread is supposed to 1183 ## then kill itself but cannot. Paul Kienzle came up with 1184 ## this fix to prevent threads from stepping on each other 1185 ## in Calc1D of fitting.py which was causing a simple custom model 1186 ## to crash Sasview. See rest of notes under Calc1D. 1187 ## 1188 ## -PDB August 13, 2014 1189 while self.estimation_thread.isrunning(): 1190 time.sleep(0.1) 1191 1164 1192 pr = self.pr.clone() 1165 1193 # Skip the slit settings for the estimation -
src/sans/perspectives/simulation/simulation.py
ra855fec rf4167637 213 213 if self.calc_thread_1D != None and self.calc_thread_1D.isrunning(): 214 214 self.calc_thread_1D.stop() 215 ## stop just raises the flag -- the thread is supposed to 216 ## then kill itself but cannot. Paul Kienzle came up with 217 ## this fix to prevent threads from stepping on each other 218 ## in Calc1D of fitting.py which was causing a simple custom model 219 ## to crash Sasview. See rest of notes under Calc1D. 220 ## 221 ## -PDB August 13, 2014 222 while self.calc_thread_1D.isrunning(): 223 time.sleep(0.1) 215 224 216 225 # Create a computation thread -
src/sans/perspectives/fitting/basepage.py
r116e1a7 rbf5e985 96 96 self.num_points = None 97 97 ## default fitengine type 98 self.engine_type = ' scipy'98 self.engine_type = 'bumps' 99 99 ## smear default 100 100 self.current_smearer = None … … 835 835 infor = "warning" 836 836 else: 837 msg = "Error was occured"838 msg += " :No valid parameter values to paste from the clipboard..."837 msg = "Error occured: " 838 msg += "No valid parameter values to paste from the clipboard..." 839 839 infor = "error" 840 840 wx.PostEvent(self._manager.parent, … … 2183 2183 else: 2184 2184 tcrtl.SetBackgroundColour("pink") 2185 msg = "Model Error: wrong value entered: %s" % sys.exc_value2185 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2186 2186 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2187 2187 return 2188 2188 except: 2189 2189 tcrtl.SetBackgroundColour("pink") 2190 msg = "Model Error: wrong value entered: %s" % sys.exc_value2190 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2191 2191 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2192 2192 return … … 2199 2199 #is_modified = True 2200 2200 else: 2201 msg = "Cannot Plot :No npts in that Qrange!!! "2201 msg = "Cannot plot: No points in Q range!!! " 2202 2202 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2203 2203 else: 2204 2204 tcrtl.SetBackgroundColour("pink") 2205 msg = "Model Error: wrong value entered!!!"2205 msg = "Model Error: wrong value entered!!!" 2206 2206 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2207 2207 self.save_current_state() … … 2240 2240 else: 2241 2241 tcrtl.SetBackgroundColour("pink") 2242 msg = "Model Error: wrong value entered: %s" % sys.exc_value2242 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2243 2243 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2244 2244 return 2245 2245 except: 2246 2246 tcrtl.SetBackgroundColour("pink") 2247 msg = "Model Error: wrong value entered: %s" % sys.exc_value2247 msg = "Model Error: wrong value entered: %s" % sys.exc_value 2248 2248 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2249 2249 return … … 2256 2256 is_modified = True 2257 2257 else: 2258 msg = "Cannot Plot :No npts in that Qrange!!! "2258 msg = "Cannot Plot: No points in Q range!!! " 2259 2259 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2260 2260 else: 2261 2261 tcrtl.SetBackgroundColour("pink") 2262 msg = "Model Error: wrong value entered!!!"2262 msg = "Model Error: wrong value entered!!!" 2263 2263 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2264 2264 self.save_current_state() … … 2431 2431 self.qmax.SetBackgroundColour("pink") 2432 2432 self.qmax.Refresh() 2433 msg = " Npts of Data Error :"2434 msg += " No or too little npts of%s." % data.name2433 msg = "Data Error: " 2434 msg += "Too few points in %s." % data.name 2435 2435 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2436 2436 self.fitrange = False … … 2466 2466 self.qmax.SetBackgroundColour("pink") 2467 2467 self.qmax.Refresh() 2468 msg = " Npts of Data Error :"2469 msg += " No or too little npts of%s." % data.name2468 msg = "Data Error: " 2469 msg += "Too few points in %s." % data.name 2470 2470 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2471 2471 self.fitrange = False … … 2518 2518 2519 2519 except: 2520 msg = "Wrong Fit parameter range entered"2520 msg = "Wrong fit parameter range entered" 2521 2521 wx.PostEvent(self._manager.parent, 2522 2522 StatusEvent(status=msg)) … … 2986 2986 self.qmin.SetValue(str(self.qmin_x)) 2987 2987 self.qmax.SetValue(str(self.qmax_x)) 2988 self.s et_npts2fit()2988 self.show_npts2fit() 2989 2989 # At this point, some button and variables satatus (disabled?) 2990 2990 # should be checked such as color that should be reset to … … 3874 3874 to fit if implemented 3875 3875 """ 3876 def s et_npts2fit(self):3876 def show_npts2fit(self): 3877 3877 """ 3878 3878 setValue Npts for fitting if implemented -
src/sans/perspectives/fitting/console.py
r5777106 r35086c3 5 5 import time 6 6 import wx 7 import park 8 from park.fitresult import FitHandler 7 from sans.fit import FitHandler 9 8 10 9 class ConsoleUpdate(FitHandler): … … 88 87 Print result object 89 88 """ 90 msg = " \n %s \n" % s elf.result.__str__()89 msg = " \n %s \n" % str(self.result) 91 90 wx.PostEvent(self.parent, StatusEvent(status=msg)) 92 91 … … 129 128 130 129 131 def update_fit(self, msg="",last=False):130 def update_fit(self, last=False): 132 131 """ 133 132 """ … … 136 135 self.update_duration = t1 137 136 self.fit_duration += self.elapsed_time 138 str_time = time.strftime("% a, %d %b %Y%H:%M:%S ", time.localtime(t1))139 UPDATE_INTERVAL = 0.5137 str_time = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(t1)) 138 UPDATE_INTERVAL = 5.0 140 139 u_flag = False 141 140 if self.fit_duration >= UPDATE_INTERVAL: 142 141 self.fit_duration = 0 143 142 u_flag = True 144 if not last: 145 msg += "Fit Updates ... %s \n" % str_time 146 else: 147 msg += "Final updates ........." 143 msg = str_time 148 144 if u_flag or last: 149 145 if self.result is not None: … … 164 160 msg += str(self.result) 165 161 msg += "\n" 166 if not last:167 msg += "About %s s elapsed......... \n" % \168 str (UPDATE_INTERVAL)169 162 else: 170 163 msg += "No result available\n" -
src/sans/perspectives/fitting/fit_thread.py
ra855fec re3efa6b3 18 18 19 19 def __init__(self, 20 21 22 23 24 batch_inputs=None,25 20 fn, 21 page_id, 22 handler, 23 batch_outputs, 24 batch_inputs=None, 25 pars=None, 26 26 completefn = None, 27 27 updatefn = None, … … 30 30 ftol = None, 31 31 reset_flag = False): 32 CalcThread.__init__(self,completefn, 32 CalcThread.__init__(self, 33 completefn, 33 34 updatefn, 34 35 yieldtime, … … 80 81 list_map_get_attr.append(map_getattr) 81 82 #from multiprocessing import Pool 82 inputs = zip(list_map_get_attr, self.fitter, list_fit_function,83 83 inputs = zip(list_map_get_attr, self.fitter, list_fit_function, 84 list_q, list_q, list_handler,list_curr_thread,list_ftol, 84 85 list_reset_flag) 85 86 result = map(map_apply, inputs) … … 87 88 self.complete(result=result, 88 89 batch_inputs=self.batch_inputs, 89 90 batch_outputs=self.batch_outputs, 90 91 page_id=self.page_id, 91 92 pars = self.pars, -
src/sans/perspectives/fitting/fitpage.py
rd44648e rbf5e985 661 661 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 662 662 663 if self.engine_type == "park": 664 self.text_disp_max.Show(True) 665 self.text_disp_min.Show(True) 663 self.text_disp_max.Show(True) 664 self.text_disp_min.Show(True) 666 665 667 666 for item in self.model.dispersion.keys(): … … 738 737 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 739 738 740 if self.engine_type == "park": 741 ctl3.Show(True) 742 ctl4.Show(True) 739 ctl3.Show(True) 740 ctl4.Show(True) 743 741 744 742 elif p == "npts": … … 1005 1003 return 1006 1004 1007 if len(self._manager.fit_thread_list) > 0 and\1008 self._manager._fit_engine != "park" and\1009 self._manager.sim_page != None and \1010 self._manager.sim_page.uid == self.uid:1005 if (len(self._manager.fit_thread_list) > 0 1006 and self._manager._fit_engine not in ("park","bumps") 1007 and self._manager.sim_page != None 1008 and self._manager.sim_page.uid == self.uid): 1011 1009 msg = "The FitEnging will be set to 'ParkMC'\n" 1012 1010 msg += " to fit with more than one data set..." … … 1268 1266 if check_float(tcrtl): 1269 1267 flag = self._onparamEnter_helper() 1270 self.s et_npts2fit()1268 self.show_npts2fit() 1271 1269 if self.fitrange: 1272 1270 temp_smearer = None … … 1468 1466 #self.data.mask = index_data 1469 1467 #self.Npts_fit.SetValue(str(len(self.data.mask))) 1470 self.s et_npts2fit()1468 self.show_npts2fit() 1471 1469 else: 1472 1470 index_data = ((self.qmin_x <= self.data.x) & \ … … 1766 1764 # try re draw the model plot if it exists 1767 1765 self._draw_model() 1768 self.s et_npts2fit()1766 self.show_npts2fit() 1769 1767 elif self.model == None: 1770 1768 self.panel.MakeModal(False) 1771 1769 event.Skip() 1772 self.s et_npts2fit()1770 self.show_npts2fit() 1773 1771 msg = "No model is found on updating MASK in the model plot... " 1774 1772 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) … … 2056 2054 return npts2fit 2057 2055 2058 def s et_npts2fit(self):2056 def show_npts2fit(self): 2059 2057 """ 2060 2058 setValue Npts for fitting … … 2068 2066 return self.tcChi.GetValue() 2069 2067 2070 def get_param_list(self):2071 """2072 :return self.param_toFit: list containing references to TextCtrl2073 checked.Theses TextCtrl will allow reference to parameters to fit.2074 2075 :raise: if return an empty list of parameter fit will nnote work2076 properly so raise ValueError,"missing parameter to fit"2077 """2078 if self.param_toFit != []:2079 return self.param_toFit2080 else:2081 msg = "missing parameters to fit"2082 wx.MessageBox(msg, 'warning')2083 return False2084 2085 2068 def onsetValues(self, chisqr, p_name, out, cov): 2086 2069 """ … … 2108 2091 if chisqr != None and numpy.isfinite(chisqr): 2109 2092 #format chi2 2110 if self.engine_type == "park":2111 npt_fit = float(self.get_npts2fit())2112 2093 chi2 = format_number(chisqr, True) 2113 2094 self.tcChi.SetValue(chi2) -
src/sans/perspectives/fitting/fitpanel.py
rb6a181b reff93b8 64 64 self.sim_page = None 65 65 self.batch_page = None 66 self.fit_engine_type = " scipy"66 self.fit_engine_type = "bumps" 67 67 ## get the state of a page 68 68 self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) -
src/sans/perspectives/fitting/fitproblem.py
r5777106 r5bf0331 454 454 return self.itervalues() 455 455 456 def 456 def set_result(self, result, fid): 457 457 """ 458 458 """ -
src/sans/perspectives/fitting/simfitpage.py
r5777106 rbf5e985 138 138 self.Layout() 139 139 break 140 self._onAdd_constraint(None) 140 141 #self._onAdd_constraint(None) 141 142 142 143 def onFit(self, event): … … 152 153 ## making sure all parameters content a constraint 153 154 ## validity of the constraint expression is own by fit engine 154 if self.parent._manager._fit_engine != "park"and flag:155 if self.parent._manager._fit_engine not in ("park","bumps") and flag: 155 156 msg = "The FitEnging will be set to 'Park' fit engine\n" 156 157 msg += " for the simultaneous fit..." … … 378 379 box_description = wx.StaticBox(self, -1,"Easy Setup ") 379 380 boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) 380 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL |wx.LEFT|wx.RIGHT|wx.EXPAND)381 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 381 382 self.model_cbox_left = wx.ComboBox(self, -1, style=wx.CB_READONLY) 382 383 self.model_cbox_left.Clear() … … 814 815 815 816 for fid in self.page_finder[id].iterkeys(): 816 self.page_finder[id].set_model_param(param, 817 constraint, fid=fid) 817 # wrap in param/constraint in str() to remove unicode 818 self.page_finder[id].set_model_param(str(param), 819 str(constraint), fid=fid) 818 820 break 819 821 return True
Note: See TracChangeset
for help on using the changeset viewer.