casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
plotcal.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2009, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from  casac import *
00009 import string
00010 from taskinit import casalog
00011 #from taskmanager import tm
00012 import task_plotcal
00013 def plotcal(caltable='', xaxis='', yaxis='', poln='', field='', antenna='', spw='', timerange='', subplot=111, overplot=False, clearpanel='Auto', iteration='', plotrange=[
00014                         ], showflags=False, plotsymbol='o', plotcolor='blue', markersize=5.0, fontsize=10.0, showgui=True, figfile=''):
00015 
00016         """An all-purpose plotter for calibration results 
00017         
00018         The values for all calibration solutions (G, T, GSPLINE, B, BPOLY, D, M) 
00019         can be displayed for a variety of polarization combinations and calibrations.
00020         The plot solutions may be iterated through antennas/spw/fields during one execution,
00021         and many frames can be obtained in each plot.
00022 
00023         The plotter permits zooming, listing and flagging of solutions, although
00024         the results of flagged solutions are not yet available.
00025 
00026 
00027         The plotter permits zooming, listing and flagging of solutions, although
00028         the implications of flagged solutions are not yet made.  See some hints at the end
00029         of this description.
00030 
00031 
00032         Keyword arguments:
00033         caltable -- Name of input calibration table 
00034                 default: none; example: caltable='ngc5921.gcal'
00035                 The type of calibration table is determined automatically.
00036         xaxis -- Value to plot on the x axis
00037                 Options: 'time','scan','chan','freq','antenna','amp','phase','real','imag','snr'
00038                 Default: cal type dependent, usually 'time'
00039         yaxis -- Value to plot on the y-axis
00040                 Options: 'amp','phase','real','imag','snr','antenna','tsys','delay','spgain'
00041                 Default: cal type dependent, usually 'amp'
00042         poln -- Polarization (or combination) to plot
00043                 default: '' (RL); all polarizations
00044                 Options: '' = ('RL'),'R','L','XY','X','Y',
00045                                '/' --> form complex poln ratio
00046                                      (amp ratio and phase difference)
00047         field -- Select field using field id(s) or field name(s).
00048                   ['go listobs' to obtain the fieldt id's or names]
00049                default: ''=all fields
00050                If field string is a non-negative integer, it is assumed a
00051                field index, otherwise it is assumed a field name
00052                field='0~2'; field ids 0,1,2
00053                field='0,4,5~7'; field ids 0,4,5,6,7
00054                field='3C286,3C295'; field named 3C286 and 3C295
00055                field = '3,4C*'; field id 3, all names starting with 4C
00056         antenna -- Antenna selection (baseline syntax ignored)
00057                default: '' (all);
00058                example: antenna='1,3~5' means antenna
00059                   indices 1,3,4,5.  
00060         spw -- Select spectral window (channel syntax ignored, except for D)
00061                default: ''=all spectral windows
00062                spw='0~2,4'; spectral windows 0,1,2,4
00063                spw='<2';  spectral windows less than 2
00064         timerange -- Time selection
00065                   default: '' (all)
00066                   example: timerange='1995/04/13/09:15:00~1995/04/13/09:25:00'
00067 
00068         --- Plot Options ---
00069         subplot -- Panel number on the display screen
00070                default: 111 (full screen display);
00071                examples:
00072                if iteration = 'antenna'; subplot=321 then
00073                   a plot frame will contain the first 6 antennas, in three
00074                   rows and two columns.  Follow instructions on screen to
00075                   cycle through the frames
00076                if iteration = ''; then one frame can be filled with many
00077                   plots in a piecemeal fashion; for example
00078                   antenna='0'; subplot=221; plotcal()
00079                   antenna='1'; subplot=222; plotcal()
00080                   antenna='2'; subplot=223; plotcal()
00081                   antenna='3'; subplot=224; plotcal()
00082         overplot -- Overplot these values on current plot (if possible)
00083                default: False;
00084                   True (overplotting) can be done ONLY IF iteration=''
00085         clearpanel -- Ignore this parameter.
00086                   Clear nothing on the plot window, automatically
00087                   clear plotting area, clear the current plot area, or
00088                   clear the whole plot panel.
00089                options: None, Auto, Current, All (None and Auto not supported)
00090                default: Auto
00091                example: clearpanel='Current'
00092         iteration -- Create a sequence of plots, iterating over antenna, time,
00093                  field, and/or spw  
00094                default: '' --> create in all in one plot
00095                example: iteration='antenna' --> create a sequence of
00096                         separate plots separated by antenna. Flagging cannot
00097                         be done in iteration mode.
00098         plotrange -- Control the x and y ranges of the plot, as a list of
00099                  values, e.g., [xmin,xmax,ymin,ymax]
00100                  default=[] --> plot will self-scale
00101                  Note: time plotting ranges are cumbersome to use.
00102                        Use the zoom option
00103         showflags -- If true, only flagged solutions will be plotted
00104                  default: false --> only show unflagged solutions
00105         plotsymbol -- pylab plot symbol.  See cookbook for details
00106                    default: '.': large points
00107                    ',' = small points (see markersize)
00108                    '-' = connect points by line
00109                    colors are cycled automatically for multi-function plots
00110         plotcolor -- Initial color to use on each plot
00111                  default: 'blue'
00112         markersize -- Control the size of plot symbols
00113                   default: 5.0 --> a nice size for symbols
00114         fontsize -- Control the font size of title (axes labels will be
00115                   80% of this size)
00116                   default: 10.0
00117         showgui -- Whether or not to display the plotting GUI
00118                   default: True; example showgui=False
00119         figfile -- File name to save the plotted figure to.
00120                   default: ''; example figfile=myPlot.png
00121 
00122          Hints on using plotxy (see section 3.4 in cookbook)
00123 
00124          Useful Buttons at bottom left:
00125               5th--magnifying glass.  Click on this,
00126                        left mouse button rectangle drag will zoom
00127                        right mose button rectangle drag will unzoom a certain amount
00128               1st--restore original magnification
00129 
00130          Useful regions just above:
00131               Quit will terminate plotter
00132               Next will go to next plot as specified by iteration
00133               To locate, you must click 'Mark Region' first
00134                  then make appropriate region(s)
00135                  then click locate to list points on logger
00136                  DO NOT USE Flag, Unflag at the present time.
00137                           
00138  
00139         """
00140         if type(plotrange)==float: plotrange=[plotrange]
00141 
00142 #
00143 #    The following is work around to avoid a bug with current python translation
00144 #
00145         mytmp = {}
00146 
00147         mytmp['caltable'] = caltable
00148         mytmp['xaxis'] = xaxis
00149         mytmp['yaxis'] = yaxis
00150         mytmp['poln'] = poln
00151         mytmp['field'] = field
00152         mytmp['antenna'] = antenna
00153         mytmp['spw'] = spw
00154         mytmp['timerange'] = timerange
00155         mytmp['subplot'] = subplot
00156         mytmp['overplot'] = overplot
00157         mytmp['clearpanel'] = clearpanel
00158         mytmp['iteration'] = iteration
00159         mytmp['plotrange'] = plotrange
00160         mytmp['showflags'] = showflags
00161         mytmp['plotsymbol'] = plotsymbol
00162         mytmp['plotcolor'] = plotcolor
00163         mytmp['markersize'] = markersize
00164         mytmp['fontsize'] = fontsize
00165         mytmp['showgui'] = showgui
00166         mytmp['figfile'] = figfile
00167         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00168         trec = casac.utils().torecord(pathname+'plotcal.xml')
00169 
00170         casalog.origin('plotcal')
00171         if trec.has_key('plotcal') and casac.utils().verify(mytmp, trec['plotcal']) :
00172             result = task_plotcal.plotcal(caltable, xaxis, yaxis, poln, field, antenna, spw, timerange, subplot, overplot, clearpanel, iteration, plotrange, showflags, plotsymbol, plotcolor, markersize, fontsize, showgui, figfile)
00173 
00174         else :
00175           result = False
00176         return result