Changeset 2691 for trunk/python
- Timestamp:
- 12/10/12 15:16:10 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r2650 r2691 1646 1646 1647 1647 # Center and spacing 1648 dirarr = array(self._data.get_directionval()).transpose() 1649 print "Pointing range: (x, y) = (%f - %f, %f - %f)" %\ 1650 (dirarr[0].min(),dirarr[0].max(),dirarr[1].min(),dirarr[1].max()) 1651 dircent = [0.5*(dirarr[0].max() + dirarr[0].min()), 1652 0.5*(dirarr[1].max() + dirarr[1].min())] 1653 del dirarr 1648 1654 if center is None: 1649 1655 #asaplog.post() 1650 1656 asaplog.push("Grid center is not specified. Automatically calculated from pointing center.") 1651 1657 #asaplog.post("WARN") 1652 dirarr = array(self._data.get_directionval()).transpose()1653 1658 #center = [dirarr[0].mean(), dirarr[1].mean()] 1654 center = [0.5*(dirarr[0].max() + dirarr[0].min()), 1655 0.5*(dirarr[1].max() + dirarr[1].min())] 1656 del dirarr 1659 center = dircent 1657 1660 elif (type(center) in (list, tuple)) and len(center) > 1: 1658 center = center[0:2] 1661 from numpy import pi 1662 # make sure center_x is in +-pi of pointing center 1663 # (assumes dirs are in rad) 1664 rotnum = round(abs(center[0] - dircent[0])/(2*pi)) 1665 if center[0] < dircent[0]: rotnum *= -1 1666 cenx = center[0] - rotnum*2*pi 1667 center = [cenx, center[1]] 1659 1668 else: 1660 1669 msg = "Direction of grid center should be a list of float (R.A., Dec.)" … … 1673 1682 abs(dirarr[1].min()-center[1])) 1674 1683 ## slightly expand area to plot the edges 1675 #wx *= 1.01 1676 #wy *= 1.01 1677 #xgrid = wx/self._cols 1678 #ygrid = wy/self._rows 1684 #wx *= 1.1 1685 #wy *= 1.1 1679 1686 xgrid = wx/max(self._cols-1.,1.) 1687 #xgrid = wx/float(max(self._cols,1.)) 1688 xgrid *= cos(center[1]) 1680 1689 ygrid = wy/max(self._rows-1.,1.) 1681 #print "Pointing range: (x, y) = (%f - %f, %f - %f)" %\ 1682 # (dirarr[0].min(),dirarr[0].max(),dirarr[1].min(),dirarr[1].max()) 1683 # identical R.A. and/or Dec. for all spectra. 1690 #ygrid = wy/float(max(self._rows,1.)) 1691 # single pointing (identical R.A. and/or Dec. for all spectra.) 1684 1692 if xgrid == 0: 1685 1693 xgrid = 1. … … 1699 1707 spacing[i] = -val 1700 1708 spacing = spacing[0:2] 1701 # Correction of Dec. effect1702 spacing[0] /= cos(center[1])1703 1709 else: 1704 1710 msg = "Invalid spacing." … … 1707 1713 1708 1714 ntotpl = self._rows * self._cols 1709 minpos = [center[0]-spacing[0]*self._cols/2.,1710 center[1]-spacing[1]*self._rows/2.]1711 #print "Plot range: (x, y) = (%f - %f, %f - %f)" %\1712 # (minpos[0],minpos[0]+spacing[0]*self._cols,1713 # minpos[1],minpos[1]+spacing[1]*self._rows)1714 1715 ifs = self._data.getifnos() 1715 1716 if len(ifs) > 1: … … 1742 1743 self._plotter.clear() 1743 1744 self._plotter.legend() 1744 1745 1745 1746 # Adjust subplot margins 1746 1747 if not self._margins or len(self._margins) !=6: … … 1751 1752 self._plotter.figmgr.casabar.set_pagecounter(1) 1752 1753 self._plotter.figmgr.casabar.enable_button() 1754 # Plot helper 1755 from asap._asap import plothelper as plhelper 1756 ph = plhelper(self._data) 1757 ph.set_gridval(self._cols, self._rows, spacing[0], spacing[1], 1758 center[0], center[1], epoch="J2000", projname="SIN") 1753 1759 # Actual plot 1754 1760 npl = 0 1755 1761 for irow in range(self._data.nrow()): 1756 pos = self._data.get_directionval(irow)1757 ix = int((pos[0] - minpos[0])/spacing[0])1762 (ix, iy) = ph.get_gpos(irow) 1763 #print("asapplotter.plotgrid: (ix, iy) = (%f, %f)" % (ix, iy)) 1758 1764 if ix < 0 or ix >= self._cols: 1759 1765 #print "Row %d : Out of X-range (x = %f) ... skipped" % (irow, pos[0]) 1760 1766 continue 1761 i y = int((pos[1]- minpos[1])/spacing[1])1762 if iy < 0 or iy >= self._ cols:1767 ix = int(ix) 1768 if iy < 0 or iy >= self._rows: 1763 1769 #print "Row %d : Out of Y-range (y = %f) ... skipped" % (irow,pos[1]) 1764 1770 continue 1765 ipanel = ix + iy*self._cols 1771 iy = int(iy) 1772 ipanel = ix + iy*self._rows 1773 #print("Resolved panel Id (%d, %d): %d" % (ix, iy, ipanel)) 1766 1774 if len(self._plotter.subplots[ipanel]['lines']) > 0: 1767 1775 #print "Row %d : panel %d lready plotted ... skipped" % (irow,ipanel) … … 1782 1790 self._plotter.set_axes('xlabel', xlab) 1783 1791 self._plotter.set_axes('ylabel', ylab) 1784 #from numpy import pi1785 #lbl = "(%f, %f)" % (self._data.get_directionval(irow)[0]*180/pi,self._data.get_directionval(irow)[1]*180./pi)1786 1792 lbl = self._data.get_direction(irow) 1787 1793 self._plotter.set_axes('title',lbl)
Note:
See TracChangeset
for help on using the changeset viewer.