Changeset 9a5097c in sasview for src/sas/sasgui/perspectives/fitting/fitting.py
- Timestamp:
- Mar 26, 2017 11:33:16 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:
- ed2276f
- Parents:
- 9146ed9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitting.py
rddbac66 r9a5097c 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 … … 1332 1332 new_theory = copy_data.data 1333 1333 new_theory[res.index] = res.theory 1334 new_theory[res.index == False] = n umpy.nan1334 new_theory[res.index == False] = np.nan 1335 1335 correct_result = True 1336 1336 #get all fittable parameters of the current model … … 1341 1341 param_list.remove(param) 1342 1342 if not correct_result or res.fitness is None or \ 1343 not n umpy.isfinite(res.fitness) or \1344 numpy.any(res.pvec == None) or not \1345 numpy.all(numpy.isfinite(res.pvec)):1343 not np.isfinite(res.fitness) or \ 1344 np.any(res.pvec == None) or not \ 1345 np.all(np.isfinite(res.pvec)): 1346 1346 data_name = str(None) 1347 1347 if data is not None: … … 1352 1352 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1353 1353 model_name) 1354 ERROR = n umpy.NAN1354 ERROR = np.NAN 1355 1355 cell = BatchCell() 1356 1356 cell.label = res.fitness … … 1366 1366 batch_inputs["error on %s" % str(param)].append(ERROR) 1367 1367 else: 1368 # TODO: Why sometimes res.pvec comes with n umpy.float64?1368 # TODO: Why sometimes res.pvec comes with np.float64? 1369 1369 # probably from scipy lmfit 1370 if res.pvec.__class__ == n umpy.float64:1370 if res.pvec.__class__ == np.float64: 1371 1371 res.pvec = [res.pvec] 1372 1372 … … 1533 1533 fit_msg = res.mesg 1534 1534 if res.fitness is None or \ 1535 not n umpy.isfinite(res.fitness) or \1536 numpy.any(res.pvec == None) or \1537 not n umpy.all(numpy.isfinite(res.pvec)):1535 not np.isfinite(res.fitness) or \ 1536 np.any(res.pvec == None) or \ 1537 not np.all(np.isfinite(res.pvec)): 1538 1538 fit_msg += "\nFitting did not converge!!!" 1539 1539 wx.CallAfter(self._update_fit_button, page_id) 1540 1540 else: 1541 1541 #set the panel when fit result are float not list 1542 if res.pvec.__class__ == n umpy.float64:1542 if res.pvec.__class__ == np.float64: 1543 1543 pvec = [res.pvec] 1544 1544 else: 1545 1545 pvec = res.pvec 1546 if res.stderr.__class__ == n umpy.float64:1546 if res.stderr.__class__ == np.float64: 1547 1547 stderr = [res.stderr] 1548 1548 else: … … 1692 1692 if dy is None: 1693 1693 new_plot.is_data = False 1694 new_plot.dy = n umpy.zeros(len(y))1694 new_plot.dy = np.zeros(len(y)) 1695 1695 # If this is a theory curve, pick the proper symbol to make it a curve 1696 1696 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM … … 1741 1741 """ 1742 1742 try: 1743 n umpy.nan_to_num(y)1743 np.nan_to_num(y) 1744 1744 new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 1745 1745 data_description=model.name, … … 1826 1826 that can be plot. 1827 1827 """ 1828 n umpy.nan_to_num(image)1828 np.nan_to_num(image) 1829 1829 new_plot = Data2D(image=image, err_image=data.err_data) 1830 1830 new_plot.name = model.name + '2d' … … 2018 2018 if data_copy.__class__.__name__ == "Data2D": 2019 2019 if index == None: 2020 index = n umpy.ones(len(data_copy.data), dtype=bool)2020 index = np.ones(len(data_copy.data), dtype=bool) 2021 2021 if weight != None: 2022 2022 data_copy.err_data = weight 2023 2023 # get rid of zero error points 2024 2024 index = index & (data_copy.err_data != 0) 2025 index = index & (n umpy.isfinite(data_copy.data))2025 index = index & (np.isfinite(data_copy.data)) 2026 2026 fn = data_copy.data[index] 2027 2027 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) … … 2033 2033 # 1 d theory from model_thread is only in the range of index 2034 2034 if index == None: 2035 index = n umpy.ones(len(data_copy.y), dtype=bool)2035 index = np.ones(len(data_copy.y), dtype=bool) 2036 2036 if weight != None: 2037 2037 data_copy.dy = weight 2038 2038 if data_copy.dy == None or data_copy.dy == []: 2039 dy = n umpy.ones(len(data_copy.y))2039 dy = np.ones(len(data_copy.y)) 2040 2040 else: 2041 2041 ## Set consistently w/AbstractFitengine: … … 2058 2058 return 2059 2059 2060 residuals = res[n umpy.isfinite(res)]2060 residuals = res[np.isfinite(res)] 2061 2061 # get chisqr only w/finite 2062 chisqr = n umpy.average(residuals * residuals)2062 chisqr = np.average(residuals * residuals) 2063 2063 2064 2064 self._plot_residuals(page_id=page_id, data=data_copy, … … 2097 2097 residuals.qy_data = data_copy.qy_data 2098 2098 residuals.q_data = data_copy.q_data 2099 residuals.err_data = n umpy.ones(len(residuals.data))2099 residuals.err_data = np.ones(len(residuals.data)) 2100 2100 residuals.xmin = min(residuals.qx_data) 2101 2101 residuals.xmax = max(residuals.qx_data) … … 2111 2111 # 1 d theory from model_thread is only in the range of index 2112 2112 if data_copy.dy == None or data_copy.dy == []: 2113 dy = n umpy.ones(len(data_copy.y))2113 dy = np.ones(len(data_copy.y)) 2114 2114 else: 2115 2115 if weight == None: 2116 dy = n umpy.ones(len(data_copy.y))2116 dy = np.ones(len(data_copy.y)) 2117 2117 ## Set consitently w/AbstractFitengine: 2118 2118 ## But this should be corrected later. … … 2133 2133 residuals.y = (fn - gn[index]) / en 2134 2134 residuals.x = data_copy.x[index] 2135 residuals.dy = n umpy.ones(len(residuals.y))2135 residuals.dy = np.ones(len(residuals.y)) 2136 2136 residuals.dx = None 2137 2137 residuals.dxl = None
Note: See TracChangeset
for help on using the changeset viewer.