Changes in src/sas/sasgui/plottools/PlotPanel.py [463e7ffc:9a5097c] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/PlotPanel.py
r463e7ffc r9a5097c 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 34 34 from .toolbar import NavigationToolBar, PlotPrintout, bind 35 36 logger = logging.getLogger(__name__)37 35 38 36 def show_tree(obj, d=0): … … 1454 1452 if self.zmin_2D <= 0 and len(output[output > 0]) > 0: 1455 1453 zmin_temp = self.zmin_2D 1456 output[output > 0] = n umpy.log10(output[output > 0])1454 output[output > 0] = np.log10(output[output > 0]) 1457 1455 #In log scale Negative values are not correct in general 1458 #output[output<=0] = math.log(n umpy.min(output[output>0]))1456 #output[output<=0] = math.log(np.min(output[output>0])) 1459 1457 elif self.zmin_2D <= 0: 1460 1458 zmin_temp = self.zmin_2D 1461 output[output > 0] = n umpy.zeros(len(output))1459 output[output > 0] = np.zeros(len(output)) 1462 1460 output[output <= 0] = -32 1463 1461 else: 1464 1462 zmin_temp = self.zmin_2D 1465 output[output > 0] = n umpy.log10(output[output > 0])1463 output[output > 0] = np.log10(output[output > 0]) 1466 1464 #In log scale Negative values are not correct in general 1467 #output[output<=0] = math.log(n umpy.min(output[output>0]))1465 #output[output<=0] = math.log(np.min(output[output>0])) 1468 1466 except: 1469 1467 #Too many problems in 2D plot with scale … … 1494 1492 X = self.x_bins[0:-1] 1495 1493 Y = self.y_bins[0:-1] 1496 X, Y = n umpy.meshgrid(X, Y)1494 X, Y = np.meshgrid(X, Y) 1497 1495 1498 1496 try: … … 1508 1506 from mpl_toolkits.mplot3d import Axes3D 1509 1507 except: 1510 logg er.error("PlotPanel could not import Axes3D")1508 logging.error("PlotPanel could not import Axes3D") 1511 1509 self.subplot.figure.clear() 1512 1510 ax = Axes3D(self.subplot.figure) … … 1557 1555 # 1d array to use for weighting the data point averaging 1558 1556 #when they fall into a same bin. 1559 weights_data = n umpy.ones([self.data.size])1557 weights_data = np.ones([self.data.size]) 1560 1558 # get histogram of ones w/len(data); this will provide 1561 1559 #the weights of data on each bins 1562 weights, xedges, yedges = n umpy.histogram2d(x=self.qy_data,1560 weights, xedges, yedges = np.histogram2d(x=self.qy_data, 1563 1561 y=self.qx_data, 1564 1562 bins=[self.y_bins, self.x_bins], 1565 1563 weights=weights_data) 1566 1564 # 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,1565 image, xedges, yedges = np.histogram2d(x=self.qy_data, 1568 1566 y=self.qx_data, 1569 1567 bins=[self.y_bins, self.x_bins], … … 1583 1581 # do while loop until all vacant bins are filled up up 1584 1582 #to loop = max_loop 1585 while not(n umpy.isfinite(image[weights == 0])).all():1583 while not(np.isfinite(image[weights == 0])).all(): 1586 1584 if loop >= max_loop: # this protects never-ending loop 1587 1585 break … … 1632 1630 1633 1631 # 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)1632 x_bins = np.linspace(xmin, xmax, npix_x) 1633 y_bins = np.linspace(ymin, ymax, npix_y) 1636 1634 1637 1635 #set x_bins and y_bins … … 1652 1650 """ 1653 1651 # No image matrix given 1654 if image == None or n umpy.ndim(image) != 2 \1655 or n umpy.isfinite(image).all() \1652 if image == None or np.ndim(image) != 2 \ 1653 or np.isfinite(image).all() \ 1656 1654 or weights == None: 1657 1655 return image … … 1659 1657 len_y = len(image) 1660 1658 len_x = len(image[1]) 1661 temp_image = n umpy.zeros([len_y, len_x])1662 weit = n umpy.zeros([len_y, len_x])1659 temp_image = np.zeros([len_y, len_x]) 1660 weit = np.zeros([len_y, len_x]) 1663 1661 # do for-loop for all pixels 1664 1662 for n_y in range(len(image)): 1665 1663 for n_x in range(len(image[1])): 1666 1664 # find only null pixels 1667 if weights[n_y][n_x] > 0 or n umpy.isfinite(image[n_y][n_x]):1665 if weights[n_y][n_x] > 0 or np.isfinite(image[n_y][n_x]): 1668 1666 continue 1669 1667 else: 1670 1668 # find 4 nearest neighbors 1671 1669 # check where or not it is at the corner 1672 if n_y != 0 and n umpy.isfinite(image[n_y - 1][n_x]):1670 if n_y != 0 and np.isfinite(image[n_y - 1][n_x]): 1673 1671 temp_image[n_y][n_x] += image[n_y - 1][n_x] 1674 1672 weit[n_y][n_x] += 1 1675 if n_x != 0 and n umpy.isfinite(image[n_y][n_x - 1]):1673 if n_x != 0 and np.isfinite(image[n_y][n_x - 1]): 1676 1674 temp_image[n_y][n_x] += image[n_y][n_x - 1] 1677 1675 weit[n_y][n_x] += 1 1678 if n_y != len_y - 1 and n umpy.isfinite(image[n_y + 1][n_x]):1676 if n_y != len_y - 1 and np.isfinite(image[n_y + 1][n_x]): 1679 1677 temp_image[n_y][n_x] += image[n_y + 1][n_x] 1680 1678 weit[n_y][n_x] += 1 1681 if n_x != len_x - 1 and n umpy.isfinite(image[n_y][n_x + 1]):1679 if n_x != len_x - 1 and np.isfinite(image[n_y][n_x + 1]): 1682 1680 temp_image[n_y][n_x] += image[n_y][n_x + 1] 1683 1681 weit[n_y][n_x] += 1 1684 1682 # go 4 next nearest neighbors when no non-zero 1685 1683 # neighbor exists 1686 if n_y != 0 and n_x != 0 and \1687 numpy.isfinite(image[n_y - 1][n_x - 1]):1684 if n_y != 0 and n_x != 0 and \ 1685 np.isfinite(image[n_y - 1][n_x - 1]): 1688 1686 temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 1689 1687 weit[n_y][n_x] += 1 1690 1688 if n_y != len_y - 1 and n_x != 0 and \ 1691 numpy.isfinite(image[n_y + 1][n_x - 1]):1689 np.isfinite(image[n_y + 1][n_x - 1]): 1692 1690 temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 1693 1691 weit[n_y][n_x] += 1 1694 1692 if n_y != len_y and n_x != len_x - 1 and \ 1695 numpy.isfinite(image[n_y - 1][n_x + 1]):1693 np.isfinite(image[n_y - 1][n_x + 1]): 1696 1694 temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 1697 1695 weit[n_y][n_x] += 1 1698 1696 if n_y != len_y - 1 and n_x != len_x - 1 and \ 1699 numpy.isfinite(image[n_y + 1][n_x + 1]):1697 np.isfinite(image[n_y + 1][n_x + 1]): 1700 1698 temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 1701 1699 weit[n_y][n_x] += 1
Note: See TracChangeset
for help on using the changeset viewer.