Changeset 2992 for trunk/python


Ignore:
Timestamp:
09/24/14 16:15:21 (10 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-6704)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asapplotter, sdplot

Description: Fixed bugs in asapplotter._plottp_in_time.

Combination of the first IFs/Pols/Beams is selected to plot total power unless it is not used for plot overlay.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2991 r2992  
    17111711        self._plotter.set_panels()
    17121712        self._plotter.palette(0)
    1713         #title
    1714         #xlab = self._abcissa and self._abcissa[panelcount] \
    1715         #       or scan._getabcissalabel()
    1716         #ylab = self._ordinate and self._ordinate[panelcount] \
    1717         #       or scan._get_ordinate_label()
    1718         xlab = self._abcissa or 'Time (UTC)'
    1719         ylab = self._ordinate or scan._get_ordinate_label()
    1720         self._plotter.set_axes('xlabel',xlab)
    1721         self._plotter.set_axes('ylabel',ylab)
    1722         lbl = self._get_label(scan, r, 's', self._title)
    1723         if isinstance(lbl, list) or isinstance(lbl, tuple):
    1724         #    if 0 <= panelcount < len(lbl):
    1725         #        lbl = lbl[panelcount]
    1726         #    else:
    1727                 # get default label
    1728              lbl = self._get_label(scan, r, self._panelling, None)
    1729         self._plotter.set_axes('title',lbl)
    17301713        # check of overlay settings
    1731         validtypes=['type','scan','if','pol', 'beam']
     1714        time_types = ['type','scan'] # time dependent meta-data
     1715        misc_types = ['if','pol','beam'] # time independent meta-data
     1716        validtypes=time_types + misc_types
    17321717        stype = None
    17331718        col_msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes)
     1719        colorby = colorby.lower()
    17341720        if (colorby in validtypes):
    17351721            stype = colorby[0]
     
    17381724        if not stype:
    17391725            raise ValueError(col_msg)
    1740         elif stype == 't':
     1726        # Selection and sort order
     1727        basesel = scan.get_selection()
     1728        if colorby in misc_types: misc_types.pop(misc_types.index(colorby))
     1729        sel_lbl = ""
     1730        for meta in misc_types:
     1731            idx = getattr(scan,'get'+meta+'nos')()
     1732            if len(idx) > 1: getattr(basesel, 'set_'+meta+'s')([idx[0]])
     1733            sel_lbl += ("%s%d, " % (meta.upper(), idx[0]))
     1734        sel_lbl = sel_lbl.rstrip(', ')
     1735        scan.set_selection(basesel)
     1736        if len(sel_lbl) > 0:
     1737            asaplog.push("Selection contains multiple IFs/Pols/Beams. Plotting the first ones: %s" % sel_lbl)
     1738            asaplog.post("WARN")
     1739        if stype == 't':
    17411740            selIds = range(15)
    17421741            sellab = "src type "
     
    17451744            sellab = colorby.upper()
    17461745        selFunc = "set_"+colorby+"s"
    1747         basesel = scan.get_selection()
    1748         if stype: basesel.set_order(["TIME"])
     1746        basesel.set_order(["TIME"])
     1747        # define axes labels
     1748        xlab = self._abcissa or 'Time (UTC)'
     1749        ylab = self._ordinate or scan._get_ordinate_label()
     1750        self._plotter.set_axes('xlabel',xlab)
     1751        self._plotter.set_axes('ylabel',ylab)
     1752        # define the panel title
     1753        if len(sel_lbl) > 0: lbl = sel_lbl
     1754        else: lbl = self._get_label(scan, r, 's', self._title)
     1755        if isinstance(lbl, list) or isinstance(lbl, tuple):
     1756            # get default label
     1757            lbl = self._get_label(scan, r, self._panelling, None)
     1758        self._plotter.set_axes('title',lbl)
     1759        # linestyle
     1760        lstyle = '' if colorby in time_types else ':'
    17491761        alldates = []
    17501762        for idx in selIds:
     
    17751787                l,m = y.shape
    17761788            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.")
     1789                raise ValueError(str(e)+" This error usually occurs when you select multiple spws with different number of channels. Try selecting single spw and retry.")
    17781790            if m > 1:
    17791791                y=y.mean(axis=1)
     
    17821794            y = ma.masked_array(y,mask=m)
    17831795            if len(y) == 0: continue
    1784             #llbl = self._get_label(scan, r, self._stacking, None)
    1785             #self._plotter.set_line(label=llbl)
    1786             self._plotter.set_line(label=(sellab+str(idx)))
     1796            # line label
     1797            llbl=sellab+str(idx)
    17871798            from matplotlib.dates import date2num
    17881799            from pytz import timezone
     
    17911802            x = date2num(dates)
    17921803            tz = timezone('UTC')
    1793             self._plotter.axes.plot_date(x,y,'-',tz=tz)
     1804            # get color
     1805            lc = self._plotter.colormap[self._plotter.color]
     1806            self._plotter.palette( (self._plotter.color+1) % len(self._plotter.colormap) )
     1807            # actual plotting
     1808            self._plotter.axes.plot_date(x,y,tz=tz,label=llbl,linestyle=lstyle,color=lc,
     1809                                         marker='o',markersize=3,markeredgewidth=0)
    17941810
    17951811        # legend and axis formatting
     
    17991815        ax.xaxis.set_major_locator(majloc)
    18001816        ax.xaxis.set_minor_locator(minloc)
    1801         self._plotter.legend(self._legendloc)
     1817        self._plotter.axes.legend(loc=self._legendloc)
    18021818
    18031819    def _plottp(self,scan):
     
    18361852        x = arange(len(y))
    18371853        # try to handle spectral data somewhat...
    1838         l,m = y.shape
     1854        try:
     1855            l,m = y.shape
     1856        except ValueError, e:
     1857                raise ValueError(str(e)+" This error usually occurs when you select multiple spws with different number of channels. Try selecting single spw and retry.")
    18391858        if m > 1:
    18401859            y=y.mean(axis=1)
Note: See TracChangeset for help on using the changeset viewer.