Changeset 9c0f3c17 in sasview for src/sas/sasgui/perspectives/calculator
- 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/calculator
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
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
r463e7ffc 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 … … 743 743 marker = 'o' 744 744 m_size = 3.5 745 sld_tot = (n umpy.fabs(sld_mx) + numpy.fabs(sld_my) + \746 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)) 747 747 is_nonzero = sld_tot > 0.0 748 748 is_zero = sld_tot == 0.0 … … 759 759 pix_symbol = output.pix_symbol[is_nonzero] 760 760 # II. Plot selective points in color 761 other_color = n umpy.ones(len(pix_symbol), dtype='bool')761 other_color = np.ones(len(pix_symbol), dtype='bool') 762 762 for key in color_dic.keys(): 763 763 chosen_color = pix_symbol == key 764 if n umpy.any(chosen_color):764 if np.any(chosen_color): 765 765 other_color = other_color & (chosen_color != True) 766 766 color = color_dic[key] … … 769 769 markeredgecolor=color, markersize=m_size, label=key) 770 770 # III. Plot All others 771 if n umpy.any(other_color):771 if np.any(other_color): 772 772 a_name = '' 773 773 if output.pix_type == 'atom': … … 797 797 draw magnetic vectors w/arrow 798 798 """ 799 max_mx = max(n umpy.fabs(sld_mx))800 max_my = max(n umpy.fabs(sld_my))801 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)) 802 802 max_m = max(max_mx, max_my, max_mz) 803 803 try: … … 814 814 unit_z2 = sld_mz / max_m 815 815 # 0.8 is for avoiding the color becomes white=(1,1,1)) 816 color_x = n umpy.fabs(unit_x2 * 0.8)817 color_y = n umpy.fabs(unit_y2 * 0.8)818 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) 819 819 x2 = pos_x + unit_x2 * max_step 820 820 y2 = pos_y + unit_y2 * max_step 821 821 z2 = pos_z + unit_z2 * max_step 822 x_arrow = n umpy.column_stack((pos_x, x2))823 y_arrow = n umpy.column_stack((pos_y, y2))824 z_arrow = n umpy.column_stack((pos_z, z2))825 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)) 826 826 arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 827 827 colors, mutation_scale=10, lw=1, … … 882 882 if self.is_avg or self.is_avg == None: 883 883 self._create_default_1d_data() 884 i_out = n umpy.zeros(len(self.data.y))884 i_out = np.zeros(len(self.data.y)) 885 885 inputs = [self.data.x, [], i_out] 886 886 else: 887 887 self._create_default_2d_data() 888 i_out = n umpy.zeros(len(self.data.data))888 i_out = np.zeros(len(self.data.data)) 889 889 inputs = [self.data.qx_data, self.data.qy_data, i_out] 890 890 … … 991 991 :Param input: input list [qx_data, qy_data, i_out] 992 992 """ 993 out = n umpy.empty(0)993 out = np.empty(0) 994 994 #s = time.time() 995 995 for ind in range(len(input[0])): … … 1000 1000 inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 1001 1001 outi = self.model.run(inputi) 1002 out = n umpy.append(out, outi)1002 out = np.append(out, outi) 1003 1003 else: 1004 1004 if ind % 50 == 0 and update != None: … … 1008 1008 input[2][ind:ind + 1]] 1009 1009 outi = self.model.runXY(inputi) 1010 out = n umpy.append(out, outi)1010 out = np.append(out, outi) 1011 1011 #print time.time() - s 1012 1012 if self.is_avg or self.is_avg == None: … … 1029 1029 self.npts_x = int(float(self.npt_ctl.GetValue())) 1030 1030 self.data = Data2D() 1031 qmax = self.qmax_x #/ n umpy.sqrt(2)1031 qmax = self.qmax_x #/ np.sqrt(2) 1032 1032 self.data.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 1033 1033 self.data.yaxis('\\rm{Q_{y}}', '\AA^{-1}') … … 1050 1050 qstep = self.npts_x 1051 1051 1052 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1053 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) 1054 1054 ## use data info instead 1055 new_x = n umpy.tile(x, (len(y), 1))1056 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)) 1057 1057 new_y = new_y.swapaxes(0, 1) 1058 1058 # all data reuire now in 1d array 1059 1059 qx_data = new_x.flatten() 1060 1060 qy_data = new_y.flatten() 1061 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) 1062 1062 # set all True (standing for unmasked) as default 1063 mask = n umpy.ones(len(qx_data), dtype=bool)1063 mask = np.ones(len(qx_data), dtype=bool) 1064 1064 # store x and y bin centers in q space 1065 1065 x_bins = x 1066 1066 y_bins = y 1067 1067 self.data.source = Source() 1068 self.data.data = n umpy.ones(len(mask))1069 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)) 1070 1070 self.data.qx_data = qx_data 1071 1071 self.data.qy_data = qy_data … … 1086 1086 :warning: This data is never plotted. 1087 1087 residuals.x = data_copy.x[index] 1088 residuals.dy = n umpy.ones(len(residuals.y))1088 residuals.dy = np.ones(len(residuals.y)) 1089 1089 residuals.dx = None 1090 1090 residuals.dxl = None … … 1093 1093 self.qmax_x = float(self.qmax_ctl.GetValue()) 1094 1094 self.npts_x = int(float(self.npt_ctl.GetValue())) 1095 qmax = self.qmax_x #/ n umpy.sqrt(2)1095 qmax = self.qmax_x #/ np.sqrt(2) 1096 1096 ## Default values 1097 1097 xmax = qmax 1098 1098 xmin = qmax * _Q1D_MIN 1099 1099 qstep = self.npts_x 1100 x = n umpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1100 x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 1101 1101 # store x and y bin centers in q space 1102 1102 #self.data.source = Source() 1103 y = n umpy.ones(len(x))1104 dy = n umpy.zeros(len(x))1105 dx = n umpy.zeros(len(x))1103 y = np.ones(len(x)) 1104 dy = np.zeros(len(x)) 1105 dx = np.zeros(len(x)) 1106 1106 self.data = Data1D(x=x, y=y) 1107 1107 self.data.dx = dx … … 1173 1173 state = None 1174 1174 1175 n umpy.nan_to_num(image)1175 np.nan_to_num(image) 1176 1176 new_plot = Data2D(image=image, err_image=data.err_data) 1177 1177 new_plot.name = model.name + '2d' … … 1642 1642 for key in sld_list.keys(): 1643 1643 if ctr_list[0] == key: 1644 min_val = n umpy.min(sld_list[key])1645 max_val = n umpy.max(sld_list[key])1646 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]) 1647 1647 enable = (min_val == max_val) and \ 1648 1648 sld_data.pix_type == 'pixel' … … 1735 1735 npts = -1 1736 1736 break 1737 if n umpy.isfinite(n_val):1737 if np.isfinite(n_val): 1738 1738 npts *= int(n_val) 1739 1739 if npts > 0: … … 1772 1772 ctl.Refresh() 1773 1773 return 1774 if n umpy.isfinite(s_val):1774 if np.isfinite(s_val): 1775 1775 s_size *= s_val 1776 1776 self.sld_data.set_pixel_volumes(s_size) … … 1789 1789 try: 1790 1790 sld_data = self.parent.get_sld_from_omf() 1791 #nop = (nop * n umpy.pi) / 61791 #nop = (nop * np.pi) / 6 1792 1792 nop = len(sld_data.sld_n) 1793 1793 except: -
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/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]
Note: See TracChangeset
for help on using the changeset viewer.