Changeset 9c0f3c17 in sasview for src/sas/sasgui/plottools
- 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/plottools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/PlotPanel.py
r463e7ffc r9c0f3c17 29 29 DEFAULT_CMAP = pylab.cm.jet 30 30 import copy 31 import numpy 31 import numpy as np 32 32 33 33 from sas.sasgui.guiframe.events import StatusEvent … … 1454 1454 if self.zmin_2D <= 0 and len(output[output > 0]) > 0: 1455 1455 zmin_temp = self.zmin_2D 1456 output[output > 0] = n umpy.log10(output[output > 0])1456 output[output > 0] = np.log10(output[output > 0]) 1457 1457 #In log scale Negative values are not correct in general 1458 #output[output<=0] = math.log(n umpy.min(output[output>0]))1458 #output[output<=0] = math.log(np.min(output[output>0])) 1459 1459 elif self.zmin_2D <= 0: 1460 1460 zmin_temp = self.zmin_2D 1461 output[output > 0] = n umpy.zeros(len(output))1461 output[output > 0] = np.zeros(len(output)) 1462 1462 output[output <= 0] = -32 1463 1463 else: 1464 1464 zmin_temp = self.zmin_2D 1465 output[output > 0] = n umpy.log10(output[output > 0])1465 output[output > 0] = np.log10(output[output > 0]) 1466 1466 #In log scale Negative values are not correct in general 1467 #output[output<=0] = math.log(n umpy.min(output[output>0]))1467 #output[output<=0] = math.log(np.min(output[output>0])) 1468 1468 except: 1469 1469 #Too many problems in 2D plot with scale … … 1494 1494 X = self.x_bins[0:-1] 1495 1495 Y = self.y_bins[0:-1] 1496 X, Y = n umpy.meshgrid(X, Y)1496 X, Y = np.meshgrid(X, Y) 1497 1497 1498 1498 try: … … 1557 1557 # 1d array to use for weighting the data point averaging 1558 1558 #when they fall into a same bin. 1559 weights_data = n umpy.ones([self.data.size])1559 weights_data = np.ones([self.data.size]) 1560 1560 # get histogram of ones w/len(data); this will provide 1561 1561 #the weights of data on each bins 1562 weights, xedges, yedges = n umpy.histogram2d(x=self.qy_data,1562 weights, xedges, yedges = np.histogram2d(x=self.qy_data, 1563 1563 y=self.qx_data, 1564 1564 bins=[self.y_bins, self.x_bins], 1565 1565 weights=weights_data) 1566 1566 # get histogram of data, all points into a bin in a way of summing 1567 image, xedges, yedges = n umpy.histogram2d(x=self.qy_data,1567 image, xedges, yedges = np.histogram2d(x=self.qy_data, 1568 1568 y=self.qx_data, 1569 1569 bins=[self.y_bins, self.x_bins], … … 1583 1583 # do while loop until all vacant bins are filled up up 1584 1584 #to loop = max_loop 1585 while not(n umpy.isfinite(image[weights == 0])).all():1585 while not(np.isfinite(image[weights == 0])).all(): 1586 1586 if loop >= max_loop: # this protects never-ending loop 1587 1587 break … … 1632 1632 1633 1633 # store x and y bin centers in q space 1634 x_bins = n umpy.linspace(xmin, xmax, npix_x)1635 y_bins = n umpy.linspace(ymin, ymax, npix_y)1634 x_bins = np.linspace(xmin, xmax, npix_x) 1635 y_bins = np.linspace(ymin, ymax, npix_y) 1636 1636 1637 1637 #set x_bins and y_bins … … 1652 1652 """ 1653 1653 # No image matrix given 1654 if image == None or n umpy.ndim(image) != 2 \1655 or n umpy.isfinite(image).all() \1654 if image == None or np.ndim(image) != 2 \ 1655 or np.isfinite(image).all() \ 1656 1656 or weights == None: 1657 1657 return image … … 1659 1659 len_y = len(image) 1660 1660 len_x = len(image[1]) 1661 temp_image = n umpy.zeros([len_y, len_x])1662 weit = n umpy.zeros([len_y, len_x])1661 temp_image = np.zeros([len_y, len_x]) 1662 weit = np.zeros([len_y, len_x]) 1663 1663 # do for-loop for all pixels 1664 1664 for n_y in range(len(image)): 1665 1665 for n_x in range(len(image[1])): 1666 1666 # find only null pixels 1667 if weights[n_y][n_x] > 0 or n umpy.isfinite(image[n_y][n_x]):1667 if weights[n_y][n_x] > 0 or np.isfinite(image[n_y][n_x]): 1668 1668 continue 1669 1669 else: 1670 1670 # find 4 nearest neighbors 1671 1671 # check where or not it is at the corner 1672 if n_y != 0 and n umpy.isfinite(image[n_y - 1][n_x]):1672 if n_y != 0 and np.isfinite(image[n_y - 1][n_x]): 1673 1673 temp_image[n_y][n_x] += image[n_y - 1][n_x] 1674 1674 weit[n_y][n_x] += 1 1675 if n_x != 0 and n umpy.isfinite(image[n_y][n_x - 1]):1675 if n_x != 0 and np.isfinite(image[n_y][n_x - 1]): 1676 1676 temp_image[n_y][n_x] += image[n_y][n_x - 1] 1677 1677 weit[n_y][n_x] += 1 1678 if n_y != len_y - 1 and n umpy.isfinite(image[n_y + 1][n_x]):1678 if n_y != len_y - 1 and np.isfinite(image[n_y + 1][n_x]): 1679 1679 temp_image[n_y][n_x] += image[n_y + 1][n_x] 1680 1680 weit[n_y][n_x] += 1 1681 if n_x != len_x - 1 and n umpy.isfinite(image[n_y][n_x + 1]):1681 if n_x != len_x - 1 and np.isfinite(image[n_y][n_x + 1]): 1682 1682 temp_image[n_y][n_x] += image[n_y][n_x + 1] 1683 1683 weit[n_y][n_x] += 1 1684 1684 # go 4 next nearest neighbors when no non-zero 1685 1685 # neighbor exists 1686 if n_y != 0 and n_x != 0 and \1687 numpy.isfinite(image[n_y - 1][n_x - 1]):1686 if n_y != 0 and n_x != 0 and \ 1687 np.isfinite(image[n_y - 1][n_x - 1]): 1688 1688 temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 1689 1689 weit[n_y][n_x] += 1 1690 1690 if n_y != len_y - 1 and n_x != 0 and \ 1691 numpy.isfinite(image[n_y + 1][n_x - 1]):1691 np.isfinite(image[n_y + 1][n_x - 1]): 1692 1692 temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 1693 1693 weit[n_y][n_x] += 1 1694 1694 if n_y != len_y and n_x != len_x - 1 and \ 1695 numpy.isfinite(image[n_y - 1][n_x + 1]):1695 np.isfinite(image[n_y - 1][n_x + 1]): 1696 1696 temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 1697 1697 weit[n_y][n_x] += 1 1698 1698 if n_y != len_y - 1 and n_x != len_x - 1 and \ 1699 numpy.isfinite(image[n_y + 1][n_x + 1]):1699 np.isfinite(image[n_y + 1][n_x + 1]): 1700 1700 temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 1701 1701 weit[n_y][n_x] += 1 -
src/sas/sasgui/plottools/fitDialog.py
rdd5bf63 r9a5097c 2 2 from plottables import Theory1D 3 3 import math 4 import numpy 4 import numpy as np 5 5 import fittings 6 6 import transform … … 482 482 483 483 if self.xLabel.lower() == "log10(x)": 484 tempdy = n umpy.asarray(tempdy)484 tempdy = np.asarray(tempdy) 485 485 tempdy[tempdy == 0] = 1 486 486 chisqr, out, cov = fittings.sasfit(self.model, … … 491 491 math.log10(xmax)) 492 492 else: 493 tempdy = n umpy.asarray(tempdy)493 tempdy = np.asarray(tempdy) 494 494 tempdy[tempdy == 0] = 1 495 495 chisqr, out, cov = fittings.sasfit(self.model, … … 572 572 if self.rg_on: 573 573 if self.Rg_tctr.IsShown(): 574 rg = n umpy.sqrt(-3 * float(cstA))574 rg = np.sqrt(-3 * float(cstA)) 575 575 value = format_number(rg) 576 576 self.Rg_tctr.SetValue(value) 577 577 if self.I0_tctr.IsShown(): 578 val = n umpy.exp(cstB)578 val = np.exp(cstB) 579 579 self.I0_tctr.SetValue(format_number(val)) 580 580 if self.Rgerr_tctr.IsShown(): … … 585 585 self.Rgerr_tctr.SetValue(value) 586 586 if self.I0err_tctr.IsShown(): 587 val = n umpy.abs(numpy.exp(cstB) * errB)587 val = np.abs(np.exp(cstB) * errB) 588 588 self.I0err_tctr.SetValue(format_number(val)) 589 589 if self.Diameter_tctr.IsShown(): 590 rg = n umpy.sqrt(-2 * float(cstA))591 _diam = 4 * n umpy.sqrt(-float(cstA))590 rg = np.sqrt(-2 * float(cstA)) 591 _diam = 4 * np.sqrt(-float(cstA)) 592 592 value = format_number(_diam) 593 593 self.Diameter_tctr.SetValue(value) -
src/sas/sasgui/plottools/plottables.py
r463e7ffc r9c0f3c17 43 43 # Support for ancient python versions 44 44 import copy 45 import numpy 45 import numpy as np 46 46 import sys 47 47 import logging … … 708 708 self.dy = None 709 709 if not has_err_x: 710 dx = n umpy.zeros(len(x))710 dx = np.zeros(len(x)) 711 711 if not has_err_y: 712 dy = n umpy.zeros(len(y))712 dy = np.zeros(len(y)) 713 713 for i in range(len(x)): 714 714 try: … … 798 798 tempdy = [] 799 799 if self.dx == None: 800 self.dx = n umpy.zeros(len(self.x))800 self.dx = np.zeros(len(self.x)) 801 801 if self.dy == None: 802 self.dy = n umpy.zeros(len(self.y))802 self.dy = np.zeros(len(self.y)) 803 803 if self.xLabel == "log10(x)": 804 804 for i in range(len(self.x)): … … 828 828 tempdy = [] 829 829 if self.dx == None: 830 self.dx = n umpy.zeros(len(self.x))830 self.dx = np.zeros(len(self.x)) 831 831 if self.dy == None: 832 self.dy = n umpy.zeros(len(self.y))832 self.dy = np.zeros(len(self.y)) 833 833 if self.yLabel == "log10(y)": 834 834 for i in range(len(self.x)): … … 861 861 tempdy = [] 862 862 if self.dx == None: 863 self.dx = n umpy.zeros(len(self.x))863 self.dx = np.zeros(len(self.x)) 864 864 if self.dy == None: 865 self.dy = n umpy.zeros(len(self.y))865 self.dy = np.zeros(len(self.y)) 866 866 if xmin != None and xmax != None: 867 867 for i in range(len(self.x)): … … 1230 1230 1231 1231 def sample_graph(): 1232 import numpy as n x1232 import numpy as np 1233 1233 1234 1234 # Construct a simple graph 1235 1235 if False: 1236 x = n x.array([1, 2, 3, 4, 5, 6], 'd')1237 y = n x.array([4, 5, 6, 5, 4, 5], 'd')1238 dy = n x.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3])1236 x = np.array([1, 2, 3, 4, 5, 6], 'd') 1237 y = np.array([4, 5, 6, 5, 4, 5], 'd') 1238 dy = np.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 1239 1239 else: 1240 x = n x.linspace(0, 1., 10000)1241 y = n x.sin(2 * nx.pi * x * 2.8)1242 dy = n x.sqrt(100 * nx.abs(y)) / 1001240 x = np.linspace(0, 1., 10000) 1241 y = np.sin(2 * np.pi * x * 2.8) 1242 dy = np.sqrt(100 * np.abs(y)) / 100 1243 1243 data = Data1D(x, y, dy=dy) 1244 1244 data.xaxis('distance', 'm') -
src/sas/sasgui/plottools/binder.py
rd7bb526 r463e7ffc 4 4 import sys 5 5 import logging 6 7 logger = logging.getLogger(__name__) 6 8 7 9 class Selection(object): … … 121 123 for cid in self._connections: self.canvas.mpl_disconnect(cid) 122 124 except: 123 logg ing.error("Error disconnection canvas: %s" % sys.exc_value)125 logger.error("Error disconnection canvas: %s" % sys.exc_value) 124 126 self._connections = [] 125 127 -
src/sas/sasgui/plottools/canvas.py
rd7bb526 r463e7ffc 11 11 from matplotlib.backends.backend_wx import RendererWx 12 12 13 logger = logging.getLogger(__name__) 14 13 15 14 16 def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): … … 96 98 dc.DrawBitmap(self.canvas.bitmap, (0, 0)) 97 99 except: 98 logg ing.error(sys.exc_value)100 logger.error(sys.exc_value) 99 101 100 102 # restore original figure resolution … … 207 209 fig.draw(self) 208 210 except ValueError: 209 logg ing.error(sys.exc_value)211 logger.error(sys.exc_value) 210 212 else: 211 213 self._isRendered = False -
src/sas/sasgui/plottools/toolbar.py
rd7bb526 r463e7ffc 6 6 from matplotlib.backends.backend_wx import _load_bitmap 7 7 import logging 8 9 logger = logging.getLogger(__name__) 8 10 9 11 # Event binding code changed after version 2.5 … … 94 96 self._parent.onToolContextMenu(event=event) 95 97 except: 96 logg ing.error("Plot toolbar could not show menu")98 logger.error("Plot toolbar could not show menu") 97 99 98 100 def context_menu(self, event): … … 122 124 except: 123 125 import traceback 124 logg ing.error(traceback.format_exc())126 logger.error(traceback.format_exc()) 125 127 126 128 def copy_figure(self, event):
Note: See TracChangeset
for help on using the changeset viewer.