[1996] | 1 | from asap.asapplotter import asapplotter |
---|
| 2 | from asap.logging import asaplog, asaplog_post_dec |
---|
| 3 | |
---|
| 4 | from asap.parameters import rcParams |
---|
| 5 | from asap.selector import selector |
---|
| 6 | from asap.scantable import scantable |
---|
| 7 | import matplotlib.axes |
---|
| 8 | from matplotlib.font_manager import FontProperties |
---|
| 9 | from matplotlib.text import Text |
---|
| 10 | |
---|
| 11 | class flagplotter(asapplotter): |
---|
| 12 | """ |
---|
| 13 | The flag plotter |
---|
| 14 | Only row based panneling is allowed. |
---|
| 15 | |
---|
| 16 | Example: |
---|
[2001] | 17 | scan = asa p.scantable(filename='your_filename',average=False) |
---|
[1996] | 18 | guiflagger = asap.flagplotter(visible=True) |
---|
| 19 | guiflagger.plot(scan) |
---|
| 20 | ### flag/Unflag data graphically. |
---|
[2001] | 21 | guiflagger.save_data(name='flagged_file.asap',format='ASAP') |
---|
[1996] | 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) |
---|
[1997] | 29 | self._plotter.window.title('Flag Plotter') |
---|
[1996] | 30 | self._panelling = 'r' |
---|
[2001] | 31 | self.set_stacking('scan') |
---|
[1996] | 32 | |
---|
| 33 | def _newcasabar(self): |
---|
| 34 | backend=matplotlib.get_backend() |
---|
| 35 | if self._visible and backend == "TkAgg": |
---|
| 36 | #from asap.casatoolbar import CustomToolbarTkAgg |
---|
| 37 | #return CustomToolbarTkAgg(self) |
---|
| 38 | from asap.flagtoolbar import CustomFlagToolbarTkAgg |
---|
| 39 | return CustomFlagToolbarTkAgg(self) |
---|
| 40 | return None |
---|
| 41 | |
---|
| 42 | @asaplog_post_dec |
---|
| 43 | def _invalid_func(self, name): |
---|
| 44 | msg = "Invalid function 'flagplotter."+name+"'" |
---|
[2001] | 45 | #raise AttributeError(msg) |
---|
[1996] | 46 | asaplog.push(msg) |
---|
| 47 | asaplog.post('ERROR') |
---|
| 48 | |
---|
[2001] | 49 | def set_panelling(self,which='r'): |
---|
| 50 | """ This function is not available for the class flagplotter """ |
---|
| 51 | if which.lower().startswith('r'): |
---|
| 52 | return |
---|
| 53 | msg = "Pannel setting is fixed to row mode in 'flagplotter'" |
---|
| 54 | asaplog.push(msg) |
---|
| 55 | asaplog.post('ERROR') |
---|
| 56 | self._panelling = 'r' |
---|
| 57 | |
---|
| 58 | def plotazel(self,*args,**kwargs): |
---|
| 59 | """ This function is not available for the class flagplotter """ |
---|
| 60 | self._invalid_func(name='plotazel') |
---|
| 61 | |
---|
| 62 | def plotpointing(self,*args,**kwargs): |
---|
| 63 | """ This function is not available for the class flagplotter """ |
---|
| 64 | self._invalid_func(name='plotpointing') |
---|
| 65 | |
---|
| 66 | def plottp(self,*args,**kwargs): |
---|
| 67 | """ This function is not available for the class flagplotter """ |
---|
| 68 | self._invalid_func(name='plottp') |
---|
| 69 | |
---|
[1996] | 70 | def save_data(self, name=None, format=None, overwrite=False): |
---|
[2001] | 71 | """ |
---|
| 72 | Store the plotted scantable on disk. |
---|
| 73 | This function simply redirects call to scantable.save() |
---|
| 74 | |
---|
| 75 | Parameters: |
---|
| 76 | |
---|
| 77 | name: the name of the outputfile. For format "ASCII" |
---|
| 78 | this is the root file name (data in 'name'.txt |
---|
| 79 | and header in 'name'_header.txt) |
---|
| 80 | |
---|
| 81 | format: an optional file format. Default is ASAP. |
---|
| 82 | Allowed are: |
---|
| 83 | * 'ASAP' (save as ASAP [aips++] Table), |
---|
| 84 | * 'SDFITS' (save as SDFITS file) |
---|
| 85 | * 'ASCII' (saves as ascii text file) |
---|
| 86 | * 'MS2' (saves as an casacore MeasurementSet V2) |
---|
| 87 | * 'FITS' (save as image FITS - not readable by class) |
---|
| 88 | * 'CLASS' (save as FITS readable by CLASS) |
---|
| 89 | |
---|
| 90 | overwrite: If the file should be overwritten if it exists. |
---|
| 91 | The default False is to return with warning |
---|
| 92 | without writing the output. USE WITH CARE. |
---|
| 93 | """ |
---|
[1996] | 94 | # simply calls scantable.save |
---|
| 95 | self._data.save(name,format,overwrite) |
---|