Changeset 2607


Ignore:
Timestamp:
07/25/12 15:51:33 (12 years ago)
Author:
Kana Sugimoto
Message:

New Development: No (bug fixes)

JIRA Issue: Yes (CAS-1814/Trac-274)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: unit tests will be committed shortly (CASA)

Put in Release Notes: No

Module(s): asapplotter, sdplot

Description:

Take projection effect into account in plotting.
Fixed automatic calculation of spacing.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2604 r2607  
    16121612        """
    16131613        from asap import scantable
    1614         from numpy import array, ma
     1614        from numpy import array, ma, cos
    16151615        if not self._data and not scan:
    16161616            msg = "No scantable is specified to plot"
     
    16491649
    16501650        # Center and spacing
    1651         if type(center) == list and len(center) > 1:
    1652             center = center[0:2]
    1653         else:
    1654             asaplog.post()
     1651        if center is None:
     1652            #asaplog.post()
    16551653            asaplog.push("Grid center is not specified. Automatically calculated from pointing center.")
    1656             asaplog.post("WARN")
     1654            #asaplog.post("WARN")
    16571655            dirarr = array(self._data.get_directionval()).transpose()
    16581656            #center = [dirarr[0].mean(), dirarr[1].mean()]
     
    16601658                      0.5*(dirarr[1].max() + dirarr[1].min())]
    16611659            del dirarr
     1660        elif (type(center) in (list, tuple)) and len(center) > 1:
     1661            center = center[0:2]
     1662        else:
     1663            msg = "Direction of grid center should be a list of float (R.A., Dec.)"
     1664            raise ValueError, msg
    16621665        asaplog.push("Grid center: (%f, %f) " % (center[0],center[1]))
    16631666
    16641667        if spacing is None:
    1665             asaplog.post()
     1668            #asaplog.post()
    16661669            asaplog.push("Grid spacing not specified. Automatically calculated from map coverage")
    1667             asaplog.post("WARN")
     1670            #asaplog.post("WARN")
    16681671            # automatically get spacing
    16691672            dirarr = array(self._data.get_directionval()).transpose()
     
    16721675            wy = 2. * max(abs(dirarr[1].max()-center[1]),
    16731676                          abs(dirarr[1].min()-center[1]))
    1674             # 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
     1677            ## slightly expand area to plot the edges
     1678            #wx *= 1.01
     1679            #wy *= 1.01
     1680            #xgrid = wx/self._cols
     1681            #ygrid = wy/self._rows
     1682            xgrid = wx/max(self._cols-1.,1.)
     1683            ygrid = wy/max(self._rows-1.,1.)
    16791684            #print "Pointing range: (x, y) = (%f - %f, %f - %f)" %\
    16801685            #  (dirarr[0].min(),dirarr[0].max(),dirarr[1].min(),dirarr[1].max())
     
    16891694        #elif isinstance(spacing, str):
    16901695        #    # spacing is a quantity
    1691         elif isinstance(spacing,list) and len(spacing) > 1:
     1696        elif (type(spacing) in (list, tuple)) and len(spacing) > 1:
    16921697            for i in xrange(2):
    16931698                val = spacing[i]
     
    16971702                    spacing[i] = -val
    16981703            spacing = spacing[0:2]
     1704            # Correction of Dec. effect
     1705            spacing[0] /= cos(center[1])
    16991706        else:
    17001707            msg = "Invalid spacing."
    17011708            raise TypeError(msg)
    1702         asaplog.push("Spacing: (%f, %f) " % (spacing[0],spacing[1]))
     1709        asaplog.push("Spacing: (%f, %f) (projected)" % (spacing[0],spacing[1]))
    17031710
    17041711        ntotpl = self._rows * self._cols
    17051712        minpos = [center[0]-spacing[0]*self._cols/2.,
    17061713                  center[1]-spacing[1]*self._rows/2.]
    1707         #xbound = [center[0]-spacing[0]*self._cols/2.,
    1708         #          center[0]+spacing[0]*self._cols/2.]
    1709         #ybound = [center[1]-spacing[1]*self._rows/2.,
    1710         #          center[1]+spacing[1]*self._rows/2.]
    17111714        #print "Plot range: (x, y) = (%f - %f, %f - %f)" %\
    17121715        #      (minpos[0],minpos[0]+spacing[0]*self._cols,
    17131716        #       minpos[1],minpos[1]+spacing[1]*self._rows)
    1714         ##      (xbound[0],xbound[1],ybound[0],ybound[1])
    17151717        ifs = self._data.getifnos()
    17161718        if len(ifs) > 1:
     
    17501752                                 nplots=ntotpl,margin=self._margins,ganged=True)
    17511753        if self.casabar_exists():
    1752             #self._plotter.figmgr.casabar.disable_button()
    17531754            self._plotter.figmgr.casabar.set_pagecounter(1)
    17541755            self._plotter.figmgr.casabar.enable_button()
     
    17581759            pos = self._data.get_directionval(irow)
    17591760            ix = int((pos[0] - minpos[0])/spacing[0])
    1760             #if pos[0] < xbound[0] or pos[0] > xbound[1]:
    17611761            if ix < 0 or ix >= self._cols:
    17621762                #print "Row %d : Out of X-range (x = %f) ... skipped" % (irow, pos[0])
    17631763                continue
    1764             #ix = min(int((pos[0] - xbound[0])/spacing[0]),self._cols)
    17651764            iy = int((pos[1]- minpos[1])/spacing[1])
    1766             #if pos[1] < ybound[0] or pos[1] > ybound[1]:
    17671765            if iy < 0 or iy >= self._cols:
    17681766                #print "Row %d : Out of Y-range (y = %f) ... skipped" % (irow,pos[1])
    17691767                continue
    1770             #iy = min(int((pos[1]- ybound[0])/spacing[1]),self._rows)
    17711768            ipanel = ix + iy*self._cols
    17721769            if len(self._plotter.subplots[ipanel]['lines']) > 0:
Note: See TracChangeset for help on using the changeset viewer.