Changeset 9c0f3c17 in sasview for src/sas/sasgui/perspectives/fitting
- Timestamp:
- Apr 4, 2017 12:50:04 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.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. - Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r463e7ffc r9c0f3c17 5 5 import os 6 6 import wx 7 import numpy 7 import numpy as np 8 8 import time 9 9 import copy … … 101 101 self.graph_id = None 102 102 # Q range for data set 103 self.qmin_data_set = n umpy.inf103 self.qmin_data_set = np.inf 104 104 self.qmax_data_set = None 105 105 self.npts_data_set = 0 … … 279 279 280 280 """ 281 x = n umpy.linspace(start=self.qmin_x, stop=self.qmax_x,281 x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 282 282 num=self.npts_x, endpoint=True) 283 283 self.data = Data1D(x=x) … … 296 296 """ 297 297 if self.qmin_x >= 1.e-10: 298 qmin = n umpy.log10(self.qmin_x)298 qmin = np.log10(self.qmin_x) 299 299 else: 300 300 qmin = -10. 301 301 302 302 if self.qmax_x <= 1.e10: 303 qmax = n umpy.log10(self.qmax_x)303 qmax = np.log10(self.qmax_x) 304 304 else: 305 305 qmax = 10. 306 306 307 x = n umpy.logspace(start=qmin, stop=qmax,307 x = np.logspace(start=qmin, stop=qmax, 308 308 num=self.npts_x, endpoint=True, base=10.0) 309 309 self.data = Data1D(x=x) … … 342 342 qstep = self.npts_x 343 343 344 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)345 y = n umpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)344 x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 345 y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 346 346 # use data info instead 347 new_x = n umpy.tile(x, (len(y), 1))348 new_y = n umpy.tile(y, (len(x), 1))347 new_x = np.tile(x, (len(y), 1)) 348 new_y = np.tile(y, (len(x), 1)) 349 349 new_y = new_y.swapaxes(0, 1) 350 350 # all data reuire now in 1d array 351 351 qx_data = new_x.flatten() 352 352 qy_data = new_y.flatten() 353 q_data = n umpy.sqrt(qx_data * qx_data + qy_data * qy_data)353 q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 354 354 # set all True (standing for unmasked) as default 355 mask = n umpy.ones(len(qx_data), dtype=bool)355 mask = np.ones(len(qx_data), dtype=bool) 356 356 # store x and y bin centers in q space 357 357 x_bins = x … … 359 359 360 360 self.data.source = Source() 361 self.data.data = n umpy.ones(len(mask))362 self.data.err_data = n umpy.ones(len(mask))361 self.data.data = np.ones(len(mask)) 362 self.data.err_data = np.ones(len(mask)) 363 363 self.data.qx_data = qx_data 364 364 self.data.qy_data = qy_data … … 784 784 # Skip non-data lines 785 785 logger.error(traceback.format_exc()) 786 return n umpy.array(angles), numpy.array(weights)786 return np.array(angles), np.array(weights) 787 787 except: 788 788 raise … … 1450 1450 self.state_change = True 1451 1451 self._draw_model() 1452 # Time delay has been introduced to prevent _handle error1453 # on Windows1454 # This part of code is executed when model is selected and1455 # it's parameters are changed (with respect to previously1456 # selected model). There are two Iq evaluations occuring one1457 # after another and therefore there may be compilation error1458 # if model is calculated for the first time.1459 # This seems to be Windows only issue - haven't tested on Linux1460 # though.The proper solution (other than time delay) requires1461 # more fundemental code refatoring1462 # Wojtek P. Nov 7, 20161463 if not ON_MAC:1464 time.sleep(0.1)1465 1452 self.Refresh() 1466 1453 … … 2121 2108 for data in self.data_list: 2122 2109 # q value from qx and qy 2123 radius = n umpy.sqrt(data.qx_data * data.qx_data +2110 radius = np.sqrt(data.qx_data * data.qx_data + 2124 2111 data.qy_data * data.qy_data) 2125 2112 # get unmasked index … … 2127 2114 (radius <= float(self.qmax.GetValue())) 2128 2115 index_data = (index_data) & (data.mask) 2129 index_data = (index_data) & (n umpy.isfinite(data.data))2116 index_data = (index_data) & (np.isfinite(data.data)) 2130 2117 2131 2118 if len(index_data[index_data]) < 10: … … 2162 2149 index_data = (float(self.qmin.GetValue()) <= radius) & \ 2163 2150 (radius <= float(self.qmax.GetValue())) 2164 index_data = (index_data) & (n umpy.isfinite(data.y))2151 index_data = (index_data) & (np.isfinite(data.y)) 2165 2152 2166 2153 if len(index_data[index_data]) < 5: … … 2234 2221 2235 2222 # Check that min is less than max 2236 low = -n umpy.inf if min_str == "" else float(min_str)2237 high = n umpy.inf if max_str == "" else float(max_str)2223 low = -np.inf if min_str == "" else float(min_str) 2224 high = np.inf if max_str == "" else float(max_str) 2238 2225 if high < low: 2239 2226 min_ctrl.SetBackgroundColour("pink") … … 2610 2597 Layout is called after fitting. 2611 2598 """ 2612 self._sleep4sec()2613 2599 self.Layout() 2614 2600 return 2615 2616 def _sleep4sec(self):2617 """2618 sleep for 1 sec only applied on Mac2619 Note: This 1sec helps for Mac not to crash on self.2620 Layout after self._draw_model2621 """2622 if ON_MAC:2623 time.sleep(1)2624 2601 2625 2602 def _find_polyfunc_selection(self, disp_func=None): … … 2655 2632 self.qmin_x = data_min 2656 2633 self.qmax_x = math.sqrt(x * x + y * y) 2657 # self.data.mask = n umpy.ones(len(self.data.data),dtype=bool)2634 # self.data.mask = np.ones(len(self.data.data),dtype=bool) 2658 2635 # check smearing 2659 2636 if not self.disable_smearer.GetValue(): … … 3367 3344 3368 3345 if value[1] == 'array': 3369 pd_vals = n umpy.array(value[2])3370 pd_weights = n umpy.array(value[3])3346 pd_vals = np.array(value[2]) 3347 pd_weights = np.array(value[3]) 3371 3348 if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 3372 3349 msg = ("bad array distribution parameters for %s" -
src/sas/sasgui/perspectives/fitting/fitpage.py
rd85f1d8a red2276f 6 6 import wx 7 7 import wx.lib.newevent 8 import numpy 8 import numpy as np 9 9 import copy 10 10 import math … … 1115 1115 if item.GetValue(): 1116 1116 if button_list.index(item) == 0: 1117 flag = 0 # dy = n umpy.ones_like(dy_data)1117 flag = 0 # dy = np.ones_like(dy_data) 1118 1118 elif button_list.index(item) == 1: 1119 1119 flag = 1 # dy = dy_data 1120 1120 elif button_list.index(item) == 2: 1121 flag = 2 # dy = n umpy.sqrt(numpy.abs(data))1121 flag = 2 # dy = np.sqrt(np.abs(data)) 1122 1122 elif button_list.index(item) == 3: 1123 flag = 3 # dy = n umpy.abs(data)1123 flag = 3 # dy = np.abs(data) 1124 1124 break 1125 1125 return flag … … 1422 1422 key = event.GetKeyCode() 1423 1423 length = len(self.data.x) 1424 indx = (n umpy.abs(self.data.x - x_data)).argmin()1424 indx = (np.abs(self.data.x - x_data)).argmin() 1425 1425 # return array.flat[idx] 1426 1426 if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: … … 1477 1477 self.enable2D: 1478 1478 # set mask 1479 radius = n umpy.sqrt(self.data.qx_data * self.data.qx_data +1479 radius = np.sqrt(self.data.qx_data * self.data.qx_data + 1480 1480 self.data.qy_data * self.data.qy_data) 1481 1481 index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x)) 1482 1482 index_data = (index_data) & (self.data.mask) 1483 index_data = (index_data) & (n umpy.isfinite(self.data.data))1483 index_data = (index_data) & (np.isfinite(self.data.data)) 1484 1484 if len(index_data[index_data]) < 10: 1485 1485 msg = "Cannot Plot :No or too little npts in" … … 1598 1598 and data.dqx_data.any() != 0: 1599 1599 self.smear_type = "Pinhole2d" 1600 self.dq_l = format_number(n umpy.average(data.dqx_data))1601 self.dq_r = format_number(n umpy.average(data.dqy_data))1600 self.dq_l = format_number(np.average(data.dqx_data)) 1601 self.dq_r = format_number(np.average(data.dqy_data)) 1602 1602 return 1603 1603 else: 1604 1604 return 1605 1605 # check if it is pinhole smear and get min max if it is. 1606 if data.dx is not None and n umpy.any(data.dx):1606 if data.dx is not None and np.any(data.dx): 1607 1607 self.smear_type = "Pinhole" 1608 1608 self.dq_l = data.dx[0] … … 1612 1612 elif data.dxl is not None or data.dxw is not None: 1613 1613 self.smear_type = "Slit" 1614 if data.dxl is not None and n umpy.all(data.dxl, 0):1614 if data.dxl is not None and np.all(data.dxl, 0): 1615 1615 self.dq_l = data.dxl[0] 1616 if data.dxw is not None and n umpy.all(data.dxw, 0):1616 if data.dxw is not None and np.all(data.dxw, 0): 1617 1617 self.dq_r = data.dxw[0] 1618 1618 # return self.smear_type,self.dq_l,self.dq_r … … 1808 1808 if not flag: 1809 1809 self.onSmear(None) 1810 1811 def _mac_sleep(self, sec=0.2):1812 """1813 Give sleep to MAC1814 """1815 if self.is_mac:1816 time.sleep(sec)1817 1810 1818 1811 def get_view_mode(self): … … 1921 1914 self.default_mask = copy.deepcopy(self.data.mask) 1922 1915 if self.data.err_data is not None \ 1923 and n umpy.any(self.data.err_data):1916 and np.any(self.data.err_data): 1924 1917 di_flag = True 1925 1918 if self.data.dqx_data is not None \ 1926 and n umpy.any(self.data.dqx_data):1919 and np.any(self.data.dqx_data): 1927 1920 dq_flag = True 1928 1921 else: 1929 1922 self.slit_smearer.Enable(True) 1930 1923 self.pinhole_smearer.Enable(True) 1931 if self.data.dy is not None and n umpy.any(self.data.dy):1924 if self.data.dy is not None and np.any(self.data.dy): 1932 1925 di_flag = True 1933 if self.data.dx is not None and n umpy.any(self.data.dx):1926 if self.data.dx is not None and np.any(self.data.dx): 1934 1927 dq_flag = True 1935 elif self.data.dxl is not None and n umpy.any(self.data.dxl):1928 elif self.data.dxl is not None and np.any(self.data.dxl): 1936 1929 dq_flag = True 1937 1930 … … 2067 2060 if self.data.__class__.__name__ == "Data2D" or \ 2068 2061 self.enable2D: 2069 radius = n umpy.sqrt(self.data.qx_data * self.data.qx_data +2062 radius = np.sqrt(self.data.qx_data * self.data.qx_data + 2070 2063 self.data.qy_data * self.data.qy_data) 2071 2064 index_data = (self.qmin_x <= radius) & (radius <= self.qmax_x) 2072 2065 index_data = (index_data) & (self.data.mask) 2073 index_data = (index_data) & (n umpy.isfinite(self.data.data))2066 index_data = (index_data) & (np.isfinite(self.data.data)) 2074 2067 npts2fit = len(self.data.data[index_data]) 2075 2068 else: … … 2104 2097 # make sure stop button to fit button all the time 2105 2098 self._on_fit_complete() 2106 if out is None or not n umpy.isfinite(chisqr):2099 if out is None or not np.isfinite(chisqr): 2107 2100 raise ValueError, "Fit error occured..." 2108 2101 … … 2115 2108 2116 2109 # Check if chi2 is finite 2117 if chisqr is not None and n umpy.isfinite(chisqr):2110 if chisqr is not None and np.isfinite(chisqr): 2118 2111 # format chi2 2119 2112 chi2 = format_number(chisqr, True) … … 2167 2160 2168 2161 if cov[ind] is not None: 2169 if n umpy.isfinite(float(cov[ind])):2162 if np.isfinite(float(cov[ind])): 2170 2163 val_err = format_number(cov[ind], True) 2171 2164 item[4].SetForegroundColour(wx.BLACK) … … 2188 2181 self.save_current_state() 2189 2182 2190 if not self.is_mac:2191 self.Layout()2192 self.Refresh()2193 self._mac_sleep(0.1)2194 2183 # plot model ( when drawing, do not update chisqr value again) 2195 2184 self._draw_model(update_chisqr=False, source='fit') … … 2291 2280 self.smear_type = 'Pinhole2d' 2292 2281 len_data = len(data.data) 2293 data.dqx_data = n umpy.zeros(len_data)2294 data.dqy_data = n umpy.zeros(len_data)2282 data.dqx_data = np.zeros(len_data) 2283 data.dqy_data = np.zeros(len_data) 2295 2284 else: 2296 2285 self.smear_type = 'Pinhole' 2297 2286 len_data = len(data.x) 2298 data.dx = n umpy.zeros(len_data)2287 data.dx = np.zeros(len_data) 2299 2288 data.dxl = None 2300 2289 data.dxw = None … … 2469 2458 try: 2470 2459 self.dxl = float(self.smear_slit_height.GetValue()) 2471 data.dxl = self.dxl * n umpy.ones(data_len)2460 data.dxl = self.dxl * np.ones(data_len) 2472 2461 self.smear_slit_height.SetBackgroundColour(wx.WHITE) 2473 2462 except: 2474 2463 self.dxl = None 2475 data.dxl = n umpy.zeros(data_len)2464 data.dxl = np.zeros(data_len) 2476 2465 if self.smear_slit_height.GetValue().lstrip().rstrip() != "": 2477 2466 self.smear_slit_height.SetBackgroundColour("pink") … … 2482 2471 self.dxw = float(self.smear_slit_width.GetValue()) 2483 2472 self.smear_slit_width.SetBackgroundColour(wx.WHITE) 2484 data.dxw = self.dxw * n umpy.ones(data_len)2473 data.dxw = self.dxw * np.ones(data_len) 2485 2474 except: 2486 2475 self.dxw = None 2487 data.dxw = n umpy.zeros(data_len)2476 data.dxw = np.zeros(data_len) 2488 2477 if self.smear_slit_width.GetValue().lstrip().rstrip() != "": 2489 2478 self.smear_slit_width.SetBackgroundColour("pink") … … 2612 2601 if event is None: 2613 2602 output = "-" 2614 elif not n umpy.isfinite(event.output):2603 elif not np.isfinite(event.output): 2615 2604 output = "-" 2616 2605 else: -
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 -
src/sas/sasgui/perspectives/fitting/model_thread.py
rc1c9929 r9a5097c 4 4 5 5 import time 6 import numpy 6 import numpy as np 7 7 import math 8 8 from sas.sascalc.data_util.calcthread import CalcThread … … 68 68 69 69 # Define matrix where data will be plotted 70 radius = n umpy.sqrt((self.data.qx_data * self.data.qx_data) + \70 radius = np.sqrt((self.data.qx_data * self.data.qx_data) + \ 71 71 (self.data.qy_data * self.data.qy_data)) 72 72 … … 75 75 index_model = (self.qmin <= radius) & (radius <= self.qmax) 76 76 index_model = index_model & self.data.mask 77 index_model = index_model & n umpy.isfinite(self.data.data)77 index_model = index_model & np.isfinite(self.data.data) 78 78 79 79 if self.smearer is not None: … … 91 91 self.data.qy_data[index_model] 92 92 ]) 93 output = n umpy.zeros(len(self.data.qx_data))93 output = np.zeros(len(self.data.qx_data)) 94 94 # output default is None 95 95 # This method is to distinguish between masked … … 163 163 """ 164 164 self.starttime = time.time() 165 output = n umpy.zeros((len(self.data.x)))165 output = np.zeros((len(self.data.x))) 166 166 index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 167 167 … … 175 175 self.qmax) 176 176 mask = self.data.x[first_bin:last_bin+1] 177 unsmeared_output = n umpy.zeros((len(self.data.x)))177 unsmeared_output = np.zeros((len(self.data.x))) 178 178 unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 179 179 self.smearer.model = self.model … … 183 183 # Check that the arrays are compatible. If we only have a model but no data, 184 184 # the length of data.y will be zero. 185 if isinstance(self.data.y, n umpy.ndarray) and output.shape == self.data.y.shape:186 unsmeared_data = n umpy.zeros((len(self.data.x)))187 unsmeared_error = n umpy.zeros((len(self.data.x)))185 if isinstance(self.data.y, np.ndarray) and output.shape == self.data.y.shape: 186 unsmeared_data = np.zeros((len(self.data.x))) 187 unsmeared_error = np.zeros((len(self.data.x))) 188 188 unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 189 189 * unsmeared_output[first_bin:last_bin+1]\ … … 209 209 210 210 if p_model is not None and s_model is not None: 211 sq_values = n umpy.zeros((len(self.data.x)))212 pq_values = n umpy.zeros((len(self.data.x)))211 sq_values = np.zeros((len(self.data.x))) 212 pq_values = np.zeros((len(self.data.x))) 213 213 sq_values[index] = s_model.evalDistribution(self.data.x[index]) 214 214 pq_values[index] = p_model.evalDistribution(self.data.x[index]) -
src/sas/sasgui/perspectives/fitting/pagestate.py
r463e7ffc r9c0f3c17 18 18 import copy 19 19 import logging 20 import numpy 20 import numpy as np 21 21 import traceback 22 22 … … 412 412 for fittable, name, value, _, uncert, lower, upper, units in params: 413 413 if not value: 414 value = n umpy.nan414 value = np.nan 415 415 if not uncert or uncert[1] == '' or uncert[1] == 'None': 416 416 uncert[0] = False 417 uncert[1] = n umpy.nan417 uncert[1] = np.nan 418 418 if not upper or upper[1] == '' or upper[1] == 'None': 419 419 upper[0] = False 420 upper[1] = n umpy.nan420 upper[1] = np.nan 421 421 if not lower or lower[1] == '' or lower[1] == 'None': 422 422 lower[0] = False 423 lower[1] = n umpy.nan423 lower[1] = np.nan 424 424 if is_string: 425 425 p[name] = str(value) … … 451 451 lower = params.get(name + ".lower", '-inf') 452 452 units = params.get(name + ".units") 453 if std is not None and std is not n umpy.nan:453 if std is not None and std is not np.nan: 454 454 std = [True, str(std)] 455 455 else: 456 456 std = [False, ''] 457 if lower is not None and lower is not n umpy.nan:457 if lower is not None and lower is not np.nan: 458 458 lower = [True, str(lower)] 459 459 else: 460 460 lower = [True, '-inf'] 461 if upper is not None and upper is not n umpy.nan:461 if upper is not None and upper is not np.nan: 462 462 upper = [True, str(upper)] 463 463 else: … … 1102 1102 % (line, tagname, name)) 1103 1103 logger.error(msg + traceback.format_exc()) 1104 dic[name] = n umpy.array(value_list)1104 dic[name] = np.array(value_list) 1105 1105 setattr(self, varname, dic) 1106 1106 -
src/sas/sasgui/perspectives/fitting/utils.py
rd85c194 r9a5097c 2 2 Module contains functions frequently used in this package 3 3 """ 4 import numpy 4 import numpy as np 5 5 6 6 … … 19 19 data = data.y 20 20 if flag == 0: 21 weight = n umpy.ones_like(data)21 weight = np.ones_like(data) 22 22 elif flag == 1: 23 23 weight = dy_data 24 24 elif flag == 2: 25 weight = n umpy.sqrt(numpy.abs(data))25 weight = np.sqrt(np.abs(data)) 26 26 elif flag == 3: 27 weight = n umpy.abs(data)27 weight = np.abs(data) 28 28 return weight -
src/sas/sasgui/perspectives/fitting/models.py
r11b094f r463e7ffc 18 18 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 19 19 from sasmodels.sasview_model import load_custom_model, load_standard_models 20 21 logger = logging.getLogger(__name__) 20 22 21 23 … … 168 170 if not os.path.isdir(dir): 169 171 msg = "SasView couldn't locate Model plugin folder %r." % dir 170 logg ing.warning(msg)172 logger.warning(msg) 171 173 return {} 172 174 173 175 plugin_log("looking for models in: %s" % str(dir)) 174 176 #compile_file(dir) #always recompile the folder plugin 175 logg ing.info("plugin model dir: %s" % str(dir))177 logger.info("plugin model dir: %s" % str(dir)) 176 178 177 179 plugins = {} … … 188 190 msg += "\nwhile accessing model in %r" % path 189 191 plugin_log(msg) 190 logg ing.warning("Failed to load plugin %r. See %s for details"192 logger.warning("Failed to load plugin %r. See %s for details" 191 193 % (path, PLUGIN_LOG)) 192 194 … … 261 263 if self.is_changed(): 262 264 return _findModels(dir) 263 logg ing.info("plugin model : %s" % str(temp))265 logger.info("plugin model : %s" % str(temp)) 264 266 return temp 265 267
Note: See TracChangeset
for help on using the changeset viewer.