Changeset 9c0f3c17 in sasview for src/sas/sasgui/perspectives/fitting/fitting.py
- Timestamp:
- Apr 4, 2017 12:50:04 PM (7 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:
- f2940c4
- Parents:
- 463e7ffc (diff), 1779e72 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitting.py
r463e7ffc r9c0f3c17 16 16 import wx 17 17 import logging 18 import numpy 18 import numpy as np 19 19 import time 20 20 from copy import deepcopy … … 878 878 qmin=qmin, qmax=qmax, weight=weight) 879 879 880 def _mac_sleep(self, sec=0.2):881 """882 Give sleep to MAC883 """884 if ON_MAC:885 time.sleep(sec)886 887 880 def draw_model(self, model, page_id, data=None, smearer=None, 888 881 enable1D=True, enable2D=False, … … 1032 1025 manager=self, 1033 1026 improvement_delta=0.1) 1034 self._mac_sleep(0.2)1035 1027 1036 1028 # batch fit … … 1272 1264 :param elapsed: time spent at the fitting level 1273 1265 """ 1274 self._mac_sleep(0.2)1275 1266 uid = page_id[0] 1276 1267 if uid in self.fit_thread_list.keys(): … … 1334 1325 new_theory = copy_data.data 1335 1326 new_theory[res.index] = res.theory 1336 new_theory[res.index == False] = n umpy.nan1327 new_theory[res.index == False] = np.nan 1337 1328 correct_result = True 1338 1329 #get all fittable parameters of the current model … … 1343 1334 param_list.remove(param) 1344 1335 if not correct_result or res.fitness is None or \ 1345 not n umpy.isfinite(res.fitness) or \1346 numpy.any(res.pvec == None) or not \1347 numpy.all(numpy.isfinite(res.pvec)):1336 not np.isfinite(res.fitness) or \ 1337 np.any(res.pvec == None) or not \ 1338 np.all(np.isfinite(res.pvec)): 1348 1339 data_name = str(None) 1349 1340 if data is not None: … … 1354 1345 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1355 1346 model_name) 1356 ERROR = n umpy.NAN1347 ERROR = np.NAN 1357 1348 cell = BatchCell() 1358 1349 cell.label = res.fitness … … 1368 1359 batch_inputs["error on %s" % str(param)].append(ERROR) 1369 1360 else: 1370 # TODO: Why sometimes res.pvec comes with n umpy.float64?1361 # TODO: Why sometimes res.pvec comes with np.float64? 1371 1362 # probably from scipy lmfit 1372 if res.pvec.__class__ == n umpy.float64:1363 if res.pvec.__class__ == np.float64: 1373 1364 res.pvec = [res.pvec] 1374 1365 … … 1522 1513 page_id = [] 1523 1514 ## fit more than 1 model at the same time 1524 self._mac_sleep(0.2)1525 1515 try: 1526 1516 index = 0 … … 1535 1525 fit_msg = res.mesg 1536 1526 if res.fitness is None or \ 1537 not n umpy.isfinite(res.fitness) or \1538 numpy.any(res.pvec == None) or \1539 not n umpy.all(numpy.isfinite(res.pvec)):1527 not np.isfinite(res.fitness) or \ 1528 np.any(res.pvec == None) or \ 1529 not np.all(np.isfinite(res.pvec)): 1540 1530 fit_msg += "\nFitting did not converge!!!" 1541 1531 wx.CallAfter(self._update_fit_button, page_id) 1542 1532 else: 1543 1533 #set the panel when fit result are float not list 1544 if res.pvec.__class__ == n umpy.float64:1534 if res.pvec.__class__ == np.float64: 1545 1535 pvec = [res.pvec] 1546 1536 else: 1547 1537 pvec = res.pvec 1548 if res.stderr.__class__ == n umpy.float64:1538 if res.stderr.__class__ == np.float64: 1549 1539 stderr = [res.stderr] 1550 1540 else: … … 1694 1684 if dy is None: 1695 1685 new_plot.is_data = False 1696 new_plot.dy = n umpy.zeros(len(y))1686 new_plot.dy = np.zeros(len(y)) 1697 1687 # If this is a theory curve, pick the proper symbol to make it a curve 1698 1688 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM … … 1743 1733 """ 1744 1734 try: 1745 n umpy.nan_to_num(y)1735 np.nan_to_num(y) 1746 1736 new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 1747 1737 data_description=model.name, … … 1827 1817 that can be plot. 1828 1818 """ 1829 n umpy.nan_to_num(image)1819 np.nan_to_num(image) 1830 1820 new_plot = Data2D(image=image, err_image=data.err_data) 1831 1821 new_plot.name = model.name + '2d' … … 2019 2009 if data_copy.__class__.__name__ == "Data2D": 2020 2010 if index == None: 2021 index = n umpy.ones(len(data_copy.data), dtype=bool)2011 index = np.ones(len(data_copy.data), dtype=bool) 2022 2012 if weight != None: 2023 2013 data_copy.err_data = weight 2024 2014 # get rid of zero error points 2025 2015 index = index & (data_copy.err_data != 0) 2026 index = index & (n umpy.isfinite(data_copy.data))2016 index = index & (np.isfinite(data_copy.data)) 2027 2017 fn = data_copy.data[index] 2028 2018 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) … … 2034 2024 # 1 d theory from model_thread is only in the range of index 2035 2025 if index == None: 2036 index = n umpy.ones(len(data_copy.y), dtype=bool)2026 index = np.ones(len(data_copy.y), dtype=bool) 2037 2027 if weight != None: 2038 2028 data_copy.dy = weight 2039 2029 if data_copy.dy == None or data_copy.dy == []: 2040 dy = n umpy.ones(len(data_copy.y))2030 dy = np.ones(len(data_copy.y)) 2041 2031 else: 2042 2032 ## Set consistently w/AbstractFitengine: … … 2059 2049 return 2060 2050 2061 residuals = res[n umpy.isfinite(res)]2051 residuals = res[np.isfinite(res)] 2062 2052 # get chisqr only w/finite 2063 chisqr = n umpy.average(residuals * residuals)2053 chisqr = np.average(residuals * residuals) 2064 2054 2065 2055 self._plot_residuals(page_id=page_id, data=data_copy, … … 2098 2088 residuals.qy_data = data_copy.qy_data 2099 2089 residuals.q_data = data_copy.q_data 2100 residuals.err_data = n umpy.ones(len(residuals.data))2090 residuals.err_data = np.ones(len(residuals.data)) 2101 2091 residuals.xmin = min(residuals.qx_data) 2102 2092 residuals.xmax = max(residuals.qx_data) … … 2112 2102 # 1 d theory from model_thread is only in the range of index 2113 2103 if data_copy.dy == None or data_copy.dy == []: 2114 dy = n umpy.ones(len(data_copy.y))2104 dy = np.ones(len(data_copy.y)) 2115 2105 else: 2116 2106 if weight == None: 2117 dy = n umpy.ones(len(data_copy.y))2107 dy = np.ones(len(data_copy.y)) 2118 2108 ## Set consitently w/AbstractFitengine: 2119 2109 ## But this should be corrected later. … … 2134 2124 residuals.y = (fn - gn[index]) / en 2135 2125 residuals.x = data_copy.x[index] 2136 residuals.dy = n umpy.ones(len(residuals.y))2126 residuals.dy = np.ones(len(residuals.y)) 2137 2127 residuals.dx = None 2138 2128 residuals.dxl = None
Note: See TracChangeset
for help on using the changeset viewer.