Changeset 9a5097c in sasview for src/sas/sasgui/plottools/PlotPanel.py
- Timestamp:
- Mar 26, 2017 9:33:16 PM (7 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:
- ed2276f
- Parents:
- 9146ed9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/PlotPanel.py
r198fa76 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 … … 1452 1452 if self.zmin_2D <= 0 and len(output[output > 0]) > 0: 1453 1453 zmin_temp = self.zmin_2D 1454 output[output > 0] = n umpy.log10(output[output > 0])1454 output[output > 0] = np.log10(output[output > 0]) 1455 1455 #In log scale Negative values are not correct in general 1456 #output[output<=0] = math.log(n umpy.min(output[output>0]))1456 #output[output<=0] = math.log(np.min(output[output>0])) 1457 1457 elif self.zmin_2D <= 0: 1458 1458 zmin_temp = self.zmin_2D 1459 output[output > 0] = n umpy.zeros(len(output))1459 output[output > 0] = np.zeros(len(output)) 1460 1460 output[output <= 0] = -32 1461 1461 else: 1462 1462 zmin_temp = self.zmin_2D 1463 output[output > 0] = n umpy.log10(output[output > 0])1463 output[output > 0] = np.log10(output[output > 0]) 1464 1464 #In log scale Negative values are not correct in general 1465 #output[output<=0] = math.log(n umpy.min(output[output>0]))1465 #output[output<=0] = math.log(np.min(output[output>0])) 1466 1466 except: 1467 1467 #Too many problems in 2D plot with scale … … 1492 1492 X = self.x_bins[0:-1] 1493 1493 Y = self.y_bins[0:-1] 1494 X, Y = n umpy.meshgrid(X, Y)1494 X, Y = np.meshgrid(X, Y) 1495 1495 1496 1496 try: … … 1555 1555 # 1d array to use for weighting the data point averaging 1556 1556 #when they fall into a same bin. 1557 weights_data = n umpy.ones([self.data.size])1557 weights_data = np.ones([self.data.size]) 1558 1558 # get histogram of ones w/len(data); this will provide 1559 1559 #the weights of data on each bins 1560 weights, xedges, yedges = n umpy.histogram2d(x=self.qy_data,1560 weights, xedges, yedges = np.histogram2d(x=self.qy_data, 1561 1561 y=self.qx_data, 1562 1562 bins=[self.y_bins, self.x_bins], 1563 1563 weights=weights_data) 1564 1564 # get histogram of data, all points into a bin in a way of summing 1565 image, xedges, yedges = n umpy.histogram2d(x=self.qy_data,1565 image, xedges, yedges = np.histogram2d(x=self.qy_data, 1566 1566 y=self.qx_data, 1567 1567 bins=[self.y_bins, self.x_bins], … … 1581 1581 # do while loop until all vacant bins are filled up up 1582 1582 #to loop = max_loop 1583 while not(n umpy.isfinite(image[weights == 0])).all():1583 while not(np.isfinite(image[weights == 0])).all(): 1584 1584 if loop >= max_loop: # this protects never-ending loop 1585 1585 break … … 1630 1630 1631 1631 # store x and y bin centers in q space 1632 x_bins = n umpy.linspace(xmin, xmax, npix_x)1633 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) 1634 1634 1635 1635 #set x_bins and y_bins … … 1650 1650 """ 1651 1651 # No image matrix given 1652 if image == None or n umpy.ndim(image) != 2 \1653 or n umpy.isfinite(image).all() \1652 if image == None or np.ndim(image) != 2 \ 1653 or np.isfinite(image).all() \ 1654 1654 or weights == None: 1655 1655 return image … … 1657 1657 len_y = len(image) 1658 1658 len_x = len(image[1]) 1659 temp_image = n umpy.zeros([len_y, len_x])1660 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]) 1661 1661 # do for-loop for all pixels 1662 1662 for n_y in range(len(image)): 1663 1663 for n_x in range(len(image[1])): 1664 1664 # find only null pixels 1665 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]): 1666 1666 continue 1667 1667 else: 1668 1668 # find 4 nearest neighbors 1669 1669 # check where or not it is at the corner 1670 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]): 1671 1671 temp_image[n_y][n_x] += image[n_y - 1][n_x] 1672 1672 weit[n_y][n_x] += 1 1673 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]): 1674 1674 temp_image[n_y][n_x] += image[n_y][n_x - 1] 1675 1675 weit[n_y][n_x] += 1 1676 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]): 1677 1677 temp_image[n_y][n_x] += image[n_y + 1][n_x] 1678 1678 weit[n_y][n_x] += 1 1679 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]): 1680 1680 temp_image[n_y][n_x] += image[n_y][n_x + 1] 1681 1681 weit[n_y][n_x] += 1 1682 1682 # go 4 next nearest neighbors when no non-zero 1683 1683 # neighbor exists 1684 if n_y != 0 and n_x != 0 and \1685 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]): 1686 1686 temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 1687 1687 weit[n_y][n_x] += 1 1688 1688 if n_y != len_y - 1 and n_x != 0 and \ 1689 numpy.isfinite(image[n_y + 1][n_x - 1]):1689 np.isfinite(image[n_y + 1][n_x - 1]): 1690 1690 temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 1691 1691 weit[n_y][n_x] += 1 1692 1692 if n_y != len_y and n_x != len_x - 1 and \ 1693 numpy.isfinite(image[n_y - 1][n_x + 1]):1693 np.isfinite(image[n_y - 1][n_x + 1]): 1694 1694 temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 1695 1695 weit[n_y][n_x] += 1 1696 1696 if n_y != len_y - 1 and n_x != len_x - 1 and \ 1697 numpy.isfinite(image[n_y + 1][n_x + 1]):1697 np.isfinite(image[n_y + 1][n_x + 1]): 1698 1698 temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 1699 1699 weit[n_y][n_x] += 1
Note: See TracChangeset
for help on using the changeset viewer.