Changeset 80a49c2 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Apr 6, 2017 5:55:21 AM (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:
- 8fbf8d6, 5f768c2
- Parents:
- c5251f6 (diff), 5e2f36c (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
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/calculator.py
ra0c1e1d r463e7ffc 28 28 import logging 29 29 30 logger = logging.getLogger(__name__) 31 30 32 class Plugin(PluginBase): 31 33 """ … … 36 38 PluginBase.__init__(self, name="Calculator") 37 39 # Log startup 38 logg ing.info("Calculator plug-in started")40 logger.info("Calculator plug-in started") 39 41 self.sub_menu = "Tool" 40 42 self.data_edit_frame = None -
src/sas/sasgui/perspectives/calculator/data_operator.py
r61780e3 r9a5097c 5 5 import sys 6 6 import time 7 import numpy 7 import numpy as np 8 8 from sas.sascalc.dataloader.data_info import Data1D 9 9 from sas.sasgui.plottools.PlotPanel import PlotPanel … … 541 541 theory, _ = theory_list.values()[0] 542 542 dnames.append(theory.name) 543 ind = n umpy.argsort(dnames)543 ind = np.argsort(dnames) 544 544 if len(ind) > 0: 545 val_list = n umpy.array(self._data.values())[ind]545 val_list = np.array(self._data.values())[ind] 546 546 for datastate in val_list: 547 547 data = datastate.data -
src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py
r0f7c930 r9c0f3c17 7 7 import sys 8 8 import os 9 import numpy 9 import numpy as np 10 10 #import math 11 11 import wx.aui as aui … … 38 38 from sas.sasgui.guiframe.events import NewPlotEvent 39 39 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 40 41 logger = logging.getLogger(__name__) 40 42 41 43 _BOX_WIDTH = 76 … … 699 701 ax = Axes3D(panel.figure) 700 702 except: 701 logg ing.error("PlotPanel could not import Axes3D")703 logger.error("PlotPanel could not import Axes3D") 702 704 raise 703 705 panel.dimension = 3 … … 741 743 marker = 'o' 742 744 m_size = 3.5 743 sld_tot = (n umpy.fabs(sld_mx) + numpy.fabs(sld_my) + \744 n umpy.fabs(sld_mz) + numpy.fabs(output.sld_n))745 sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) + \ 746 np.fabs(sld_mz) + np.fabs(output.sld_n)) 745 747 is_nonzero = sld_tot > 0.0 746 748 is_zero = sld_tot == 0.0 … … 757 759 pix_symbol = output.pix_symbol[is_nonzero] 758 760 # II. Plot selective points in color 759 other_color = n umpy.ones(len(pix_symbol), dtype='bool')761 other_color = np.ones(len(pix_symbol), dtype='bool') 760 762 for key in color_dic.keys(): 761 763 chosen_color = pix_symbol == key 762 if n umpy.any(chosen_color):764 if np.any(chosen_color): 763 765 other_color = other_color & (chosen_color != True) 764 766 color = color_dic[key] … … 767 769 markeredgecolor=color, markersize=m_size, label=key) 768 770 # III. Plot All others 769 if n umpy.any(other_color):771 if np.any(other_color): 770 772 a_name = '' 771 773 if output.pix_type == 'atom': … … 795 797 draw magnetic vectors w/arrow 796 798 """ 797 max_mx = max(n umpy.fabs(sld_mx))798 max_my = max(n umpy.fabs(sld_my))799 max_mz = max(n umpy.fabs(sld_mz))799 max_mx = max(np.fabs(sld_mx)) 800 max_my = max(np.fabs(sld_my)) 801 max_mz = max(np.fabs(sld_mz)) 800 802 max_m = max(max_mx, max_my, max_mz) 801 803 try: … … 812 814 unit_z2 = sld_mz / max_m 813 815 # 0.8 is for avoiding the color becomes white=(1,1,1)) 814 color_x = n umpy.fabs(unit_x2 * 0.8)815 color_y = n umpy.fabs(unit_y2 * 0.8)816 color_z = n umpy.fabs(unit_z2 * 0.8)816 color_x = np.fabs(unit_x2 * 0.8) 817 color_y = np.fabs(unit_y2 * 0.8) 818 color_z = np.fabs(unit_z2 * 0.8) 817 819 x2 = pos_x + unit_x2 * max_step 818 820 y2 = pos_y + unit_y2 * max_step 819 821 z2 = pos_z + unit_z2 * max_step 820 x_arrow = n umpy.column_stack((pos_x, x2))821 y_arrow = n umpy.column_stack((pos_y, y2))822 z_arrow = n umpy.column_stack((pos_z, z2))823 colors = n umpy.column_stack((color_x, color_y, color_z))822 x_arrow = np.column_stack((pos_x, x2)) 823 y_arrow = np.column_stack((pos_y, y2)) 824 z_arrow = np.column_stack((pos_z, z2)) 825 colors = np.column_stack((color_x, color_y, color_z)) 824 826 arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 825 827 colors, mutation_scale=10, lw=1, … … 880 882 if self.is_avg or self.is_avg == None: 881 883 self._create_default_1d_data() 882 i_out = n umpy.zeros(len(self.data.y))884 i_out = np.zeros(len(self.data.y)) 883 885 inputs = [self.data.x, [], i_out] 884 886 else: 885 887 self._create_default_2d_data() 886 i_out = n umpy.zeros(len(self.data.data))888 i_out = np.zeros(len(self.data.data)) 887 889 inputs = [self.data.qx_data, self.data.qy_data, i_out] 888 890 … … 989 991 :Param input: input list [qx_data, qy_data, i_out] 990 992 """ 991 out = n umpy.empty(0)993 out = np.empty(0) 992 994 #s = time.time() 993 995 for ind in range(len(input[0])): … … 998 1000 inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 999 1001 outi = self.model.run(inputi) 1000 out = n umpy.append(out, outi)1002 out = np.append(out, outi) 1001 1003 else: 1002 1004 if ind % 50 == 0 and update != None: … … 1006 1008 input[2][ind:ind + 1]] 1007 1009 outi = self.model.runXY(inputi) 1008 out = n umpy.append(out, outi)1010 out = np.append(out, outi) 1009 1011 #print time.time() - s 1010 1012 if self.is_avg or self.is_avg == None: … … 1027 1029 self.npts_x = int(float(self.npt_ctl.GetValue())) 1028 1030 self.data = Data2D() 1029 qmax = self.qmax_x #/ n umpy.sqrt(2)1031 qmax = self.qmax_x #/ np.sqrt(2) 1030 1032 self.data.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 1031 1033 self.data.yaxis('\\rm{Q_{y}}', '\AA^{-1}') … … 1048 1050 qstep = self.npts_x 1049 1051 1050 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1051 y = n umpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)1052 x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 1053 y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 1052 1054 ## use data info instead 1053 new_x = n umpy.tile(x, (len(y), 1))1054 new_y = n umpy.tile(y, (len(x), 1))1055 new_x = np.tile(x, (len(y), 1)) 1056 new_y = np.tile(y, (len(x), 1)) 1055 1057 new_y = new_y.swapaxes(0, 1) 1056 1058 # all data reuire now in 1d array 1057 1059 qx_data = new_x.flatten() 1058 1060 qy_data = new_y.flatten() 1059 q_data = n umpy.sqrt(qx_data * qx_data + qy_data * qy_data)1061 q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 1060 1062 # set all True (standing for unmasked) as default 1061 mask = n umpy.ones(len(qx_data), dtype=bool)1063 mask = np.ones(len(qx_data), dtype=bool) 1062 1064 # store x and y bin centers in q space 1063 1065 x_bins = x 1064 1066 y_bins = y 1065 1067 self.data.source = Source() 1066 self.data.data = n umpy.ones(len(mask))1067 self.data.err_data = n umpy.ones(len(mask))1068 self.data.data = np.ones(len(mask)) 1069 self.data.err_data = np.ones(len(mask)) 1068 1070 self.data.qx_data = qx_data 1069 1071 self.data.qy_data = qy_data … … 1084 1086 :warning: This data is never plotted. 1085 1087 residuals.x = data_copy.x[index] 1086 residuals.dy = n umpy.ones(len(residuals.y))1088 residuals.dy = np.ones(len(residuals.y)) 1087 1089 residuals.dx = None 1088 1090 residuals.dxl = None … … 1091 1093 self.qmax_x = float(self.qmax_ctl.GetValue()) 1092 1094 self.npts_x = int(float(self.npt_ctl.GetValue())) 1093 qmax = self.qmax_x #/ n umpy.sqrt(2)1095 qmax = self.qmax_x #/ np.sqrt(2) 1094 1096 ## Default values 1095 1097 xmax = qmax 1096 1098 xmin = qmax * _Q1D_MIN 1097 1099 qstep = self.npts_x 1098 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1100 x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 1099 1101 # store x and y bin centers in q space 1100 1102 #self.data.source = Source() 1101 y = n umpy.ones(len(x))1102 dy = n umpy.zeros(len(x))1103 dx = n umpy.zeros(len(x))1103 y = np.ones(len(x)) 1104 dy = np.zeros(len(x)) 1105 dx = np.zeros(len(x)) 1104 1106 self.data = Data1D(x=x, y=y) 1105 1107 self.data.dx = dx … … 1171 1173 state = None 1172 1174 1173 n umpy.nan_to_num(image)1175 np.nan_to_num(image) 1174 1176 new_plot = Data2D(image=image, err_image=data.err_data) 1175 1177 new_plot.name = model.name + '2d' … … 1344 1346 msg = "OMF Panel: %s" % sys.exc_value 1345 1347 infor = 'Error' 1346 #logg ing.error(msg)1348 #logger.error(msg) 1347 1349 if self.parent.parent != None: 1348 1350 # inform msg to wx … … 1640 1642 for key in sld_list.keys(): 1641 1643 if ctr_list[0] == key: 1642 min_val = n umpy.min(sld_list[key])1643 max_val = n umpy.max(sld_list[key])1644 mean_val = n umpy.mean(sld_list[key])1644 min_val = np.min(sld_list[key]) 1645 max_val = np.max(sld_list[key]) 1646 mean_val = np.mean(sld_list[key]) 1645 1647 enable = (min_val == max_val) and \ 1646 1648 sld_data.pix_type == 'pixel' … … 1696 1698 msg = "%s cannot write %s\n" % ('Generic Scattering', str(path)) 1697 1699 infor = 'Error' 1698 #logg ing.error(msg)1700 #logger.error(msg) 1699 1701 if self.parent.parent != None: 1700 1702 # inform msg to wx … … 1733 1735 npts = -1 1734 1736 break 1735 if n umpy.isfinite(n_val):1737 if np.isfinite(n_val): 1736 1738 npts *= int(n_val) 1737 1739 if npts > 0: … … 1770 1772 ctl.Refresh() 1771 1773 return 1772 if n umpy.isfinite(s_val):1774 if np.isfinite(s_val): 1773 1775 s_size *= s_val 1774 1776 self.sld_data.set_pixel_volumes(s_size) … … 1787 1789 try: 1788 1790 sld_data = self.parent.get_sld_from_omf() 1789 #nop = (nop * n umpy.pi) / 61791 #nop = (nop * np.pi) / 6 1790 1792 nop = len(sld_data.sld_n) 1791 1793 except: -
src/sas/sasgui/perspectives/calculator/model_editor.py
rddbac66 r463e7ffc 32 32 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 33 33 from .pyconsole import show_model_output, check_model 34 35 logger = logging.getLogger(__name__) 34 36 35 37 … … 985 987 exec "from %s import Model" % name 986 988 except: 987 logg ing.error(sys.exc_value)989 logger.error(sys.exc_value) 988 990 989 991 # Prepare the messagebox -
src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py
ra0c1e1d r463e7ffc 34 34 from sas.sasgui.perspectives.calculator import calculator_widgets as widget 35 35 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 36 37 logger = logging.getLogger(__name__) 36 38 37 39 _BOX_WIDTH = 100 … … 1098 1100 new_string.append(value) 1099 1101 except: 1100 logg ing.error(sys.exc_value)1102 logger.error(sys.exc_value) 1101 1103 1102 1104 return new_string … … 1140 1142 return out 1141 1143 except: 1142 logg ing.error(sys.exc_value)1144 logger.error(sys.exc_value) 1143 1145 1144 1146 def _on_xy_coordinate(self, event=None): … … 1318 1320 except: 1319 1321 # Skip non-data lines 1320 logg ing.error(sys.exc_value)1322 logger.error(sys.exc_value) 1321 1323 1322 1324 return [wavelength, intensity] -
src/sas/sasgui/perspectives/corfunc/corfunc.py
r1dc8ec9 r463e7ffc 20 20 from plot_labels import * 21 21 22 logger = logging.getLogger(__name__) 22 23 23 24 class Plugin(PluginBase): … … 29 30 def __init__(self): 30 31 PluginBase.__init__(self, name="Correlation Function") 31 logg ing.info("Correlation function plug-in started")32 logger.info("Correlation function plug-in started") 32 33 self._always_active = True 33 34 self.state_reader = Reader(self.set_state) -
src/sas/sasgui/perspectives/corfunc/corfunc_state.py
rae9b8bf r463e7ffc 13 13 from sas.sascalc.dataloader.loader import Loader 14 14 15 logger = logging.getLogger(__name__) 16 15 17 CORNODE_NAME = 'corfunc' 16 18 CANSAS_NS = 'cansas1d/1.0' … … 216 218 msg = ("CorfuncState.fromXML: Could not read timestamp", 217 219 "\n{}").format(sys.exc_value) 218 logg ing.error(msg)220 logger.error(msg) 219 221 220 222 # Parse current state … … 360 362 msg = "XML document does not contain CorfuncState information\n{}" 361 363 msg.format(sys.exc_value) 362 logg ing.info(msg)364 logger.info(msg) 363 365 return state -
src/sas/sasgui/perspectives/file_converter/file_converter.py
rba65aff r463e7ffc 6 6 from sas.sasgui.guiframe.plugin_base import PluginBase 7 7 from sas.sasgui.perspectives.file_converter.converter_panel import ConverterWindow 8 9 logger = logging.getLogger(__name__) 8 10 9 11 class Plugin(PluginBase): … … 15 17 def __init__(self): 16 18 PluginBase.__init__(self, name="File Converter") 17 logg ing.info("File Converter plug-in started")19 logger.info("File Converter plug-in started") 18 20 self._sub_menu = "Tool" 19 21 self.converter_frame = None -
src/sas/sasgui/perspectives/fitting/basepage.py
rb301db9 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 … … 34 34 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 35 35 36 logger = logging.getLogger(__name__) 36 37 37 38 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 100 101 self.graph_id = None 101 102 # Q range for data set 102 self.qmin_data_set = n umpy.inf103 self.qmin_data_set = np.inf 103 104 self.qmax_data_set = None 104 105 self.npts_data_set = 0 … … 278 279 279 280 """ 280 x = n umpy.linspace(start=self.qmin_x, stop=self.qmax_x,281 x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 281 282 num=self.npts_x, endpoint=True) 282 283 self.data = Data1D(x=x) … … 295 296 """ 296 297 if self.qmin_x >= 1.e-10: 297 qmin = n umpy.log10(self.qmin_x)298 qmin = np.log10(self.qmin_x) 298 299 else: 299 300 qmin = -10. 300 301 301 302 if self.qmax_x <= 1.e10: 302 qmax = n umpy.log10(self.qmax_x)303 qmax = np.log10(self.qmax_x) 303 304 else: 304 305 qmax = 10. 305 306 306 x = n umpy.logspace(start=qmin, stop=qmax,307 x = np.logspace(start=qmin, stop=qmax, 307 308 num=self.npts_x, endpoint=True, base=10.0) 308 309 self.data = Data1D(x=x) … … 341 342 qstep = self.npts_x 342 343 343 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)344 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) 345 346 # use data info instead 346 new_x = n umpy.tile(x, (len(y), 1))347 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)) 348 349 new_y = new_y.swapaxes(0, 1) 349 350 # all data reuire now in 1d array 350 351 qx_data = new_x.flatten() 351 352 qy_data = new_y.flatten() 352 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) 353 354 # set all True (standing for unmasked) as default 354 mask = n umpy.ones(len(qx_data), dtype=bool)355 mask = np.ones(len(qx_data), dtype=bool) 355 356 # store x and y bin centers in q space 356 357 x_bins = x … … 358 359 359 360 self.data.source = Source() 360 self.data.data = n umpy.ones(len(mask))361 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)) 362 363 self.data.qx_data = qx_data 363 364 self.data.qy_data = qy_data … … 782 783 except Exception: 783 784 # Skip non-data lines 784 logg ing.error(traceback.format_exc())785 return n umpy.array(angles), numpy.array(weights)785 logger.error(traceback.format_exc()) 786 return np.array(angles), np.array(weights) 786 787 except: 787 788 raise … … 1304 1305 [state.values, state.weights] 1305 1306 except Exception: 1306 logg ing.error(traceback.format_exc())1307 logger.error(traceback.format_exc()) 1307 1308 selection = self._find_polyfunc_selection(disp_model) 1308 1309 for list in self.fittable_param: … … 1321 1322 list[6].Disable() 1322 1323 except Exception: 1323 logg ing.error(traceback.format_exc())1324 logger.error(traceback.format_exc()) 1324 1325 # For array, disable all fixed params 1325 1326 if selection == 1: … … 1330 1331 item[2].Disable() 1331 1332 except Exception: 1332 logg ing.error(traceback.format_exc())1333 logger.error(traceback.format_exc()) 1333 1334 1334 1335 def _selectDlg(self): … … 1449 1450 self.state_change = True 1450 1451 self._draw_model() 1451 # Time delay has been introduced to prevent _handle error1452 # on Windows1453 # This part of code is executed when model is selected and1454 # it's parameters are changed (with respect to previously1455 # selected model). There are two Iq evaluations occuring one1456 # after another and therefore there may be compilation error1457 # if model is calculated for the first time.1458 # This seems to be Windows only issue - haven't tested on Linux1459 # though.The proper solution (other than time delay) requires1460 # more fundemental code refatoring1461 # Wojtek P. Nov 7, 20161462 if not ON_MAC:1463 time.sleep(0.1)1464 1452 self.Refresh() 1465 1453 1466 # logg ing.info("is_modified flag set to %g",is_modified)1454 # logger.info("is_modified flag set to %g",is_modified) 1467 1455 return is_modified 1468 1456 … … 1569 1557 self.save_current_state() 1570 1558 except Exception: 1571 logg ing.error(traceback.format_exc())1559 logger.error(traceback.format_exc()) 1572 1560 1573 1561 return flag, is_modified … … 2120 2108 for data in self.data_list: 2121 2109 # q value from qx and qy 2122 radius = n umpy.sqrt(data.qx_data * data.qx_data +2110 radius = np.sqrt(data.qx_data * data.qx_data + 2123 2111 data.qy_data * data.qy_data) 2124 2112 # get unmasked index … … 2126 2114 (radius <= float(self.qmax.GetValue())) 2127 2115 index_data = (index_data) & (data.mask) 2128 index_data = (index_data) & (n umpy.isfinite(data.data))2116 index_data = (index_data) & (np.isfinite(data.data)) 2129 2117 2130 2118 if len(index_data[index_data]) < 10: … … 2161 2149 index_data = (float(self.qmin.GetValue()) <= radius) & \ 2162 2150 (radius <= float(self.qmax.GetValue())) 2163 index_data = (index_data) & (n umpy.isfinite(data.y))2151 index_data = (index_data) & (np.isfinite(data.y)) 2164 2152 2165 2153 if len(index_data[index_data]) < 5: … … 2233 2221 2234 2222 # Check that min is less than max 2235 low = -n umpy.inf if min_str == "" else float(min_str)2236 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) 2237 2225 if high < low: 2238 2226 min_ctrl.SetBackgroundColour("pink") … … 2384 2372 self.model.set_dispersion(p, disp_model) 2385 2373 except Exception: 2386 logg ing.error(traceback.format_exc())2374 logger.error(traceback.format_exc()) 2387 2375 2388 2376 # save state into … … 2499 2487 self.Refresh() 2500 2488 except Exception: 2501 logg ing.error(traceback.format_exc())2489 logger.error(traceback.format_exc()) 2502 2490 # Error msg 2503 2491 msg = "Error occurred:" … … 2600 2588 del self.state.model._persistency_dict[name.split('.')[0]] 2601 2589 except Exception: 2602 logg ing.error(traceback.format_exc())2590 logger.error(traceback.format_exc()) 2603 2591 2604 2592 def _lay_out(self): … … 2609 2597 Layout is called after fitting. 2610 2598 """ 2611 self._sleep4sec()2612 2599 self.Layout() 2613 2600 return 2614 2615 def _sleep4sec(self):2616 """2617 sleep for 1 sec only applied on Mac2618 Note: This 1sec helps for Mac not to crash on self.2619 Layout after self._draw_model2620 """2621 if ON_MAC:2622 time.sleep(1)2623 2601 2624 2602 def _find_polyfunc_selection(self, disp_func=None): … … 2654 2632 self.qmin_x = data_min 2655 2633 self.qmax_x = math.sqrt(x * x + y * y) 2656 # self.data.mask = n umpy.ones(len(self.data.data),dtype=bool)2634 # self.data.mask = np.ones(len(self.data.data),dtype=bool) 2657 2635 # check smearing 2658 2636 if not self.disable_smearer.GetValue(): … … 2742 2720 except Exception: 2743 2721 # Not for control panels 2744 logg ing.error(traceback.format_exc())2722 logger.error(traceback.format_exc()) 2745 2723 # Make sure the resduals plot goes to the last 2746 2724 if res_item is not None: … … 3075 3053 disfunc = str(item[7].GetValue()) 3076 3054 except Exception: 3077 logg ing.error(traceback.format_exc())3055 logger.error(traceback.format_exc()) 3078 3056 3079 3057 # 2D … … 3118 3096 disfunc += ' ' + str(weight) 3119 3097 except Exception: 3120 logg ing.error(traceback.format_exc())3098 logger.error(traceback.format_exc()) 3121 3099 content += name + ',' + str(check) + ',' + value + disfunc + ',' + \ 3122 3100 bound_lo + ',' + bound_hi + ':' … … 3366 3344 3367 3345 if value[1] == 'array': 3368 pd_vals = n umpy.array(value[2])3369 pd_weights = n umpy.array(value[3])3346 pd_vals = np.array(value[2]) 3347 pd_weights = np.array(value[3]) 3370 3348 if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 3371 3349 msg = ("bad array distribution parameters for %s" … … 3389 3367 3390 3368 except Exception: 3391 logg ing.error(traceback.format_exc())3369 logger.error(traceback.format_exc()) 3392 3370 print "Error in BasePage._paste_poly_help: %s" % \ 3393 3371 sys.exc_info()[1] -
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
r4c5098c 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 … … 48 48 49 49 from . import models 50 51 logger = logging.getLogger(__name__) 50 52 51 53 MAX_NBR_DATA = 4 … … 119 121 self.page_finder = {} 120 122 # Log startup 121 logg ing.info("Fitting plug-in started")123 logger.info("Fitting plug-in started") 122 124 self.batch_capable = self.get_batch_capable() 123 125 … … 346 348 page.formfactorbox.SetLabel(current_val) 347 349 except: 348 logg ing.error("update_custom_combo: %s", sys.exc_value)350 logger.error("update_custom_combo: %s", sys.exc_value) 349 351 350 352 def set_edit_menu(self, owner): … … 586 588 msg = "Fitting: cannot deal with the theory received" 587 589 evt = StatusEvent(status=msg, info="error") 588 logg ing.error("set_theory " + msg + "\n" + str(sys.exc_value))590 logger.error("set_theory " + msg + "\n" + str(sys.exc_value)) 589 591 wx.PostEvent(self.parent, evt) 590 592 … … 875 877 enable1D=enable1D, enable2D=enable2D, 876 878 qmin=qmin, qmax=qmax, weight=weight) 877 878 def _mac_sleep(self, sec=0.2):879 """880 Give sleep to MAC881 """882 if ON_MAC:883 time.sleep(sec)884 879 885 880 def draw_model(self, model, page_id, data=None, smearer=None, … … 1030 1025 manager=self, 1031 1026 improvement_delta=0.1) 1032 self._mac_sleep(0.2)1033 1027 1034 1028 # batch fit … … 1270 1264 :param elapsed: time spent at the fitting level 1271 1265 """ 1272 self._mac_sleep(0.2)1273 1266 uid = page_id[0] 1274 1267 if uid in self.fit_thread_list.keys(): … … 1332 1325 new_theory = copy_data.data 1333 1326 new_theory[res.index] = res.theory 1334 new_theory[res.index == False] = n umpy.nan1327 new_theory[res.index == False] = np.nan 1335 1328 correct_result = True 1336 1329 #get all fittable parameters of the current model … … 1341 1334 param_list.remove(param) 1342 1335 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)):1336 not np.isfinite(res.fitness) or \ 1337 np.any(res.pvec == None) or not \ 1338 np.all(np.isfinite(res.pvec)): 1346 1339 data_name = str(None) 1347 1340 if data is not None: … … 1352 1345 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1353 1346 model_name) 1354 ERROR = n umpy.NAN1347 ERROR = np.NAN 1355 1348 cell = BatchCell() 1356 1349 cell.label = res.fitness … … 1366 1359 batch_inputs["error on %s" % str(param)].append(ERROR) 1367 1360 else: 1368 # TODO: Why sometimes res.pvec comes with n umpy.float64?1361 # TODO: Why sometimes res.pvec comes with np.float64? 1369 1362 # probably from scipy lmfit 1370 if res.pvec.__class__ == n umpy.float64:1363 if res.pvec.__class__ == np.float64: 1371 1364 res.pvec = [res.pvec] 1372 1365 … … 1520 1513 page_id = [] 1521 1514 ## fit more than 1 model at the same time 1522 self._mac_sleep(0.2)1523 1515 try: 1524 1516 index = 0 … … 1533 1525 fit_msg = res.mesg 1534 1526 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)):1527 not np.isfinite(res.fitness) or \ 1528 np.any(res.pvec == None) or \ 1529 not np.all(np.isfinite(res.pvec)): 1538 1530 fit_msg += "\nFitting did not converge!!!" 1539 1531 wx.CallAfter(self._update_fit_button, page_id) 1540 1532 else: 1541 1533 #set the panel when fit result are float not list 1542 if res.pvec.__class__ == n umpy.float64:1534 if res.pvec.__class__ == np.float64: 1543 1535 pvec = [res.pvec] 1544 1536 else: 1545 1537 pvec = res.pvec 1546 if res.stderr.__class__ == n umpy.float64:1538 if res.stderr.__class__ == np.float64: 1547 1539 stderr = [res.stderr] 1548 1540 else: … … 1692 1684 if dy is None: 1693 1685 new_plot.is_data = False 1694 new_plot.dy = n umpy.zeros(len(y))1686 new_plot.dy = np.zeros(len(y)) 1695 1687 # If this is a theory curve, pick the proper symbol to make it a curve 1696 1688 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM … … 1741 1733 """ 1742 1734 try: 1743 n umpy.nan_to_num(y)1735 np.nan_to_num(y) 1744 1736 new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 1745 1737 data_description=model.name, … … 1806 1798 Handle exception from calculator by posting it as an error. 1807 1799 """ 1808 logg ing.error("".join(traceback.format_exception(etype, value, tb)))1800 logger.error("".join(traceback.format_exception(etype, value, tb))) 1809 1801 msg = traceback.format_exception(etype, value, tb, limit=1) 1810 1802 evt = StatusEvent(status="".join(msg), type="stop", info="error") … … 1825 1817 that can be plot. 1826 1818 """ 1827 n umpy.nan_to_num(image)1819 np.nan_to_num(image) 1828 1820 new_plot = Data2D(image=image, err_image=data.err_data) 1829 1821 new_plot.name = model.name + '2d' … … 2017 2009 if data_copy.__class__.__name__ == "Data2D": 2018 2010 if index == None: 2019 index = n umpy.ones(len(data_copy.data), dtype=bool)2011 index = np.ones(len(data_copy.data), dtype=bool) 2020 2012 if weight != None: 2021 2013 data_copy.err_data = weight 2022 2014 # get rid of zero error points 2023 2015 index = index & (data_copy.err_data != 0) 2024 index = index & (n umpy.isfinite(data_copy.data))2016 index = index & (np.isfinite(data_copy.data)) 2025 2017 fn = data_copy.data[index] 2026 2018 theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) … … 2032 2024 # 1 d theory from model_thread is only in the range of index 2033 2025 if index == None: 2034 index = n umpy.ones(len(data_copy.y), dtype=bool)2026 index = np.ones(len(data_copy.y), dtype=bool) 2035 2027 if weight != None: 2036 2028 data_copy.dy = weight 2037 2029 if data_copy.dy == None or data_copy.dy == []: 2038 dy = n umpy.ones(len(data_copy.y))2030 dy = np.ones(len(data_copy.y)) 2039 2031 else: 2040 2032 ## Set consistently w/AbstractFitengine: … … 2057 2049 return 2058 2050 2059 residuals = res[n umpy.isfinite(res)]2051 residuals = res[np.isfinite(res)] 2060 2052 # get chisqr only w/finite 2061 chisqr = n umpy.average(residuals * residuals)2053 chisqr = np.average(residuals * residuals) 2062 2054 2063 2055 self._plot_residuals(page_id=page_id, data=data_copy, … … 2096 2088 residuals.qy_data = data_copy.qy_data 2097 2089 residuals.q_data = data_copy.q_data 2098 residuals.err_data = n umpy.ones(len(residuals.data))2090 residuals.err_data = np.ones(len(residuals.data)) 2099 2091 residuals.xmin = min(residuals.qx_data) 2100 2092 residuals.xmax = max(residuals.qx_data) … … 2110 2102 # 1 d theory from model_thread is only in the range of index 2111 2103 if data_copy.dy == None or data_copy.dy == []: 2112 dy = n umpy.ones(len(data_copy.y))2104 dy = np.ones(len(data_copy.y)) 2113 2105 else: 2114 2106 if weight == None: 2115 dy = n umpy.ones(len(data_copy.y))2107 dy = np.ones(len(data_copy.y)) 2116 2108 ## Set consitently w/AbstractFitengine: 2117 2109 ## But this should be corrected later. … … 2132 2124 residuals.y = (fn - gn[index]) / en 2133 2125 residuals.x = data_copy.x[index] 2134 residuals.dy = n umpy.ones(len(residuals.y))2126 residuals.dy = np.ones(len(residuals.y)) 2135 2127 residuals.dx = None 2136 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/models.py
rc5251f6 r80a49c2 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 -
src/sas/sasgui/perspectives/fitting/pagestate.py
r27109e5 r9c0f3c17 18 18 import copy 19 19 import logging 20 import numpy 20 import numpy as np 21 21 import traceback 22 22 … … 33 33 from sas.sascalc.dataloader.data_info import Data2D, Collimation, Detector 34 34 from sas.sascalc.dataloader.data_info import Process, Aperture 35 36 logger = logging.getLogger(__name__) 35 37 36 38 # Information to read/write state as xml … … 395 397 msg = "Save state does not have enough information to load" 396 398 msg += " the all of the data." 397 logg ing.warning(msg=msg)399 logger.warning(msg=msg) 398 400 else: 399 401 self.formfactorcombobox = FIRST_FORM[self.categorycombobox] … … 410 412 for fittable, name, value, _, uncert, lower, upper, units in params: 411 413 if not value: 412 value = n umpy.nan414 value = np.nan 413 415 if not uncert or uncert[1] == '' or uncert[1] == 'None': 414 416 uncert[0] = False 415 uncert[1] = n umpy.nan417 uncert[1] = np.nan 416 418 if not upper or upper[1] == '' or upper[1] == 'None': 417 419 upper[0] = False 418 upper[1] = n umpy.nan420 upper[1] = np.nan 419 421 if not lower or lower[1] == '' or lower[1] == 'None': 420 422 lower[0] = False 421 lower[1] = n umpy.nan423 lower[1] = np.nan 422 424 if is_string: 423 425 p[name] = str(value) … … 449 451 lower = params.get(name + ".lower", '-inf') 450 452 units = params.get(name + ".units") 451 if std is not None and std is not n umpy.nan:453 if std is not None and std is not np.nan: 452 454 std = [True, str(std)] 453 455 else: 454 456 std = [False, ''] 455 if lower is not None and lower is not n umpy.nan:457 if lower is not None and lower is not np.nan: 456 458 lower = [True, str(lower)] 457 459 else: 458 460 lower = [True, '-inf'] 459 if upper is not None and upper is not n umpy.nan:461 if upper is not None and upper is not np.nan: 460 462 upper = [True, str(upper)] 461 463 else: … … 620 622 except Exception: 621 623 msg = "Report string expected 'name: value' but got %r" % line 622 logg ing.error(msg)624 logger.error(msg) 623 625 if name.count("State created"): 624 626 repo_time = "" + value … … 662 664 except Exception: 663 665 msg = "While parsing 'data: ...'\n" 664 logg ing.error(msg + traceback.format_exc())666 logger.error(msg + traceback.format_exc()) 665 667 if name == "model name ": 666 668 try: … … 678 680 except Exception: 679 681 msg = "While parsing 'Plotting Range: ...'\n" 680 logg ing.error(msg + traceback.format_exc())682 logger.error(msg + traceback.format_exc()) 681 683 paramval = "" 682 684 for lines in param_string.split(":"): … … 1037 1039 msg = "PageState.fromXML: Could not" 1038 1040 msg += " read timestamp\n %s" % sys.exc_value 1039 logg ing.error(msg)1041 logger.error(msg) 1040 1042 1041 1043 if entry is not None: … … 1077 1079 except Exception: 1078 1080 base = "unable to load distribution %r for %s" 1079 logg ing.error(base % (value, parameter))1081 logger.error(base % (value, parameter)) 1080 1082 continue 1081 1083 _disp_obj_dict = getattr(self, varname) … … 1099 1101 msg = ("Error reading %r from %s %s\n" 1100 1102 % (line, tagname, name)) 1101 logg ing.error(msg + traceback.format_exc())1102 dic[name] = n umpy.array(value_list)1103 logger.error(msg + traceback.format_exc()) 1104 dic[name] = np.array(value_list) 1103 1105 setattr(self, varname, dic) 1104 1106 … … 1207 1209 1208 1210 except: 1209 logg ing.info("XML document does not contain fitting information.\n"1211 logger.info("XML document does not contain fitting information.\n" 1210 1212 + traceback.format_exc()) 1211 1213 -
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/invariant/invariant.py
rc10d9d6c r463e7ffc 27 27 from sas.sasgui.guiframe.plugin_base import PluginBase 28 28 29 logger = logging.getLogger(__name__) 30 29 31 class Plugin(PluginBase): 30 32 """ … … 46 48 47 49 # Log startup 48 logg ing.info("Invariant plug-in started")50 logger.info("Invariant plug-in started") 49 51 50 52 def get_data(self): … … 280 282 281 283 except: 282 logg ing.error("invariant.set_state: %s" % sys.exc_value)284 logger.error("invariant.set_state: %s" % sys.exc_value) 283 285 284 286 def on_set_state_helper(self, event=None): -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r18b7ecb9 r463e7ffc 24 24 from sas.sasgui.guiframe.panel_base import PanelBase 25 25 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 26 27 logger = logging.getLogger(__name__) 26 28 27 29 # The minimum q-value to be used when extrapolating … … 460 462 self._manager.plot_theory(name="Low-Q extrapolation") 461 463 except: 462 logg ing.error(sys.exc_value)464 logger.error(sys.exc_value) 463 465 464 466 def get_high_qstar(self, inv, high_q=False): … … 494 496 self._manager.plot_theory(name="High-Q extrapolation") 495 497 except: 496 logg ing.error(sys.exc_value)498 logger.error(sys.exc_value) 497 499 498 500 def get_qstar(self, inv): … … 845 847 attr.SetValue(value) 846 848 except: 847 logg ing.error("Invariant state: %s", sys.exc_value)849 logger.error("Invariant state: %s", sys.exc_value) 848 850 849 851 def get_bookmark_by_num(self, num=None): … … 862 864 _, _, current_state, comp_state = self.state.bookmark_list[int(num)] 863 865 except: 864 logg ing.error(sys.exc_value)866 logger.error(sys.exc_value) 865 867 raise ValueError, "No such bookmark exists" 866 868 … … 957 959 self.state.clone_state() 958 960 except: 959 logg ing.error(sys.exc_value)961 logger.error(sys.exc_value) 960 962 961 963 self._set_undo_flag(True) … … 1001 1003 del self.state.state_list[str(i)] 1002 1004 except: 1003 logg ing.error(sys.exc_value)1005 logger.error(sys.exc_value) 1004 1006 # Enable the undo button if it was not 1005 1007 self._set_undo_flag(True) … … 1066 1068 del self.state.state_list[str(i)] 1067 1069 except: 1068 logg ing.error(sys.exc_value)1070 logger.error(sys.exc_value) 1069 1071 1070 1072 # try to add new state of the text changes in the state_list … … 1081 1083 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1082 1084 except: 1083 logg ing.error(sys.exc_value)1085 logger.error(sys.exc_value) 1084 1086 1085 1087 self._set_undo_flag(True) … … 1103 1105 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1104 1106 except: 1105 logg ing.error(sys.exc_value)1107 logger.error(sys.exc_value) 1106 1108 1107 1109 def _get_input_list(self): -
src/sas/sasgui/perspectives/invariant/invariant_state.py
rdb5294e r463e7ffc 16 16 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 17 17 from sas.sasgui.guiframe.dataFitting import Data1D 18 19 logger = logging.getLogger(__name__) 18 20 19 21 INVNODE_NAME = 'invariant' … … 381 383 msg = "InvariantSate.fromXML: Could not read" 382 384 msg += " timestamp\n %s" % sys.exc_value 383 logg ing.error(msg)385 logger.error(msg) 384 386 385 387 # Parse bookmarks … … 694 696 msg = "XML document does not contain invariant" 695 697 msg += " information.\n %s" % sys.exc_value 696 logg ing.info(msg)698 logger.info(msg) 697 699 return state 698 700 -
src/sas/sasgui/perspectives/invariant/report_dialog.py
rd85c194 r463e7ffc 20 20 21 21 from sas.sasgui.guiframe.report_dialog import BaseReportDialog 22 23 logger = logging.getLogger(__name__) 22 24 23 25 class ReportDialog(BaseReportDialog): … … 92 94 except: 93 95 # DO not open 94 logg ing.error("Could not open file: %s" % sys.exc_value)96 logger.error("Could not open file: %s" % sys.exc_value) 95 97 # delete image file 96 98 os.remove(pic_fname) -
src/sas/sasgui/perspectives/pr/explore_dialog.py
rd85c194 r9c0f3c17 19 19 20 20 import wx 21 import numpy 21 import numpy as np 22 22 import logging 23 23 import sys 24 25 logger = logging.getLogger(__name__) 24 26 25 27 # Avoid Matplotlib complaining about the lack of legend on the plot … … 65 67 66 68 step = (self.max - self.min) / (self.npts - 1) 67 self.x = n umpy.arange(self.min, self.max + step * 0.01, step)68 dx = n umpy.zeros(len(self.x))69 y = n umpy.ones(len(self.x))70 dy = n umpy.zeros(len(self.x))69 self.x = np.arange(self.min, self.max + step * 0.01, step) 70 dx = np.zeros(len(self.x)) 71 y = np.ones(len(self.x)) 72 dy = np.zeros(len(self.x)) 71 73 72 74 # Plot area … … 284 286 msg += "a change in the " % str(output_type) 285 287 msg += "ExploreDialog code." 286 logg ing.error(msg)288 logger.error(msg) 287 289 288 290 def __do_layout(self): … … 418 420 msg = "ExploreDialog: inversion failed " 419 421 msg += "for D_max=%s\n%s" % (str(d), sys.exc_value) 420 logg ing.error(msg)422 logger.error(msg) 421 423 422 424 self.results = results -
src/sas/sasgui/perspectives/pr/inversion_panel.py
r18b7ecb9 r463e7ffc 17 17 from pr_widgets import OutputTextCtrl 18 18 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 19 20 logger = logging.getLogger(__name__) 19 21 20 22 if sys.platform.count("win32") > 0: … … 710 712 self.alpha_ctl.SetValue(alpha) 711 713 except ValueError: 712 logg ing.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha )714 logger.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha ) 713 715 except: 714 716 # No estimate or bad estimate, either do nothing 715 logg ing.error("InversionControl._on_accept_alpha: %s" % sys.exc_value)717 logger.error("InversionControl._on_accept_alpha: %s" % sys.exc_value) 716 718 717 719 def _on_accept_nterms(self, evt): … … 726 728 self.nfunc_ctl.SetValue(nterms) 727 729 except ValueError: 728 logg ing.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms )730 logger.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms ) 729 731 except: 730 732 # No estimate or bad estimate, either do nothing 731 logg ing.error("InversionControl._on_accept_nterms: %s" % sys.exc_value)733 logger.error("InversionControl._on_accept_nterms: %s" % sys.exc_value) 732 734 733 735 def clear_panel(self): … … 947 949 except: 948 950 msg = "InversionControl._change_file: %s" % sys.exc_value 949 logg ing.error(msg)951 logger.error(msg) 950 952 951 953 def on_help(self, event): -
src/sas/sasgui/perspectives/pr/inversion_state.py
rd85c194 r463e7ffc 22 22 from sas.sascalc.dataloader.readers.cansas_reader import get_content 23 23 24 logger = logging.getLogger(__name__) 25 24 26 PRNODE_NAME = 'pr_inversion' 25 27 CANSAS_NS = "cansas1d/1.0" … … 250 252 msg = "InversionState.fromXML: Could not read " 251 253 msg += "timestamp\n %s" % sys.exc_value 252 logg ing.error(msg)254 logger.error(msg) 253 255 254 256 # Parse inversion inputs … … 306 308 err_msg += "%d %d" % (len(self.coefficients), 307 309 self.nfunc) 308 logg ing.error(err_msg)310 logger.error(err_msg) 309 311 self.coefficients = None 310 312 … … 343 345 err_msg += " covariance matrix: " 344 346 err_msg += "%d %d" % (len(self.covariance), self.nfunc) 345 logg ing.error(err_msg)347 logger.error(err_msg) 346 348 self.covariance = None 347 349 … … 430 432 msg = "XML document does not contain P(r) " 431 433 msg += "information.\n %s" % sys.exc_value 432 logg ing.info(msg)434 logger.info(msg) 433 435 434 436 return state -
src/sas/sasgui/perspectives/pr/pr.py
ra69a967 r9c0f3c17 21 21 import time 22 22 import math 23 import numpy 23 import numpy as np 24 24 import pylab 25 25 from sas.sasgui.guiframe.gui_manager import MDIFrame … … 34 34 from pr_widgets import load_error 35 35 from sas.sasgui.guiframe.plugin_base import PluginBase 36 37 logger = logging.getLogger(__name__) 36 38 37 39 … … 113 115 114 116 # Log startup 115 logg ing.info("Pr(r) plug-in started")117 logger.info("Pr(r) plug-in started") 116 118 117 119 def delete_data(self, data_id): … … 181 183 self.control_panel.set_state(state) 182 184 except: 183 logg ing.error("prview.set_state: %s" % sys.exc_value)185 logger.error("prview.set_state: %s" % sys.exc_value) 184 186 185 187 … … 207 209 r = pylab.arange(0.01, d_max, d_max / 51.0) 208 210 M = len(r) 209 y = n umpy.zeros(M)210 pr_err = n umpy.zeros(M)211 y = np.zeros(M) 212 pr_err = np.zeros(M) 211 213 212 214 total = 0.0 … … 253 255 """ 254 256 # Show P(r) 255 y_true = n umpy.zeros(len(x))257 y_true = np.zeros(len(x)) 256 258 257 259 sum_true = 0.0 … … 307 309 308 310 x = pylab.arange(minq, maxq, maxq / 301.0) 309 y = n umpy.zeros(len(x))310 err = n umpy.zeros(len(x))311 y = np.zeros(len(x)) 312 err = np.zeros(len(x)) 311 313 for i in range(len(x)): 312 314 value = pr.iq(out, x[i]) … … 337 339 if pr.slit_width > 0 or pr.slit_height > 0: 338 340 x = pylab.arange(minq, maxq, maxq / 301.0) 339 y = n umpy.zeros(len(x))340 err = n umpy.zeros(len(x))341 y = np.zeros(len(x)) 342 err = np.zeros(len(x)) 341 343 for i in range(len(x)): 342 344 value = pr.iq_smeared(out, x[i]) … … 382 384 x = pylab.arange(0.0, pr.d_max, pr.d_max / self._pr_npts) 383 385 384 y = n umpy.zeros(len(x))385 dy = n umpy.zeros(len(x))386 y_true = n umpy.zeros(len(x))386 y = np.zeros(len(x)) 387 dy = np.zeros(len(x)) 388 y_true = np.zeros(len(x)) 387 389 388 390 total = 0.0 389 391 pmax = 0.0 390 cov2 = n umpy.ascontiguousarray(cov)392 cov2 = np.ascontiguousarray(cov) 391 393 392 394 for i in range(len(x)): … … 480 482 """ 481 483 # Read the data from the data file 482 data_x = n umpy.zeros(0)483 data_y = n umpy.zeros(0)484 data_err = n umpy.zeros(0)484 data_x = np.zeros(0) 485 data_y = np.zeros(0) 486 data_err = np.zeros(0) 485 487 scale = None 486 488 min_err = 0.0 … … 504 506 #err = 0 505 507 506 data_x = n umpy.append(data_x, x)507 data_y = n umpy.append(data_y, y)508 data_err = n umpy.append(data_err, err)508 data_x = np.append(data_x, x) 509 data_y = np.append(data_y, y) 510 data_err = np.append(data_err, err) 509 511 except: 510 logg ing.error(sys.exc_value)512 logger.error(sys.exc_value) 511 513 512 514 if not scale == None: … … 528 530 """ 529 531 # Read the data from the data file 530 data_x = n umpy.zeros(0)531 data_y = n umpy.zeros(0)532 data_err = n umpy.zeros(0)532 data_x = np.zeros(0) 533 data_y = np.zeros(0) 534 data_err = np.zeros(0) 533 535 scale = None 534 536 min_err = 0.0 … … 555 557 #err = 0 556 558 557 data_x = n umpy.append(data_x, x)558 data_y = n umpy.append(data_y, y)559 data_err = n umpy.append(data_err, err)559 data_x = np.append(data_x, x) 560 data_y = np.append(data_y, y) 561 data_err = np.append(data_err, err) 560 562 except: 561 logg ing.error(sys.exc_value)563 logger.error(sys.exc_value) 562 564 elif line.find("The 6 columns") >= 0: 563 565 data_started = True … … 640 642 # Now replot the original added data 641 643 for plot in self._added_plots: 642 self._added_plots[plot].y = n umpy.copy(self._default_Iq[plot])644 self._added_plots[plot].y = np.copy(self._default_Iq[plot]) 643 645 wx.PostEvent(self.parent, 644 646 NewPlotEvent(plot=self._added_plots[plot], … … 664 666 # Now scale the added plots too 665 667 for plot in self._added_plots: 666 total = n umpy.sum(self._added_plots[plot].y)668 total = np.sum(self._added_plots[plot].y) 667 669 npts = len(self._added_plots[plot].x) 668 670 total *= self._added_plots[plot].x[npts - 1] / npts … … 814 816 # Save Pr invertor 815 817 self.pr = pr 816 cov = n umpy.ascontiguousarray(cov)818 cov = np.ascontiguousarray(cov) 817 819 818 820 # Show result on control panel … … 982 984 all_zeros = True 983 985 if err == None: 984 err = n umpy.zeros(len(pr.y))986 err = np.zeros(len(pr.y)) 985 987 else: 986 988 for i in range(len(err)): … … 1088 1090 # If we have not errors, add statistical errors 1089 1091 if y is not None: 1090 if err == None or n umpy.all(err) == 0:1091 err = n umpy.zeros(len(y))1092 if err == None or np.all(err) == 0: 1093 err = np.zeros(len(y)) 1092 1094 scale = None 1093 1095 min_err = 0.0 … … 1201 1203 dataset = panel.plots[panel.graph.selected_plottable].name 1202 1204 else: 1203 logg ing.info("Prview Error: No data is available")1205 logger.info("Prview Error: No data is available") 1204 1206 return 1205 1207 … … 1211 1213 except: 1212 1214 self.control_panel.alpha = self.alpha 1213 logg ing.info("Prview :Alpha Not estimate yet")1215 logger.info("Prview :Alpha Not estimate yet") 1214 1216 try: 1215 1217 estimate = int(self.control_panel.nterms_estimate) … … 1217 1219 except: 1218 1220 self.control_panel.nfunc = self.nfunc 1219 logg ing.info("Prview : ntemrs Not estimate yet")1221 logger.info("Prview : ntemrs Not estimate yet") 1220 1222 1221 1223 self.current_plottable = panel.plots[panel.graph.selected_plottable] -
src/sas/sasgui/perspectives/simulation/simulation.py
rd85c194 r9c0f3c17 10 10 import wx 11 11 import os 12 import numpy 12 import numpy as np 13 13 import time 14 14 import logging … … 24 24 from sas.sascalc.data_util.calcthread import CalcThread 25 25 from sas.guicomm.events import NewPlotEvent, StatusEvent 26 27 logger = logging.getLogger(__name__) 26 28 27 29 class Calc1D(CalcThread): … … 46 48 def compute(self): 47 49 x = self.x 48 output = n umpy.zeros(len(x))49 error = n umpy.zeros(len(x))50 output = np.zeros(len(x)) 51 error = np.zeros(len(x)) 50 52 51 53 self.starttime = time.time() … … 93 95 self._default_save_location = os.getcwd() 94 96 # Log startup 95 logg ing.info("Simulation plug-in started")97 logger.info("Simulation plug-in started") 96 98 97 99 def get_panels(self, parent): … … 123 125 # Q-values for plotting simulated I(Q) 124 126 step = (self.q_max-self.q_min)/(self.q_npts-1) 125 self.x = n umpy.arange(self.q_min, self.q_max+step*0.01, step)127 self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 126 128 127 129 # Set the list of panels that are part of the simulation perspective … … 187 189 # Q-values for plotting simulated I(Q) 188 190 step = (self.q_max-self.q_min)/(self.q_npts-1) 189 self.x = n umpy.arange(self.q_min, self.q_max+step*0.01, step)191 self.x = np.arange(self.q_min, self.q_max+step*0.01, step) 190 192 191 193 # Compute the simulated I(Q)
Note: See TracChangeset
for help on using the changeset viewer.