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