Changeset 2991
- Timestamp:
- 09/12/14 21:31:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r2990 r2991 1686 1686 self._plottp(self._data) 1687 1687 else: 1688 self._plottp 2(self._data,colorby)1688 self._plottp_in_time(self._data,colorby) 1689 1689 if self._minmaxy is not None: 1690 1690 self._plotter.set_limits(ylim=self._minmaxy) … … 1694 1694 return 1695 1695 1696 def _plottp 2(self,scan,colorby):1696 def _plottp_in_time(self,scan,colorby): 1697 1697 """ 1698 1698 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' 1699 1703 """ 1700 1704 from numpy import ma, array, arange, logical_not … … 1712 1716 #ylab = self._ordinate and self._ordinate[panelcount] \ 1713 1717 # 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)' 1716 1719 ylab = self._ordinate or scan._get_ordinate_label() 1717 1720 self._plotter.set_axes('xlabel',xlab) … … 1728 1731 validtypes=['type','scan','if','pol', 'beam'] 1729 1732 stype = None 1733 col_msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes) 1730 1734 if (colorby in validtypes): 1731 1735 stype = colorby[0] 1732 1736 elif len(colorby) > 0: 1733 msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes) 1734 raise ValueError(msg) 1737 raise ValueError(col_msg) 1735 1738 if not stype: 1736 selIds = [""] # cheating 1737 sellab = "all points" 1739 raise ValueError(col_msg) 1738 1740 elif stype == 't': 1739 1741 selIds = range(15) … … 1748 1750 for idx in selIds: 1749 1751 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]) 1757 1758 if not sel.is_empty(): 1758 1759 try: … … 1771 1772 y = ma.masked_array(y,mask=logical_not(array(m,copy=False))) 1772 1773 # 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.") 1774 1778 if m > 1: 1775 1779 y=y.mean(axis=1) … … 1781 1785 #self._plotter.set_line(label=llbl) 1782 1786 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 1794 1795 # 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) 1803 1802 1804 1803 def _plottp(self,scan):
Note:
See TracChangeset
for help on using the changeset viewer.