Changes in trunk/python/asapplotter.py [3038:2704]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r3038 r2704 112 112 self._plotter.legend(self._legendloc) 113 113 114 ### TODO: it's probably better to define following two methods in115 ### backend dependent class.116 114 def _new_custombar(self): 117 115 backend=matplotlib.get_backend() … … 132 130 return True 133 131 return False 134 ### end of TODO135 132 136 133 def _assert_plotter(self,action="status",errmsg=None): … … 279 276 280 277 281 ### Forwards to m ethods in matplotlib axes ###278 ### Forwards to matplotlib axes ### 282 279 def text(self, *args, **kwargs): 283 280 self._assert_plotter(action="reload") … … 418 415 del self._data 419 416 msg = "A new scantable is set to the plotter. "\ 420 "The masks , data selections, and labels are reset."421 asaplog.push( msg)417 "The masks and data selections are reset." 418 asaplog.push( msg ) 422 419 self._data = scan 423 420 # reset … … 517 514 self._rows = rows 518 515 self._cols = cols 519 # new layout is set. need to reset counters for multi page plotting520 self._reset_counters()521 516 if refresh and self._data: self.plot(self._data) 522 517 return … … 910 905 msg = "Can only set mask after a first call to plot()" 911 906 raise RuntimeError(msg) 912 if (mask is not None) andlen(mask):907 if len(mask): 913 908 if isinstance(mask, list) or isinstance(mask, tuple): 914 909 self._usermask = array(mask) … … 931 926 ### Reset methods ### 932 927 def _reset(self): 933 """Reset method called when new data is set""" 934 # reset selections and masks 928 self._usermask = [] 929 self._usermaskspectra = None 930 self._offset = None 935 931 self.set_selection(None, False) 936 self.set_mask(None, None, False)937 # reset offset938 self._offset = None939 # reset header940 932 self._reset_header() 941 # reset labels942 self._lmap = None # related to stack943 self.set_title(None, None, False)944 self.set_ordinate(None, None, False)945 self.set_abcissa(None, None, False)946 933 947 934 def _reset_header(self): … … 951 938 self._startrow = 0 952 939 self._ipanel = -1 940 self._reset_header() 953 941 self._panelrows = [] 954 self._reset_header()955 942 if self.casabar_exists(): 956 943 self._plotter.figmgr.casabar.set_pagecounter(1) … … 1044 1031 if self._panelling == 'i': 1045 1032 ganged = False 1046 if (not firstpage) and \ 1047 self._plotter._subplotsOk(self._rows, self._cols, n): 1048 # Not the first page and subplot number is ok. 1049 # Just clear the axis 1033 if not firstpage: 1034 # not the first page just clear the axis 1050 1035 nx = self._plotter.cols 1051 1036 ipaxx = n - nx - 1 #the max panel id to supress x-label … … 1317 1302 return start,end 1318 1303 1319 def _get_date_axis_setup(self, dates, axlim=None):1320 """1321 Returns proper axis title and formatters for a list of dates1322 Input1323 dates : a list of datetime objects returned by,1324 e.g. scantable.get_time(asdatetime=True)1325 axlim : a tuple of min and max day range in the plot axis.1326 if defined, the values are taken into account.1327 Output1328 a set of1329 * date axis title string1330 * formatter of date axis1331 * major axis locator1332 * minor axis locator1333 """1334 from matplotlib import pylab as PL1335 from matplotlib.dates import DateFormatter1336 from matplotlib.dates import HourLocator, MinuteLocator,SecondLocator, DayLocator, YearLocator, MonthLocator1337 t = PL.date2num(dates)1338 tmin = min(t)1339 tmax = max(t)1340 if axlim is not None:1341 tmin = min(tmin, min(axlim))1342 tmax = max(tmax, max(axlim))1343 tdel = tmax - tmin # interval in day1344 dstr = dates[0].strftime('%Y/%m/%d')1345 if tdel > 365.0: # >1year (also the case for single or very small time range)1346 majloc = YearLocator()1347 minloc = MonthLocator(range(1,12,6))1348 timefmt = DateFormatter('%Y/%m/%d')1349 elif tdel > 1.0: # >1day1350 dstr2 = dates[len(dates)-1].strftime('%Y/%m/%d')1351 dstr = dstr + " - " + dstr21352 majloc = DayLocator()1353 minloc = HourLocator(range(0,23,12))1354 timefmt = DateFormatter("%b%d")1355 elif tdel > 24./60.: # 9.6h - 1day1356 timefmt = DateFormatter('%H:%M')1357 majloc = HourLocator()1358 minloc = MinuteLocator(range(0,60,30))1359 elif tdel > 2./24.: # 2h-9.6h1360 timefmt = DateFormatter('%H:%M')1361 majloc = HourLocator()1362 minloc = MinuteLocator(range(0,60,10))1363 elif tdel> 10./24./60.: # 10min-2h1364 timefmt = DateFormatter('%H:%M')1365 majloc = MinuteLocator(range(0,60,10))1366 minloc = MinuteLocator()1367 else: # <10min1368 timefmt = DateFormatter('%H:%M')1369 majloc = MinuteLocator()1370 minloc = SecondLocator(30)1371 return (dstr, timefmt, majloc, minloc)1372 1373 1304 def plotazel(self, scan=None, outfile=None): 1374 1305 """ … … 1378 1309 visible = rcParams['plotter.gui'] 1379 1310 from matplotlib import pylab as PL 1311 from matplotlib.dates import DateFormatter 1380 1312 from pytz import timezone 1313 from matplotlib.dates import HourLocator, MinuteLocator,SecondLocator, DayLocator 1381 1314 from matplotlib.ticker import MultipleLocator 1382 from numpy import array, pi , ma1315 from numpy import array, pi 1383 1316 if self._plotter and (PL.gcf() == self._plotter.figure): 1384 1317 # the current figure is ASAP plotter. Use mpl plotter … … 1392 1325 self._data = scan 1393 1326 dates = self._data.get_time(asdatetime=True) 1394 # for flag handling1395 mask = [ self._data._is_all_chan_flagged(i) for i in range(self._data.nrow())]1396 1327 t = PL.date2num(dates) 1397 1328 tz = timezone('UTC') … … 1406 1337 wspace=wsp,hspace=hsp) 1407 1338 1408 tdel = max(t) - min(t) # interval in day1339 tdel = max(t) - min(t) 1409 1340 ax = PL.subplot(2,1,1) 1410 el = ma.masked_array(array(self._data.get_elevation())*180./pi, mask)1341 el = array(self._data.get_elevation())*180./pi 1411 1342 PL.ylabel('El [deg.]') 1412 (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(dates) 1413 1343 dstr = dates[0].strftime('%Y/%m/%d') 1344 if tdel > 1.0: 1345 dstr2 = dates[len(dates)-1].strftime('%Y/%m/%d') 1346 dstr = dstr + " - " + dstr2 1347 majloc = DayLocator() 1348 minloc = HourLocator(range(0,23,12)) 1349 timefmt = DateFormatter("%b%d") 1350 elif tdel > 24./60.: 1351 timefmt = DateFormatter('%H:%M') 1352 majloc = HourLocator() 1353 minloc = MinuteLocator(30) 1354 else: 1355 timefmt = DateFormatter('%H:%M') 1356 majloc = MinuteLocator(interval=5) 1357 minloc = SecondLocator(30) 1358 1414 1359 PL.title(dstr) 1415 1360 if tdel == 0.0: … … 1418 1363 else: 1419 1364 PL.plot_date(t,el,'o', markersize=2, markerfacecolor='b', markeredgecolor='b',tz=tz) 1420 #ax.xaxis.set_major_formatter(timefmt) 1421 #ax.xaxis.set_major_locator(majloc) 1422 #ax.xaxis.set_minor_locator(minloc) 1365 #ax.grid(True) 1366 ax.xaxis.set_major_formatter(timefmt) 1367 ax.xaxis.set_major_locator(majloc) 1368 ax.xaxis.set_minor_locator(minloc) 1423 1369 ax.yaxis.grid(True) 1370 yloc = MultipleLocator(30) 1424 1371 ax.set_ylim(0,90) 1425 #yloc = MultipleLocator(30) 1426 #ax.yaxis.set_major_locator(yloc) 1372 ax.yaxis.set_major_locator(yloc) 1427 1373 if tdel > 1.0: 1428 1374 labels = ax.get_xticklabels() … … 1431 1377 1432 1378 # Az plot 1433 az = ma.masked_array(array(self._data.get_azimuth())*180./pi, mask)1379 az = array(self._data.get_azimuth())*180./pi 1434 1380 if min(az) < 0: 1435 1381 for irow in range(len(az)): … … 1443 1389 else: 1444 1390 PL.plot_date(t,az,'o', markersize=2,markeredgecolor='b',markerfacecolor='b',tz=tz) 1445 #ax2.xaxis.set_major_formatter(timefmt) 1446 #ax2.xaxis.set_major_locator(majloc) 1447 #ax2.xaxis.set_minor_locator(minloc) 1391 ax2.xaxis.set_major_formatter(timefmt) 1392 ax2.xaxis.set_major_locator(majloc) 1393 ax2.xaxis.set_minor_locator(minloc) 1394 #ax2.grid(True) 1448 1395 ax2.set_ylim(0,360) 1449 1396 ax2.yaxis.grid(True) 1450 1397 #hfmt = DateFormatter('%H') 1451 1398 #hloc = HourLocator() 1452 #yloc = MultipleLocator(60)1453 #ax2.yaxis.set_major_locator(yloc)1399 yloc = MultipleLocator(60) 1400 ax2.yaxis.set_major_locator(yloc) 1454 1401 if tdel > 1.0: 1455 1402 labels = ax2.get_xticklabels() 1456 1403 PL.setp(labels, fontsize=10) 1457 # PL.xlabel('Time (UT [day])') 1458 #else: 1459 # PL.xlabel('Time (UT [hour])') 1460 PL.xlabel('Time (UT)') 1404 PL.xlabel('Time (UT [day])') 1405 else: 1406 PL.xlabel('Time (UT [hour])') 1461 1407 1462 1408 PL.ion() … … 1471 1417 plot telescope pointings 1472 1418 Parameters: 1473 scan : inputscantable instance1419 infile : input filename or scantable instance 1474 1420 colorby : change color by either 1475 1421 'type'(source type)|'scan'|'if'|'pol'|'beam' … … 1479 1425 """ 1480 1426 self._plotmode = "pointing" 1481 from numpy import array, pi , ma1427 from numpy import array, pi 1482 1428 from asap import scantable 1483 1429 # check for scantable … … 1555 1501 self._data.set_selection(basesel) 1556 1502 continue 1557 #print "Plotting direction of %s = %s" % (colorby, str(idx))1503 print "Plotting direction of %s = %s" % (colorby, str(idx)) 1558 1504 # getting data to plot 1559 1505 dir = array(self._data.get_directionval()).transpose() 1560 # for flag handling1561 mask = [ self._data._is_all_chan_flagged(i) for i in range(self._data.nrow())]1562 1506 ra = dir[0]*180./pi 1563 dec = ma.masked_array(dir[1]*180./pi, mask)1507 dec = dir[1]*180./pi 1564 1508 # actual plot 1565 1509 self._plotter.set_line(label=(sellab+str(idx))) … … 1587 1531 # reverse x-axis 1588 1532 xmin, xmax = self.gca().get_xlim() 1589 ymin, ymax = self.gca().get_ylim() 1590 # expand plotrange if xmin==xmax or ymin==ymax 1591 if abs(ymax-ymin) < 1.e-3: #~4arcsec 1592 delx = 0.5*abs(xmax - xmin) 1593 if delx < 5.e-4: 1594 dxy = 5.e-4 #~2arcsec 1595 (ymin, ymax) = (ymin-dxy, ymax+dxy) 1596 (xmin, xmax) = (xmin-dxy, xmax+dxy) 1597 (ymin, ymax) = (ymin-delx, ymax+delx) 1598 elif abs(xmax-xmin) < 1.e-3: 1599 dely = 0.5*abs(ymax - ymin) 1600 (xmin, xmax) = (xmin-dely, xmax+dely) 1601 self._plotter.set_limits(xlim=[xmax,xmin], ylim=[ymin, ymax]) 1533 self._plotter.set_limits(xlim=[xmax,xmin]) 1602 1534 1603 1535 self._plotter.release() … … 1655 1587 # plotting in time is not yet implemented.. 1656 1588 @asaplog_post_dec 1657 def plottp(self, scan=None, colorby=''): 1658 """ 1659 Plot averaged spectra (total power) in time or in row ID (colorby='') 1660 Parameters: 1661 scan : input scantable instance 1662 colorby : change color by either 1663 'type'(source type)|'scan'|'if'|'pol'|'beam'|'' 1664 """ 1589 def plottp(self, scan=None): 1665 1590 self._plotmode = "totalpower" 1666 1591 from asap import scantable … … 1693 1618 left=lef,bottom=bot,right=rig,top=top,wspace=wsp,hspace=hsp) 1694 1619 if self.casabar_exists(): self._plotter.figmgr.casabar.disable_button() 1695 if len(colorby) == 0: 1696 self._plottp(self._data) 1697 else: 1698 self._plottp_in_time(self._data,colorby) 1620 self._plottp(self._data) 1699 1621 if self._minmaxy is not None: 1700 1622 self._plotter.set_limits(ylim=self._minmaxy) … … 1703 1625 self._plotter.show(hardrefresh=False) 1704 1626 return 1705 1706 def _plottp_in_time(self,scan,colorby):1707 """1708 private method for plotting total power data in time1709 Parameters:1710 scan : input scantable instance1711 colorby : change color by either1712 'type'(source type)|'scan'|'if'|'pol'|'beam'1713 """1714 from numpy import ma, array, arange, logical_not1715 r=01716 nr = scan.nrow()1717 a0,b0 = -1,-11718 allxlim = []1719 allylim = []1720 y=[]1721 self._plotter.set_panels()1722 self._plotter.palette(0)1723 # check of overlay settings1724 time_types = ['type','scan'] # time dependent meta-data1725 misc_types = ['if','pol','beam'] # time independent meta-data1726 validtypes=time_types + misc_types1727 stype = None1728 col_msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes)1729 colorby = colorby.lower()1730 if (colorby in validtypes):1731 stype = colorby[0]1732 elif len(colorby) > 0:1733 raise ValueError(col_msg)1734 if not stype:1735 raise ValueError(col_msg)1736 # Selection and sort order1737 basesel = scan.get_selection()1738 if colorby in misc_types: misc_types.pop(misc_types.index(colorby))1739 sel_lbl = ""1740 for meta in misc_types:1741 idx = getattr(scan,'get'+meta+'nos')()1742 if len(idx) > 1: getattr(basesel, 'set_'+meta+'s')([idx[0]])1743 sel_lbl += ("%s%d, " % (meta.upper(), idx[0]))1744 sel_lbl = sel_lbl.rstrip(', ')1745 scan.set_selection(basesel)1746 if len(sel_lbl) > 0:1747 asaplog.push("Selection contains multiple IFs/Pols/Beams. Plotting the first ones: %s" % sel_lbl)1748 asaplog.post("WARN")1749 if stype == 't':1750 selIds = range(15)1751 sellab = "src type "1752 else:1753 selIds = getattr(scan,'get'+colorby+'nos')()1754 sellab = colorby.upper()1755 selFunc = "set_"+colorby+"s"1756 basesel.set_order(["TIME"])1757 # define axes labels1758 xlab = self._abcissa or 'Time (UTC)'1759 ylab = self._ordinate or scan._get_ordinate_label()1760 self._plotter.set_axes('xlabel',xlab)1761 self._plotter.set_axes('ylabel',ylab)1762 # define the panel title1763 if len(sel_lbl) > 0: lbl = sel_lbl1764 else: lbl = self._get_label(scan, r, 's', self._title)1765 if isinstance(lbl, list) or isinstance(lbl, tuple):1766 # get default label1767 lbl = self._get_label(scan, r, self._panelling, None)1768 self._plotter.set_axes('title',lbl)1769 # linestyle1770 lstyle = '' if colorby in time_types else ':'1771 alldates = []1772 for idx in selIds:1773 sel = selector() + basesel1774 bid = getattr(basesel,'get_'+colorby+"s")()1775 if (len(bid) > 0) and (not idx in bid):1776 # base selection doesn't contain idx1777 # Note summation of selector is logical sum if1778 continue1779 getattr(sel, selFunc)([idx])1780 if not sel.is_empty():1781 try:1782 scan.set_selection(sel)1783 except RuntimeError, instance:1784 if stype == 't' and str(instance).startswith("Selection contains no data."):1785 continue1786 else:1787 scan.set_selection(basesel)1788 raise RuntimeError, instance1789 if scan.nrow() == 0:1790 scan.set_selection(basesel)1791 continue1792 y=array(scan._get_column(scan._getspectrum,-1))1793 m = array(scan._get_column(scan._getmask,-1))1794 y = ma.masked_array(y,mask=logical_not(array(m,copy=False)))1795 # try to handle spectral data somewhat...1796 try:1797 l,m = y.shape1798 except ValueError, e:1799 raise ValueError(str(e)+" This error usually occurs when you select multiple spws with different number of channels. Try selecting single spw and retry.")1800 if m > 1:1801 y=y.mean(axis=1)1802 # flag handling1803 m = [ scan._is_all_chan_flagged(i) for i in range(scan.nrow()) ]1804 y = ma.masked_array(y,mask=m)1805 if len(y) == 0: continue1806 # line label1807 llbl=sellab+str(idx)1808 from matplotlib.dates import date2num1809 from pytz import timezone1810 dates = self._data.get_time(asdatetime=True)1811 alldates += list(dates)1812 x = date2num(dates)1813 tz = timezone('UTC')1814 # get color1815 lc = self._plotter.colormap[self._plotter.color]1816 self._plotter.palette( (self._plotter.color+1) % len(self._plotter.colormap) )1817 # actual plotting1818 self._plotter.axes.plot_date(x,y,tz=tz,label=llbl,linestyle=lstyle,color=lc,1819 marker='o',markersize=3,markeredgewidth=0)1820 1821 # legend and axis formatting1822 ax = self.gca()1823 (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(alldates, ax.get_xlim())1824 ax.xaxis.set_major_formatter(timefmt)1825 ax.xaxis.set_major_locator(majloc)1826 ax.xaxis.set_minor_locator(minloc)1827 self._plotter.axes.legend(loc=self._legendloc)1828 1627 1829 1628 def _plottp(self,scan): … … 1862 1661 x = arange(len(y)) 1863 1662 # try to handle spectral data somewhat... 1864 try: 1865 l,m = y.shape 1866 except ValueError, e: 1867 raise ValueError(str(e)+" This error usually occurs when you select multiple spws with different number of channels. Try selecting single spw and retry.") 1663 l,m = y.shape 1868 1664 if m > 1: 1869 1665 y=y.mean(axis=1) 1870 # flag handling1871 m = [ scan._is_all_chan_flagged(i) for i in range(scan.nrow()) ]1872 y = ma.masked_array(y,mask=m)1873 1666 plotit = self._plotter.plot 1874 1667 llbl = self._get_label(scan, r, self._stacking, None) … … 1908 1701 selstr += '\n' 1909 1702 self._headtext['selstr'] = selstr 1910 #ssel=(selstr+self._data.get_selection().__str__()+self._selection.__str__() or 'none') 1911 curr_selstr = selstr+self._data.get_selection().__str__() or "none" 1912 ssel=(curr_selstr+"\n" +self._selection.__str__()) 1913 headstr.append('\n\n***Selections***\n'+ssel.replace('$','\$')) 1703 ssel=(selstr+self._data.get_selection().__str__()+self._selection.__str__() or 'none') 1704 headstr.append('***Selections***\n'+ssel) 1914 1705 1915 1706 if plot: … … 1961 1752 # plot spectra by pointing 1962 1753 @asaplog_post_dec 1963 def plotgrid(self, scan=None,center= "",spacing=[],rows=None,cols=None):1754 def plotgrid(self, scan=None,center=None,spacing=None,rows=None,cols=None): 1964 1755 """ 1965 1756 Plot spectra based on direction. … … 1967 1758 Parameters: 1968 1759 scan: a scantable to plot 1969 center: the grid center direction (a string) 1760 center: the grid center direction (a list) of plots in the 1761 unit of DIRECTION column. 1970 1762 (default) the center of map region 1971 (example) 'J2000 19h30m00s -25d00m00s'1972 1763 spacing: a list of horizontal (R.A.) and vertical (Dec.) 1973 spacing .1764 spacing in the unit of DIRECTION column. 1974 1765 (default) Calculated by the extent of map region and 1975 (example) ['1arcmin', '1arcmin']1976 1766 the number of rows and cols to cover 1977 1767 rows: number of panels (grid points) in horizontal direction … … 1997 1787 1998 1788 # Rows and cols 1999 if (self._rows is None): 2000 rows = max(1, rows) 2001 if (self._cols is None): 2002 cols = max(1, cols) 2003 self.set_layout(rows,cols,False) 2004 2005 # Select the first IF, POL, and BEAM for plotting 1789 if rows: 1790 self._rows = int(rows) 1791 else: 1792 msg = "Number of rows to plot are not specified. " 1793 if self._rows: 1794 msg += "Using previous value = %d" % (self._rows) 1795 asaplog.push(msg) 1796 else: 1797 self._rows = 1 1798 msg += "Setting rows = %d" % (self._rows) 1799 asaplog.post() 1800 asaplog.push(msg) 1801 asaplog.post("WARN") 1802 if cols: 1803 self._cols = int(cols) 1804 else: 1805 msg = "Number of cols to plot are not specified. " 1806 if self._cols: 1807 msg += "Using previous value = %d" % (self._cols) 1808 asaplog.push(msg) 1809 else: 1810 self._cols = 1 1811 msg += "Setting cols = %d" % (self._cols) 1812 asaplog.post() 1813 asaplog.push(msg) 1814 asaplog.post("WARN") 1815 1816 # Center and spacing 1817 dirarr = array(self._data.get_directionval()).transpose() 1818 print "Pointing range: (x, y) = (%f - %f, %f - %f)" %\ 1819 (dirarr[0].min(),dirarr[0].max(),dirarr[1].min(),dirarr[1].max()) 1820 dircent = [0.5*(dirarr[0].max() + dirarr[0].min()), 1821 0.5*(dirarr[1].max() + dirarr[1].min())] 1822 del dirarr 1823 if center is None: 1824 #asaplog.post() 1825 asaplog.push("Grid center is not specified. Automatically calculated from pointing center.") 1826 #asaplog.post("WARN") 1827 #center = [dirarr[0].mean(), dirarr[1].mean()] 1828 center = dircent 1829 elif (type(center) in (list, tuple)) and len(center) > 1: 1830 from numpy import pi 1831 # make sure center_x is in +-pi of pointing center 1832 # (assumes dirs are in rad) 1833 rotnum = round(abs(center[0] - dircent[0])/(2*pi)) 1834 if center[0] < dircent[0]: rotnum *= -1 1835 cenx = center[0] - rotnum*2*pi 1836 center = [cenx, center[1]] 1837 else: 1838 msg = "Direction of grid center should be a list of float (R.A., Dec.)" 1839 raise ValueError, msg 1840 asaplog.push("Grid center: (%f, %f) " % (center[0],center[1])) 1841 1842 if spacing is None: 1843 #asaplog.post() 1844 asaplog.push("Grid spacing not specified. Automatically calculated from map coverage") 1845 #asaplog.post("WARN") 1846 # automatically get spacing 1847 dirarr = array(self._data.get_directionval()).transpose() 1848 wx = 2. * max(abs(dirarr[0].max()-center[0]), 1849 abs(dirarr[0].min()-center[0])) 1850 wy = 2. * max(abs(dirarr[1].max()-center[1]), 1851 abs(dirarr[1].min()-center[1])) 1852 ## slightly expand area to plot the edges 1853 #wx *= 1.1 1854 #wy *= 1.1 1855 xgrid = wx/max(self._cols-1.,1.) 1856 #xgrid = wx/float(max(self._cols,1.)) 1857 xgrid *= cos(center[1]) 1858 ygrid = wy/max(self._rows-1.,1.) 1859 #ygrid = wy/float(max(self._rows,1.)) 1860 # single pointing (identical R.A. and/or Dec. for all spectra.) 1861 if xgrid == 0: 1862 xgrid = 1. 1863 if ygrid == 0: 1864 ygrid = 1. 1865 # spacing should be negative to transpose plot 1866 spacing = [- xgrid, - ygrid] 1867 del dirarr, xgrid, ygrid 1868 #elif isinstance(spacing, str): 1869 # # spacing is a quantity 1870 elif (type(spacing) in (list, tuple)) and len(spacing) > 1: 1871 for i in xrange(2): 1872 val = spacing[i] 1873 if not isinstance(val, float): 1874 raise TypeError("spacing should be a list of float") 1875 if val > 0.: 1876 spacing[i] = -val 1877 spacing = spacing[0:2] 1878 else: 1879 msg = "Invalid spacing." 1880 raise TypeError(msg) 1881 asaplog.push("Spacing: (%f, %f) (projected)" % (spacing[0],spacing[1])) 1882 2006 1883 ntotpl = self._rows * self._cols 2007 1884 ifs = self._data.getifnos() … … 2030 1907 asaplog.push(msg) 2031 1908 asaplog.post("WARN") 2032 2033 # Prepare plotter 1909 2034 1910 self._assert_plotter(action="reload") 2035 1911 self._plotter.hold() … … 2047 1923 from asap._asap import plothelper as plhelper 2048 1924 ph = plhelper(self._data) 2049 #ph.set_gridval(self._cols, self._rows, spacing[0], spacing[1], 2050 # center[0], center[1], epoch="J2000", projname="SIN") 2051 if type(spacing) in (list, tuple, array): 2052 if len(spacing) == 0: 2053 spacing = ["", ""] 2054 elif len(spacing) == 1: 2055 spacing = [spacing[0], spacing[0]] 2056 else: 2057 spacing = [spacing, spacing] 2058 ph.set_grid(self._cols, self._rows, spacing[0], spacing[1], \ 2059 center, projname="SIN") 2060 1925 ph.set_gridval(self._cols, self._rows, spacing[0], spacing[1], 1926 center[0], center[1], epoch="J2000", projname="SIN") 2061 1927 # Actual plot 2062 1928 npl = 0
Note:
See TracChangeset
for help on using the changeset viewer.