Changeset 1446 for branches/alma/python/asapplotter.py
- Timestamp:
- 11/12/08 17:04:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asapplotter.py
r1389 r1446 605 605 if n > 1: 606 606 ganged = rcParams['plotter.ganged'] 607 ###Start Mod: 2008.09.22 kana ### 608 if self._panelling == 'i': 609 ganged = False 610 ###End Mod####################### 607 611 if self._rows and self._cols: 608 612 n = min(n,self._rows*self._cols) … … 688 692 if stackcount == nstack: 689 693 allxlim.sort() 690 self._plotter.axes.set_xlim([allxlim[0],allxlim[-1]]) 694 ###Start Mod: 2008.09.22 kana ### 695 #self._plotter.axes.set_xlim([allxlim[0],allxlim[-1]]) 696 self._plotter.subplots[panelcount-1]['axes'].set_xlim([allxlim[0],allxlim[-1]]) 697 ###End Mod####################### 691 698 # clear 692 699 allxlim =[] … … 741 748 return userlabel or d[mode] 742 749 743 def plotazel(self, scan=None ):750 def plotazel(self, scan=None, outfile=None): 744 751 """ 745 752 plot azimuth and elevation versus time of a scantable … … 750 757 from matplotlib.numerix import array, pi 751 758 self._data = scan 759 self._outfile = outfile 752 760 dates = self._data.get_time() 753 761 t = PL.date2num(dates) 754 762 tz = timezone('UTC') 755 763 PL.cla() 756 PL.ioff()764 #PL.ioff() 757 765 PL.clf() 758 766 tdel = max(t) - min(t) … … 772 780 minloc = MinuteLocator(20) 773 781 PL.title(dstr) 774 PL.plot_date(t,el,'b,', tz=tz) 775 #ax.grid(True) 782 783 if tdel == 0.0: 784 th = (t - PL.floor(t))*24.0 785 PL.plot(th,el,'o',markersize=2, markerfacecolor='b', markeredgecolor='b') 786 else: 787 PL.plot_date(t,el,'o', markersize=2, markerfacecolor='b', markeredgecolor='b',tz=tz) 788 #ax.grid(True) 789 ax.xaxis.set_major_formatter(timefmt) 790 ax.xaxis.set_major_locator(majloc) 791 ax.xaxis.set_minor_locator(minloc) 776 792 ax.yaxis.grid(True) 777 793 yloc = MultipleLocator(30) 778 794 ax.set_ylim(0,90) 779 ax.xaxis.set_major_formatter(timefmt)780 ax.xaxis.set_major_locator(majloc)781 ax.xaxis.set_minor_locator(minloc)782 795 ax.yaxis.set_major_locator(yloc) 783 796 if tdel > 1.0: … … 785 798 # PL.setp(labels, fontsize=10, rotation=45) 786 799 PL.setp(labels, fontsize=10) 800 787 801 # Az plot 788 802 az = array(self._data.get_azimuth())*180./pi … … 792 806 793 807 ax = PL.subplot(2,1,2) 794 PL.xlabel('Time (UT)')808 #PL.xlabel('Time (UT [hour])') 795 809 PL.ylabel('Az [deg.]') 796 PL.plot_date(t,az,'b,', tz=tz) 810 if tdel == 0.0: 811 PL.plot(th,az,'o',markersize=2, markeredgecolor='b',markerfacecolor='b') 812 else: 813 PL.plot_date(t,az,'o', markersize=2,markeredgecolor='b',markerfacecolor='b',tz=tz) 814 ax.xaxis.set_major_formatter(timefmt) 815 ax.xaxis.set_major_locator(majloc) 816 ax.xaxis.set_minor_locator(minloc) 817 #ax.grid(True) 797 818 ax.set_ylim(0,360) 798 #ax.grid(True)799 819 ax.yaxis.grid(True) 800 820 #hfmt = DateFormatter('%H') 801 821 #hloc = HourLocator() 802 822 yloc = MultipleLocator(60) 803 ax.xaxis.set_major_formatter(timefmt)804 ax.xaxis.set_major_locator(majloc)805 ax.xaxis.set_minor_locator(minloc)806 823 ax.yaxis.set_major_locator(yloc) 807 824 if tdel > 1.0: 808 825 labels = ax.get_xticklabels() 809 826 PL.setp(labels, fontsize=10) 810 PL.ion() 827 PL.xlabel('Time (UT [day])') 828 else: 829 PL.xlabel('Time (UT [hour])') 830 831 #PL.ion() 811 832 PL.draw() 812 813 def plotpointing(self, scan=None): 833 if (self._outfile is not None): 834 PL.savefig(self._outfile) 835 836 def plotpointing(self, scan=None, outfile=None): 814 837 """ 815 838 plot telescope pointings … … 820 843 from matplotlib.numerix import array, pi, zeros 821 844 self._data = scan 845 self._outfile = outfile 822 846 dir = array(self._data.get_directionval()).transpose() 823 847 ra = dir[0]*180./pi 824 848 dec = dir[1]*180./pi 825 849 PL.cla() 826 PL.ioff()850 #PL.ioff() 827 851 PL.clf() 828 852 ax = PL.axes([0.1,0.1,0.8,0.8]) … … 835 859 [xmin,xmax,ymin,ymax] = PL.axis() 836 860 PL.axis([xmax,xmin,ymin,ymax]) 837 PL.ion()861 #PL.ion() 838 862 PL.draw() 839 863 if (self._outfile is not None): 864 PL.savefig(self._outfile) 865 866 # plot total power data 867 # plotting in time is not yet implemented.. 868 def plottp(self, scan=None, outfile=None): 869 if self._plotter.is_dead: 870 self._plotter = self._newplotter() 871 self._plotter.hold() 872 self._plotter.clear() 873 from asap import scantable 874 if not self._data and not scan: 875 msg = "Input is not a scantable" 876 if rcParams['verbose']: 877 print msg 878 return 879 raise TypeError(msg) 880 if isinstance(scan, scantable): 881 if self._data is not None: 882 if scan != self._data: 883 self._data = scan 884 # reset 885 self._reset() 886 else: 887 self._data = scan 888 self._reset() 889 # ranges become invalid when abcissa changes? 890 #if self._abcunit and self._abcunit != self._data.get_unit(): 891 # self._minmaxx = None 892 # self._minmaxy = None 893 # self._abcunit = self._data.get_unit() 894 # self._datamask = None 895 self._plottp(self._data) 896 if self._minmaxy is not None: 897 self._plotter.set_limits(ylim=self._minmaxy) 898 self._plotter.release() 899 self._plotter.tidy() 900 self._plotter.show(hardrefresh=False) 901 print_log() 902 return 903 904 def _plottp(self,scan): 905 """ 906 private method for plotting total power data 907 """ 908 from matplotlib.numerix import ma, array, arange, logical_not 909 r=0 910 nr = scan.nrow() 911 a0,b0 = -1,-1 912 allxlim = [] 913 allylim = [] 914 y=[] 915 self._plotter.set_panels() 916 self._plotter.palette(0) 917 #title 918 #xlab = self._abcissa and self._abcissa[panelcount] \ 919 # or scan._getabcissalabel() 920 #ylab = self._ordinate and self._ordinate[panelcount] \ 921 # or scan._get_ordinate_label() 922 xlab = self._abcissa or 'row number' #or Time 923 ylab = self._ordinate or scan._get_ordinate_label() 924 self._plotter.set_axes('xlabel',xlab) 925 self._plotter.set_axes('ylabel',ylab) 926 lbl = self._get_label(scan, r, 's', self._title) 927 if isinstance(lbl, list) or isinstance(lbl, tuple): 928 # if 0 <= panelcount < len(lbl): 929 # lbl = lbl[panelcount] 930 # else: 931 # get default label 932 lbl = self._get_label(scan, r, self._panelling, None) 933 self._plotter.set_axes('title',lbl) 934 y=array(scan._get_column(scan._getspectrum,-1)) 935 m = array(scan._get_column(scan._getmask,-1)) 936 y = ma.masked_array(y,mask=logical_not(array(m,copy=False))) 937 x = arange(len(y)) 938 # try to handle spectral data somewhat... 939 l,m = y.shape 940 if m > 1: 941 y=y.mean(axis=1) 942 plotit = self._plotter.plot 943 llbl = self._get_label(scan, r, self._stacking, None) 944 self._plotter.set_line(label=llbl) 945 if len(x) > 0: 946 plotit(x,y) 947 948 949 # forwards to matplotlib.Figure.text 950 def figtext(self, *args, **kwargs): 951 """ 952 Add text to figure at location x,y (relative 0-1 coords). 953 This method forwards *args and **kwargs to a Matplotlib method, 954 matplotlib.Figure.text. 955 See the method help for detailed information. 956 """ 957 self._plotter.text(*args, **kwargs) 958 # end matplotlib.Figure.text forwarding function 959
Note: See TracChangeset
for help on using the changeset viewer.