Changeset 2054 for branches/casa-prerelease/pre-asap/python
- Timestamp:
- 03/18/11 16:02:54 (14 years ago)
- Location:
- branches/casa-prerelease/pre-asap/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/casa-prerelease/pre-asap/python/asapplotter.py
r2052 r2054 55 55 self._ipanel = -1 56 56 self._panelrows = [] 57 self._headstring = None 58 self._headsize = None 57 self._headtext={'string': None, 'textobj': None} 59 58 60 59 def _translate(self, instr): … … 847 846 848 847 def _reset_header(self): 849 self._headsize = None 850 self._headstring = None 848 self._headtext={'string': None, 'textobj': None} 851 849 852 850 def _plot(self, scan): … … 1384 1382 # printing header information 1385 1383 @asaplog_post_dec 1386 def print_header(self, plot=True, fontsize= None, logger=False, selstr='', extrastr=''):1384 def print_header(self, plot=True, fontsize=9, logger=False, selstr='', extrastr=''): 1387 1385 """ 1388 1386 print data (scantable) header on the plot and/or logger. 1389 1387 Parameters: 1390 1388 plot: whether or not print header info on the plot. 1391 fontsize: header font size (valid only plot=True) default: 91389 fontsize: header font size (valid only plot=True) 1392 1390 logger: whether or not print header info on the logger. 1393 1391 selstr: additional selection string (not verified) 1394 extrastr: additional string to print (not verified)1392 extrastr: additional string to print at the beginning (not verified) 1395 1393 """ 1396 1394 if not plot and not logger: … … 1402 1400 ssum=self._data.__str__() 1403 1401 # Print Observation header to the upper-left corner of 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: 1410 headstr=[ssum[ssum.find('Observer:'):ssum.find('Flux Unit:')]] 1411 headstr.append(ssum[ssum.find('Beams:'):ssum.find('Observer:')] 1412 +ssum[ssum.find('Rest Freqs:'):ssum.find('Abcissa:')]) 1413 if extrastr != '': headstr[0]=extrastr+'\n'+headstr[0] 1414 ssel='***Selections***\n'+(selstr+self._data.get_selection().__str__() or 'none') 1415 headstr.append(ssel) 1416 del ssel 1417 fontsize = fontsize or 9 1418 self._headsize = fontsize 1419 self._headstring = headstr 1402 headstr=[ssum[ssum.find('Observer:'):ssum.find('Flux Unit:')]] 1403 headstr.append(ssum[ssum.find('Beams:'):ssum.find('Observer:')] 1404 +ssum[ssum.find('Rest Freqs:'):ssum.find('Abcissa:')]) 1405 if extrastr != '': 1406 headstr[0]=extrastr+'\n'+headstr[0] 1407 self._headtext['extrastr'] = extrastr 1408 if selstr != '': self._headtext['selstr'] = selstr 1409 ssel=(selstr+self._data.get_selection().__str__() or 'none') 1410 headstr.append('***Selections***\n'+ssel) 1420 1411 1421 1412 if plot: 1422 1413 self._plotter.hold() 1423 nstcol=len(headstr) 1424 for i in range(nstcol): 1425 self._plotter.figure.text(0.03+float(i)/nstcol,0.98, 1426 headstr[i], 1427 horizontalalignment='left', 1428 verticalalignment='top', 1429 fontsize=fontsize) 1414 self._header_plot(headstr,fontsize=fontsize) 1430 1415 import time 1431 1416 self._plotter.figure.text(0.99,0.0, … … 1435 1420 self._plotter.release() 1436 1421 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 1422 selstr = "Selections: "+ssel 1440 1423 asaplog.push("----------------\n Plot Summary\n----------------") 1441 asaplog.push( sextra)1424 asaplog.push(extrastr) 1442 1425 asaplog.push(ssum[ssum.find('Beams:'):ssum.find('Selection:')]\ 1443 1426 + 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() 1427 self._headtext['string'] = headstr 1428 del ssel, ssum, headstr 1429 1430 def _header_plot(self, texts, fontsize=9): 1431 self._headtext['textobj']=[] 1432 nstcol=len(texts) 1433 for i in range(nstcol): 1434 self._headtext['textobj'].append( 1435 self._plotter.figure.text(0.03+float(i)/nstcol,0.98, 1436 texts[i], 1437 horizontalalignment='left', 1438 verticalalignment='top', 1439 fontsize=fontsize)) 1440 1441 def clear_header(self): 1442 if not self._headtext['textobj']: 1443 asaplog.push("No header has been plotted. Exit without any operation") 1444 asaplog.post("WARN") 1445 else: 1446 self._plotter.hold() 1447 for textobj in self._headtext['textobj']: 1448 #if textobj.get_text() in self._headstring: 1449 try: 1450 textobj.remove() 1451 except NotImplementedError: 1452 self._plotter.figure.texts.pop(self._plotter.figure.texts.index(textobj)) 1453 self._plotter.release() 1454 self._reset_header() -
branches/casa-prerelease/pre-asap/python/casatoolbar.py
r2052 r2054 182 182 def _new_page(self,goback=False): 183 183 top = None 184 header = self.plotter._headtext 185 reset = False 186 doheader = (isinstance(header['textobj'],list) and \ 187 len(header['textobj']) > 0) 184 188 if self.plotter._startrow <= 0: 185 189 msg = "The page counter is reset due to chages of plot settings. " … … 187 191 asaplog.push(msg) 188 192 asaplog.post('WARN') 193 reset = True 189 194 goback = False 190 else: 195 if doheader: 196 extrastr = selstr = '' 197 if header.has_key('extrastr'): 198 extrastr = header['extrastr'] 199 if header.has_key('selstr'): 200 selstr = header['selstr'] 201 self.plotter._reset_header() 202 if doheader: 191 203 top = self.plotter._plotter.figure.subplotpars.top 204 fontsize = header['textobj'][0].get_fontproperties().get_size() 192 205 193 206 self.plotter._plotter.hold() … … 197 210 self.plotter._plot(self.plotter._data) 198 211 self.set_pagecounter(self._get_pagenum()) 199 self.plotter._plotter.release() 200 self.plotter._plotter.tidy() 201 if self.plotter._headstring: 212 # Plot header information 213 if header['textobj']: 202 214 if top and top != self.plotter._margins[3]: 203 215 # work around for sdplot in CASA. complete checking in future? 204 216 self.plotter._plotter.figure.subplots_adjust(top=top) 205 self.plotter.print_header() 217 if reset: 218 self.plotter.print_header(plot=True,fontsize=fontsize,selstr=selstr, extrastr=extrastr) 219 else: 220 self.plotter._header_plot(header['string'],fontsize=fontsize) 221 self.plotter._plotter.release() 222 self.plotter._plotter.tidy() 206 223 self.plotter._plotter.show(hardrefresh=False) 207 224 del top
Note:
See TracChangeset
for help on using the changeset viewer.