Changeset 2691


Ignore:
Timestamp:
12/10/12 15:16:10 (11 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: No (a fix)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: unit tests of sdplot

Put in Release Notes: Yes

Module(s): asapplotter(.plotgrid) and sdplot

Description:

asapplotter.plotgrid uses PlotHelper? to calculate projection.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2650 r2691  
    16461646
    16471647        # 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
    16481654        if center is None:
    16491655            #asaplog.post()
    16501656            asaplog.push("Grid center is not specified. Automatically calculated from pointing center.")
    16511657            #asaplog.post("WARN")
    1652             dirarr = array(self._data.get_directionval()).transpose()
    16531658            #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
    16571660        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]]
    16591668        else:
    16601669            msg = "Direction of grid center should be a list of float (R.A., Dec.)"
     
    16731682                          abs(dirarr[1].min()-center[1]))
    16741683            ## 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
    16791686            xgrid = wx/max(self._cols-1.,1.)
     1687            #xgrid = wx/float(max(self._cols,1.))
     1688            xgrid *= cos(center[1])
    16801689            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.)
    16841692            if xgrid == 0:
    16851693                xgrid = 1.
     
    16991707                    spacing[i] = -val
    17001708            spacing = spacing[0:2]
    1701             # Correction of Dec. effect
    1702             spacing[0] /= cos(center[1])
    17031709        else:
    17041710            msg = "Invalid spacing."
     
    17071713
    17081714        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)
    17141715        ifs = self._data.getifnos()
    17151716        if len(ifs) > 1:
     
    17421743        self._plotter.clear()
    17431744        self._plotter.legend()
    1744        
     1745
    17451746        # Adjust subplot margins
    17461747        if not self._margins or len(self._margins) !=6:
     
    17511752            self._plotter.figmgr.casabar.set_pagecounter(1)
    17521753            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")
    17531759        # Actual plot
    17541760        npl = 0
    17551761        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))
    17581764            if ix < 0 or ix >= self._cols:
    17591765                #print "Row %d : Out of X-range (x = %f) ... skipped" % (irow, pos[0])
    17601766                continue
    1761             iy = 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:
    17631769                #print "Row %d : Out of Y-range (y = %f) ... skipped" % (irow,pos[1])
    17641770                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))
    17661774            if len(self._plotter.subplots[ipanel]['lines']) > 0:
    17671775                #print "Row %d : panel %d lready plotted ... skipped" % (irow,ipanel)
     
    17821790            self._plotter.set_axes('xlabel', xlab)
    17831791            self._plotter.set_axes('ylabel', ylab)
    1784             #from numpy import pi
    1785             #lbl = "(%f, %f)" % (self._data.get_directionval(irow)[0]*180/pi,self._data.get_directionval(irow)[1]*180./pi)
    17861792            lbl = self._data.get_direction(irow)
    17871793            self._plotter.set_axes('title',lbl)
Note: See TracChangeset for help on using the changeset viewer.