Changes in src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py [9a5097c:463e7ffc] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py
r9a5097c r463e7ffc 7 7 import sys 8 8 import os 9 import numpy as np9 import numpy 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 p.fabs(sld_mx) + np.fabs(sld_my) + \744 n p.fabs(sld_mz) + np.fabs(output.sld_n))745 sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 746 numpy.fabs(sld_mz) + numpy.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 p.ones(len(pix_symbol), dtype='bool')761 other_color = numpy.ones(len(pix_symbol), dtype='bool') 760 762 for key in color_dic.keys(): 761 763 chosen_color = pix_symbol == key 762 if n p.any(chosen_color):764 if numpy.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 p.any(other_color):771 if numpy.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 p.fabs(sld_mx))798 max_my = max(n p.fabs(sld_my))799 max_mz = max(n p.fabs(sld_mz))799 max_mx = max(numpy.fabs(sld_mx)) 800 max_my = max(numpy.fabs(sld_my)) 801 max_mz = max(numpy.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 p.fabs(unit_x2 * 0.8)815 color_y = n p.fabs(unit_y2 * 0.8)816 color_z = n p.fabs(unit_z2 * 0.8)816 color_x = numpy.fabs(unit_x2 * 0.8) 817 color_y = numpy.fabs(unit_y2 * 0.8) 818 color_z = numpy.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 p.column_stack((pos_x, x2))821 y_arrow = n p.column_stack((pos_y, y2))822 z_arrow = n p.column_stack((pos_z, z2))823 colors = n p.column_stack((color_x, color_y, color_z))822 x_arrow = numpy.column_stack((pos_x, x2)) 823 y_arrow = numpy.column_stack((pos_y, y2)) 824 z_arrow = numpy.column_stack((pos_z, z2)) 825 colors = numpy.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 p.zeros(len(self.data.y))884 i_out = numpy.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 p.zeros(len(self.data.data))888 i_out = numpy.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 p.empty(0)993 out = numpy.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 p.append(out, outi)1002 out = numpy.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 p.append(out, outi)1010 out = numpy.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 p.sqrt(2)1031 qmax = self.qmax_x #/ numpy.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 p.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1051 y = n p.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)1052 x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 1053 y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 1052 1054 ## use data info instead 1053 new_x = n p.tile(x, (len(y), 1))1054 new_y = n p.tile(y, (len(x), 1))1055 new_x = numpy.tile(x, (len(y), 1)) 1056 new_y = numpy.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 p.sqrt(qx_data * qx_data + qy_data * qy_data)1061 q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 1060 1062 # set all True (standing for unmasked) as default 1061 mask = n p.ones(len(qx_data), dtype=bool)1063 mask = numpy.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 p.ones(len(mask))1067 self.data.err_data = n p.ones(len(mask))1068 self.data.data = numpy.ones(len(mask)) 1069 self.data.err_data = numpy.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 p.ones(len(residuals.y))1088 residuals.dy = numpy.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 p.sqrt(2)1095 qmax = self.qmax_x #/ numpy.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 p.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)1100 x = numpy.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 p.ones(len(x))1102 dy = n p.zeros(len(x))1103 dx = n p.zeros(len(x))1103 y = numpy.ones(len(x)) 1104 dy = numpy.zeros(len(x)) 1105 dx = numpy.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 p.nan_to_num(image)1175 numpy.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 p.min(sld_list[key])1643 max_val = n p.max(sld_list[key])1644 mean_val = n p.mean(sld_list[key])1644 min_val = numpy.min(sld_list[key]) 1645 max_val = numpy.max(sld_list[key]) 1646 mean_val = numpy.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 p.isfinite(n_val):1737 if numpy.isfinite(n_val): 1736 1738 npts *= int(n_val) 1737 1739 if npts > 0: … … 1770 1772 ctl.Refresh() 1771 1773 return 1772 if n p.isfinite(s_val):1774 if numpy.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 p.pi) / 61791 #nop = (nop * numpy.pi) / 6 1790 1792 nop = len(sld_data.sld_n) 1791 1793 except:
Note: See TracChangeset
for help on using the changeset viewer.