Changeset 2991 for trunk/python


Ignore:
Timestamp:
09/12/14 21:31:17 (10 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-6704)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: renamed private method asapplotter._plottp2 asapplotter._plottp_in_time

Test Programs:

Put in Release Notes: No

Module(s): asapplotter

Description: renamed the name of a private method, asapplotter._plottp2, asapplotter._plottp_in_time. An improvements to error handling.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2990 r2991  
    16861686            self._plottp(self._data)
    16871687        else:
    1688             self._plottp2(self._data,colorby)
     1688            self._plottp_in_time(self._data,colorby)
    16891689        if self._minmaxy is not None:
    16901690            self._plotter.set_limits(ylim=self._minmaxy)
     
    16941694        return
    16951695
    1696     def _plottp2(self,scan,colorby):
     1696    def _plottp_in_time(self,scan,colorby):
    16971697        """
    16981698        private method for plotting total power data in time
     1699        Parameters:
     1700            scan    : input scantable instance
     1701            colorby : change color by either
     1702                      'type'(source type)|'scan'|'if'|'pol'|'beam'
    16991703        """
    17001704        from numpy import ma, array, arange, logical_not
     
    17121716        #ylab = self._ordinate and self._ordinate[panelcount] \
    17131717        #       or scan._get_ordinate_label()
    1714         tmplab = 'row number' if colorby=='' else 'Time (UTC)' 
    1715         xlab = self._abcissa or tmplab
     1718        xlab = self._abcissa or 'Time (UTC)'
    17161719        ylab = self._ordinate or scan._get_ordinate_label()
    17171720        self._plotter.set_axes('xlabel',xlab)
     
    17281731        validtypes=['type','scan','if','pol', 'beam']
    17291732        stype = None
     1733        col_msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes)
    17301734        if (colorby in validtypes):
    17311735            stype = colorby[0]
    17321736        elif len(colorby) > 0:
    1733             msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes)
    1734             raise ValueError(msg)
     1737            raise ValueError(col_msg)
    17351738        if not stype:
    1736             selIds = [""] # cheating
    1737             sellab = "all points"
     1739            raise ValueError(col_msg)
    17381740        elif stype == 't':
    17391741            selIds = range(15)
     
    17481750        for idx in selIds:
    17491751            sel = selector() + basesel
    1750             if stype:
    1751                 bid = getattr(basesel,'get_'+colorby+"s")()
    1752                 if (len(bid) > 0) and (not idx in bid):
    1753                     # base selection doesn't contain idx
    1754                     # Note summation of selector is logical sum if
    1755                     continue
    1756                 getattr(sel, selFunc)([idx])
     1752            bid = getattr(basesel,'get_'+colorby+"s")()
     1753            if (len(bid) > 0) and (not idx in bid):
     1754                # base selection doesn't contain idx
     1755                # Note summation of selector is logical sum if
     1756                continue
     1757            getattr(sel, selFunc)([idx])
    17571758            if not sel.is_empty():
    17581759                try:
     
    17711772            y = ma.masked_array(y,mask=logical_not(array(m,copy=False)))
    17721773            # try to handle spectral data somewhat...
    1773             l,m = y.shape
     1774            try:
     1775                l,m = y.shape
     1776            except ValueError, e:
     1777                raise ValueError(str(e)+" This error usually occurs when you select multiple spws with different number of channels. Try selecting single channels and retry.")
    17741778            if m > 1:
    17751779                y=y.mean(axis=1)
     
    17811785            #self._plotter.set_line(label=llbl)
    17821786            self._plotter.set_line(label=(sellab+str(idx)))
    1783             if stype:
    1784                 from matplotlib.dates import date2num
    1785                 from pytz import timezone
    1786                 dates = self._data.get_time(asdatetime=True)
    1787                 alldates += list(dates)
    1788                 x = date2num(dates)
    1789                 tz = timezone('UTC')
    1790                 self._plotter.axes.plot_date(x,y,'-',tz=tz)
    1791             else:
    1792                 x = arange(len(y))
    1793                 self._plotter.plot(x,y)
     1787            from matplotlib.dates import date2num
     1788            from pytz import timezone
     1789            dates = self._data.get_time(asdatetime=True)
     1790            alldates += list(dates)
     1791            x = date2num(dates)
     1792            tz = timezone('UTC')
     1793            self._plotter.axes.plot_date(x,y,'-',tz=tz)
     1794
    17941795        # legend and axis formatting
    1795         if stype:
    1796             (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(alldates)
    1797             ax = self.gca()
    1798             ax.xaxis.set_major_formatter(timefmt)
    1799             ax.xaxis.set_major_locator(majloc)
    1800             ax.xaxis.set_minor_locator(minloc)
    1801             self._plotter.legend(self._legendloc)
    1802         else: self._plotter.legend(None)
     1796        (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(alldates)
     1797        ax = self.gca()
     1798        ax.xaxis.set_major_formatter(timefmt)
     1799        ax.xaxis.set_major_locator(majloc)
     1800        ax.xaxis.set_minor_locator(minloc)
     1801        self._plotter.legend(self._legendloc)
    18031802
    18041803    def _plottp(self,scan):
Note: See TracChangeset for help on using the changeset viewer.