source: branches/parallel/python/flagplotter.py@ 2227

Last change on this file since 2227 was 2116, checked in by Kana Sugimoto, 14 years ago

merged modifications in trunk (r2115)

File size: 4.3 KB
Line 
1from asap.asapplotter import asapplotter
2from asap.logging import asaplog, asaplog_post_dec
3
4from asap.parameters import rcParams
5from asap.selector import selector
6from asap.scantable import scantable
7import matplotlib.axes
8from matplotlib.font_manager import FontProperties
9from matplotlib.text import Text
10
11class flagplotter(asapplotter):
12 """
13 The flag plotter
14 Only row based panneling is allowed.
15
16 Example:
17 scan = asa p.scantable(filename='your_filename',average=False)
18 guiflagger = asap.flagplotter(visible=True)
19 guiflagger.plot(scan)
20 ### flag/Unflag data graphically.
21 guiflagger.save_data(name='flagged_file.asap',format='ASAP')
22
23 NOTICE:
24 The flagged data is not saved until you explicitly run scantable.save
25 """
26 def __init__(self, visible=None, **kwargs):
27 self._scan=None
28 asapplotter.__init__(self,visible=visible, **kwargs)
29 self._plotter.window.title('Flag Plotter')
30 self._panelling = 'r'
31 self.set_stacking('scan')
32 self._ismodified = False
33
34 def _newcasabar(self):
35 backend=matplotlib.get_backend()
36 if self._visible and backend == "TkAgg":
37 #from asap.casatoolbar import CustomToolbarTkAgg
38 #return CustomToolbarTkAgg(self)
39 from asap.flagtoolbar import CustomFlagToolbarTkAgg
40 return CustomFlagToolbarTkAgg(self)
41 return None
42
43 @asaplog_post_dec
44 def _invalid_func(self, name):
45 msg = "Invalid function 'flagplotter."+name+"'"
46 #raise AttributeError(msg)
47 asaplog.push(msg)
48 asaplog.post('ERROR')
49
50 def set_panelling(self,which='r'):
51 """ This function is not available for the class flagplotter """
52 if which.lower().startswith('r'):
53 return
54 msg = "Pannel setting is fixed to row mode in 'flagplotter'"
55 asaplog.push(msg)
56 asaplog.post('ERROR')
57 self._panelling = 'r'
58
59 def plotazel(self,*args,**kwargs):
60 """ This function is not available for the class flagplotter """
61 self._invalid_func(name='plotazel')
62
63 def plotpointing(self,*args,**kwargs):
64 """ This function is not available for the class flagplotter """
65 self._invalid_func(name='plotpointing')
66
67 def plottp(self,*args,**kwargs):
68 """ This function is not available for the class flagplotter """
69 self._invalid_func(name='plottp')
70
71 def save_data(self, name=None, format=None, overwrite=False):
72 """
73 Store the plotted scantable on disk.
74 This function simply redirects call to scantable.save()
75
76 Parameters:
77
78 name: the name of the outputfile. For format "ASCII"
79 this is the root file name (data in 'name'.txt
80 and header in 'name'_header.txt)
81
82 format: an optional file format. Default is ASAP.
83 Allowed are:
84 * 'ASAP' (save as ASAP [aips++] Table),
85 * 'SDFITS' (save as SDFITS file)
86 * 'ASCII' (saves as ascii text file)
87 * 'MS2' (saves as an casacore MeasurementSet V2)
88 * 'FITS' (save as image FITS - not readable by class)
89 * 'CLASS' (save as FITS readable by CLASS)
90
91 overwrite: If the file should be overwritten if it exists.
92 The default False is to return with warning
93 without writing the output. USE WITH CARE.
94 """
95 # simply calls scantable.save
96 self._data.save(name,format,overwrite)
97
98 def set_data(self, scan, refresh=True):
99 if self._is_new_scan(scan):
100 self._ismodified = False
101 asapplotter.set_data(self, scan, refresh)
102 set_data.__doc__ = asapplotter.set_data.__doc__
103
104 @asaplog_post_dec
105 def plot(self, scan=None):
106 if self._is_new_scan(scan):
107 self._ismodified = False
108 asapplotter.plot(self,scan)
109 plot.__doc__ = asapplotter.plot.__doc__
110
111 def _is_new_scan(self,scan):
112 if isinstance(scan, scantable):
113 if self._data is not None:
114 if scan != self._data:
115 return True
116 else:
117 return True
118 return False
Note: See TracBrowser for help on using the repository browser.