Changeset 2051


Ignore:
Timestamp:
03/17/11 17:52:18 (13 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-2764, ATNF-238)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: interactive test is necessary.

plot single dish spectra by sdplot + header=True or asapplotter.plot+asapplotter.print_header, and move between pages.
Check if you see header strings plotted in the same size and position in every page.

Put in Release Notes: No

Module(s): asapplotter, sdplot

Description: fixed a bug in asapplotter. asapplotter now prints header strings in every page.


Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2038 r2051  
    5555        self._ipanel = -1
    5656        self._panelrows = []
     57        self._headstring = None
     58        self._headsize = None
    5759
    5860    def _translate(self, instr):
     
    842844        self._offset = None
    843845        self.set_selection(None, False)
     846        self._reset_header()
     847
     848    def _reset_header(self):
     849        self._headsize = None
     850        self._headstring = None
    844851
    845852    def _plot(self, scan):
     
    13771384    # printing header information
    13781385    @asaplog_post_dec
    1379     def print_header(self, plot=True, fontsize=9, logger=False, selstr='', extrastr=''):
     1386    def print_header(self, plot=True, fontsize=None, logger=False, selstr='', extrastr=''):
    13801387        """
    13811388        print data (scantable) header on the plot and/or logger.
    13821389        Parameters:
    13831390            plot:      whether or not print header info on the plot.
    1384             fontsize:  header font size (valid only plot=True)
     1391            fontsize:  header font size (valid only plot=True) default: 9
    13851392            logger:    whether or not print header info on the logger.
    13861393            selstr:    additional selection string (not verified)
     
    13951402        ssum=self._data.__str__()
    13961403        # Print Observation header to the upper-left corner of plot
    1397         if plot:
     1404        if self._headstring:
     1405            headstr = self._headstring
     1406            if extrastr != '': headstr[0]=extrastr+'\n'+headstr[0]
     1407            if selstr != '': headstr[2] += selstr
     1408            fontsize = fontsize or self._headsize
     1409        else:
    13981410            headstr=[ssum[ssum.find('Observer:'):ssum.find('Flux Unit:')]]
    13991411            headstr.append(ssum[ssum.find('Beams:'):ssum.find('Observer:')]
    1400                          +ssum[ssum.find('Rest Freqs:'):ssum.find('Abcissa:')])
     1412                           +ssum[ssum.find('Rest Freqs:'):ssum.find('Abcissa:')])
    14011413            if extrastr != '': headstr[0]=extrastr+'\n'+headstr[0]
    1402             #headstr[1]='Data File:     '+(filestr or 'unknown')+'\n'+headstr[1]
    14031414            ssel='***Selections***\n'+(selstr+self._data.get_selection().__str__() or 'none')
    14041415            headstr.append(ssel)
     1416            del ssel
     1417        fontsize = fontsize or 9
     1418        self._headsize = fontsize
     1419        self._headstring = headstr
     1420
     1421        if plot:
     1422            self._plotter.hold()
    14051423            nstcol=len(headstr)
    1406 
    1407             self._plotter.hold()
    14081424            for i in range(nstcol):
    14091425                self._plotter.figure.text(0.03+float(i)/nstcol,0.98,
     
    14181434                            verticalalignment='bottom',fontsize=8)
    14191435            self._plotter.release()
    1420             del headstr, ssel
    14211436        if logger:
     1437            sextra = headstr[0][0:headstr[0].find('Observer:')].rstrip('\n')
     1438            selstr = "Selections:    "+(headstr[2].lstrip('***Selections***\n') or 'none')+"\n \n"
     1439               
    14221440            asaplog.push("----------------\n  Plot Summary\n----------------")
    1423             asaplog.push(extrastr)
    1424             asaplog.push(ssum[ssum.find('Beams:'):])
    1425         del ssum
     1441            asaplog.push(sextra)
     1442            asaplog.push(ssum[ssum.find('Beams:'):ssum.find('Selection:')]\
     1443                         + selstr + ssum[ssum.find('Scan Source'):])
     1444        del ssum, headstr
     1445
     1446#     def clear_header(self):
     1447#         if not self._headstring or len(self._plotter.figure.texts) == 0:
     1448#             asaplog.push("No header has been plotted. Exit without any operation")
     1449#             asaplog.post("WARN")
     1450#         else:
     1451#             self._plotter.hold()
     1452#             for textobj in self._plotter.figure.texts:
     1453#                 if textobj.get_text() in self._headstring:
     1454#                     try:
     1455#                         textobj.remove()
     1456#                     except NotImplementedError:
     1457#                         self._plotter.figure.texts.pop(self._plotter.figure.texts.index(textobj))
     1458#             self._plotter.release()
     1459#         self._reset_header()
  • trunk/python/casatoolbar.py

    r1983 r2051  
    181181    ### actual plotting of the new page
    182182    def _new_page(self,goback=False):
     183        top = None
    183184        if self.plotter._startrow <= 0:
    184185            msg = "The page counter is reset due to chages of plot settings. "
     
    187188            asaplog.post('WARN')
    188189            goback = False
    189            
     190        else:
     191            top = self.plotter._plotter.figure.subplotpars.top
     192
    190193        self.plotter._plotter.hold()
    191194        if goback:
     
    196199        self.plotter._plotter.release()
    197200        self.plotter._plotter.tidy()
     201        if self.plotter._headstring:
     202            if top and top != self.plotter._margins[3]:
     203                # work around for sdplot in CASA. complete checking in future?
     204                self.plotter._plotter.figure.subplots_adjust(top=top)
     205            self.plotter.print_header()
    198206        self.plotter._plotter.show(hardrefresh=False)
     207        del top
    199208
    200209    ### calculate the panel ID and start row to plot the previous page
Note: See TracChangeset for help on using the changeset viewer.