Changeset 2988 for trunk


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

New Development: No

JIRA Issue: Yes (CAS-6704)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: added a private method, asapplotter._get_date_axis_setup()

Test Programs: invoke sdplot with plottype="azel" or asapplotter.plotazel

Put in Release Notes: No

Module(s): sdplot/asapplotter

Description: A minor reorganization of date formatting.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2977 r2988  
    13171317            return start,end
    13181318
    1319     def plotazel(self, scan=None, outfile=None):
    1320         """
    1321         plot azimuth and elevation versus time of a scantable
    1322         """
    1323         self._plotmode = "azel"
    1324         visible = rcParams['plotter.gui']
     1319    def _get_date_axis_setup(self, dates):
     1320        """
     1321        Returns proper axis title and formatters for a list of dates
     1322        Input
     1323            dates : a list of datetime objects returned by,
     1324                    e.g. scantable.get_time(asdatetime=True)
     1325        Output
     1326            a set of
     1327            * date axis title string
     1328            * formatter of date axis
     1329            * major axis locator
     1330            * minor axis locator
     1331        """
    13251332        from matplotlib import pylab as PL
    13261333        from matplotlib.dates import DateFormatter
    1327         from pytz import timezone
    13281334        from matplotlib.dates import HourLocator, MinuteLocator,SecondLocator, DayLocator
    1329         from matplotlib.ticker import MultipleLocator
    1330         from numpy import array, pi, ma
    1331         if self._plotter and (PL.gcf() == self._plotter.figure):
    1332             # the current figure is ASAP plotter. Use mpl plotter
    1333             figids = PL.get_fignums()
    1334             PL.figure(max(figids[-1],1))
    1335 
    1336         if not visible or not self._visible:
    1337             PL.ioff()
    1338             from matplotlib.backends.backend_agg import FigureCanvasAgg
    1339             PL.gcf().canvas.switch_backends(FigureCanvasAgg)
    1340         self._data = scan
    1341         dates = self._data.get_time(asdatetime=True)
    1342         # for flag handling
    1343         mask = [ self._data._is_all_chan_flagged(i) for i in range(self._data.nrow())]
    13441335        t = PL.date2num(dates)
    1345         tz = timezone('UTC')
    1346         PL.cla()
    1347         PL.ioff()
    1348         PL.clf()
    1349         # Adjust subplot margins
    1350         if not self._margins or len(self._margins) != 6:
    1351             self.set_margin(refresh=False)
    1352         lef, bot, rig, top, wsp, hsp = self._margins
    1353         PL.gcf().subplots_adjust(left=lef,bottom=bot,right=rig,top=top,
    1354                                  wspace=wsp,hspace=hsp)
    1355 
    13561336        tdel = max(t) - min(t) # interval in day
    1357         ax = PL.subplot(2,1,1)
    1358         el = ma.masked_array(array(self._data.get_elevation())*180./pi, mask)
    1359         PL.ylabel('El [deg.]')
    13601337        dstr = dates[0].strftime('%Y/%m/%d')
    13611338        if tdel > 1.0: # >1day
     
    13811358            majloc = MinuteLocator()
    13821359            minloc = SecondLocator(30)
    1383 
     1360        return (dstr, timefmt, majloc, minloc)
     1361
     1362    def plotazel(self, scan=None, outfile=None):
     1363        """
     1364        plot azimuth and elevation versus time of a scantable
     1365        """
     1366        self._plotmode = "azel"
     1367        visible = rcParams['plotter.gui']
     1368        from matplotlib import pylab as PL
     1369        from pytz import timezone
     1370        from matplotlib.ticker import MultipleLocator
     1371        from numpy import array, pi, ma
     1372        if self._plotter and (PL.gcf() == self._plotter.figure):
     1373            # the current figure is ASAP plotter. Use mpl plotter
     1374            figids = PL.get_fignums()
     1375            PL.figure(max(figids[-1],1))
     1376
     1377        if not visible or not self._visible:
     1378            PL.ioff()
     1379            from matplotlib.backends.backend_agg import FigureCanvasAgg
     1380            PL.gcf().canvas.switch_backends(FigureCanvasAgg)
     1381        self._data = scan
     1382        dates = self._data.get_time(asdatetime=True)
     1383        # for flag handling
     1384        mask = [ self._data._is_all_chan_flagged(i) for i in range(self._data.nrow())]
     1385        t = PL.date2num(dates)
     1386        tz = timezone('UTC')
     1387        PL.cla()
     1388        PL.ioff()
     1389        PL.clf()
     1390        # Adjust subplot margins
     1391        if not self._margins or len(self._margins) != 6:
     1392            self.set_margin(refresh=False)
     1393        lef, bot, rig, top, wsp, hsp = self._margins
     1394        PL.gcf().subplots_adjust(left=lef,bottom=bot,right=rig,top=top,
     1395                                 wspace=wsp,hspace=hsp)
     1396
     1397        tdel = max(t) - min(t) # interval in day
     1398        ax = PL.subplot(2,1,1)
     1399        el = ma.masked_array(array(self._data.get_elevation())*180./pi, mask)
     1400        PL.ylabel('El [deg.]')
     1401        (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(dates)
     1402       
    13841403        PL.title(dstr)
    13851404        if tdel == 0.0:
Note: See TracChangeset for help on using the changeset viewer.