Changeset 2693
- Timestamp:
- 12/12/12 20:01:06 (12 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotbase.py
r2538 r2693 57 57 self.colormap = c.split() 58 58 59 self.lsalias = {"line": [1,0],60 "dashdot": [4,2,1,2],61 "dashed" : [4,2,4,2],62 "dotted" : [1,2],59 self.lsalias = {"line": '-', #[1,0], 60 "dashdot": '-.', #[4,2,1,2], 61 "dashed" : '--', #[4,2,4,2], 62 "dotted" : ':', #[1,2], 63 63 "dashdotdot": [4,2,1,2,1,2], 64 64 "dashdashdot": [4,2,4,2,1,2] … … 90 90 def clear(self): 91 91 """ 92 Delete all lines from the plot. Line numbering will restart from 0. 92 Delete all lines from the current subplot. 93 Line numbering will restart from 0. 93 94 """ 94 95 -
trunk/python/asapplotter.py
r2691 r2693 1363 1363 PL.savefig(outfile) 1364 1364 1365 1366 def plotpointing2(self, scan=None, colorby='', showline=False, projection=''): 1367 """ 1368 plot telescope pointings 1369 Parameters: 1370 infile : input filename or scantable instance 1371 colorby : change color by either 1372 'type'(source type)|'scan'|'if'|'pol'|'beam' 1373 showline : show dotted line 1374 projection : projection type either 1375 ''(no projection [deg])|'coord'(not implemented) 1376 """ 1377 from numpy import array, pi 1378 from asap import scantable 1379 # check for scantable 1380 if isinstance(scan, scantable): 1381 if self._data is not None: 1382 if scan != self._data: 1383 self._data = scan 1384 # reset 1385 self._reset() 1386 else: 1387 self._data = scan 1388 self._reset() 1389 if not self._data: 1390 msg = "Input is not a scantable" 1391 raise TypeError(msg) 1392 # check for color mode 1393 validtypes=['type','scan','if','pol', 'beam'] 1394 stype = None 1395 if (colorby in validtypes): 1396 stype = colorby[0] 1397 elif len(colorby) > 0: 1398 msg = "Invalid choice of 'colorby' (choices: %s)" % str(validtypes) 1399 raise ValueError(msg) 1400 self._assert_plotter(action="reload") 1401 self._plotter.hold() 1402 if self.casabar_exists(): self._plotter.figmgr.casabar.disable_button() 1403 # for now, only one plot 1404 self._plotter.set_panels(rows=1,cols=1) 1405 # first panel 1406 self._plotter.subplot(0) 1407 # first color and linestyles 1408 self._plotter.palette(0) 1409 self.gca().set_aspect('equal') 1410 basesel = scan.get_selection() 1411 marker = "+" 1412 if showline: 1413 basesel.set_order(["TIME"]) 1414 scan.set_selection(basesel) 1415 if not (stype in ["t", "s"]): 1416 marker = "+:" 1417 if not stype: 1418 selIds = [""] # cheating 1419 sellab = "all points" 1420 elif stype == 't': 1421 selIds = range(15) 1422 sellab = "src type " 1423 else: 1424 selIds = getattr(self._data,'get'+colorby+'nos')() 1425 sellab = colorby.upper() 1426 selFunc = "set_"+colorby+"s" 1427 for idx in selIds: 1428 sel = selector() + basesel 1429 if stype: 1430 bid = getattr(basesel,'get_'+colorby+"s")() 1431 if (len(bid) > 0) and (not idx in bid): 1432 # base selection doesn't contain idx 1433 # Note summation of selector is logical sum if 1434 continue 1435 getattr(sel, selFunc)([idx]) 1436 if not sel.is_empty(): 1437 try: 1438 self._data.set_selection(sel) 1439 except RuntimeError, instance: 1440 if stype == 't' and str(instance).startswith("Selection contains no data."): 1441 continue 1442 else: 1443 self._data.set_selection(basesel) 1444 raise RuntimeError, instance 1445 if self._data.nrow() == 0: 1446 self._data.set_selection(basesel) 1447 continue 1448 print "Plotting direction of %s = %s" % (colorby, str(idx)) 1449 dir = array(self._data.get_directionval()).transpose() 1450 ra = dir[0]*180./pi 1451 dec = dir[1]*180./pi 1452 self._plotter.set_line(label=(sellab+str(idx))) 1453 self._plotter.plot(ra,dec,marker) 1454 1455 # restore original selection 1456 self._data.set_selection(basesel) 1457 # need to plot scan pattern explicitly 1458 if showline and (stype in ["t", "s"]): 1459 dir = array(self._data.get_directionval()).transpose() 1460 ra = dir[0]*180./pi 1461 dec = dir[1]*180./pi 1462 self._plotter.set_line(label="scan pattern") 1463 self._plotter.plot(ra,dec,":") 1464 1465 xlab = 'RA [deg.]' 1466 ylab = 'Declination [deg.]' 1467 self._plotter.set_axes('xlabel', xlab) 1468 self._plotter.set_axes('ylabel', ylab) 1469 self._plotter.set_axes('title', 'Telescope pointings') 1470 if stype: self._plotter.legend(self._legendloc) 1471 else: self._plotter.legend(None) 1472 # reverse x-axis 1473 xmin, xmax = self.gca().get_xlim() 1474 self._plotter.set_limits(xlim=[xmax,xmin]) 1475 1476 self._plotter.release() 1477 self._plotter.show(hardrefresh=False) 1478 return 1479 1365 1480 def plotpointing(self, scan=None, outfile=None): 1366 1481 """ … … 1407 1522 @asaplog_post_dec 1408 1523 def plottp(self, scan=None): 1409 self._assert_plotter(action="reload")1410 self._plotter.hold()1411 self._plotter.clear()1412 1524 from asap import scantable 1413 1525 if not self._data and not scan: … … 1430 1542 # self._datamask = None 1431 1543 1544 self._assert_plotter(action="reload") 1545 self._plotter.hold() 1546 self._plotter.clear() 1432 1547 # Adjust subplot margins 1433 1548 if not self._margins or len(self._margins) !=6: … … 1741 1856 self._assert_plotter(action="reload") 1742 1857 self._plotter.hold() 1743 self._plotter.clear()1858 #self._plotter.clear() #all artists are cleared at set_panels 1744 1859 self._plotter.legend() 1745 1860 … … 1748 1863 self.set_margin(refresh=False) 1749 1864 self._plotter.set_panels(rows=self._rows,cols=self._cols, 1750 nplots=ntotpl,margin=self._margins,ganged=True) 1865 nplots=ntotpl,margin=self._margins,ganged=True) 1751 1866 if self.casabar_exists(): 1752 1867 self._plotter.figmgr.casabar.set_pagecounter(1)
Note:
See TracChangeset
for help on using the changeset viewer.