- Timestamp:
- 09/24/14 16:15:21 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r2991 r2992 1711 1711 self._plotter.set_panels() 1712 1712 self._plotter.palette(0) 1713 #title1714 #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 label1728 lbl = self._get_label(scan, r, self._panelling, None)1729 self._plotter.set_axes('title',lbl)1730 1713 # 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 1732 1717 stype = None 1733 1718 col_msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes) 1719 colorby = colorby.lower() 1734 1720 if (colorby in validtypes): 1735 1721 stype = colorby[0] … … 1738 1724 if not stype: 1739 1725 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': 1741 1740 selIds = range(15) 1742 1741 sellab = "src type " … … 1745 1744 sellab = colorby.upper() 1746 1745 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 ':' 1749 1761 alldates = [] 1750 1762 for idx in selIds: … … 1775 1787 l,m = y.shape 1776 1788 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 channelsand 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.") 1778 1790 if m > 1: 1779 1791 y=y.mean(axis=1) … … 1782 1794 y = ma.masked_array(y,mask=m) 1783 1795 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) 1787 1798 from matplotlib.dates import date2num 1788 1799 from pytz import timezone … … 1791 1802 x = date2num(dates) 1792 1803 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) 1794 1810 1795 1811 # legend and axis formatting … … 1799 1815 ax.xaxis.set_major_locator(majloc) 1800 1816 ax.xaxis.set_minor_locator(minloc) 1801 self._plotter. legend(self._legendloc)1817 self._plotter.axes.legend(loc=self._legendloc) 1802 1818 1803 1819 def _plottp(self,scan): … … 1836 1852 x = arange(len(y)) 1837 1853 # 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.") 1839 1858 if m > 1: 1840 1859 y=y.mean(axis=1)
Note:
See TracChangeset
for help on using the changeset viewer.