casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
plotms_pg.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2008, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from casac import *
00009 import string
00010 import time
00011 import inspect
00012 import gc
00013 import numpy
00014 from odict import odict
00015 from task_plotms import plotms
00016 from task_plotms import casalog
00017 
00018 class plotms_pg_:
00019     __name__ = "plotms"
00020 
00021     def __init__(self) :
00022        self.__bases__ = (plotms_pg_,)
00023        self.__doc__ = self.__call__.__doc__
00024 
00025 
00026     def __call__(self, vis=None, xaxis=None, xdatacolumn=None, yaxis=None, ydatacolumn=None, selectdata=None, field=None, spw=None, timerange=None, uvrange=None, antenna=None, scan=None, correlation=None, array=None, observation=None, msselect=None, averagedata=None, avgchannel=None, avgtime=None, avgscan=None, avgfield=None, avgbaseline=None, avgantenna=None, avgspw=None, scalar=None, transform=None, freqframe=None, restfreq=None, veldef=None, shift=None, extendflag=None, extcorr=None, extchannel=None, iteraxis=None, xselfscale=None, yselfscale=None, customsymbol=None, symbolshape=None, symbolsize=None, symbolcolor=None, symbolfill=None, symboloutline=None, coloraxis=None, customflaggedsymbol=None, flaggedsymbolshape=None, flaggedsymbolsize=None, flaggedsymbolcolor=None, flaggedsymbolfill=None, flaggedsymboloutline=None, plotrange=None, title=None, xlabel=None, ylabel=None, showmajorgrid=None, majorwidth=None, majorstyle=None, majorcolor=None, showminorgrid=None, minorwidth=None, minorstyle=None, minorcolor=None, plotfile=None, expformat=None, highres=None, interactive=None, overwrite=None, async=None):
00027 
00028         """A plotter/interactive flagger for visibility data.
00029 
00030             Task for plotting and interacting with visibility data.  A variety
00031         of axes choices (including data column) along with MS selection and
00032         averaging options are provided for data selection.  Flag extension
00033         parameters are also available for flagging operations in the plotter.
00034         
00035             All of the provided parameters can also be set using the GUI once
00036         the application has been launched.  Additional and more specific
00037         operations are available through the GUI and/or through the plotms
00038         tool (pm).
00039         
00040 
00041     Keyword arguments:
00042     vis -- input visibility dataset
00043            default: ''
00044     xaxis, yaxis -- what to plot on the two axes
00045                     default: '' (defaults are xaxis='time',
00046                                  yaxis='amp' on first execution;
00047                                  thereafter the most recent
00048                                  settings are used)
00049               valid options (=indicates valid synonyms): 
00050                MS Ids and other meta info:
00051                  'scan'   (number)
00052                  'field'  (index)
00053                  'time',  
00054                  'interval'='timeint'='timeinterval'='time_interval'
00055                  'spw'    (index)
00056                  'chan'='channel'    (index)  
00057                  'freq'='frequency'  (GHz)
00058                  'vel'='velocity'   (km/s)
00059                  'corr'='correlation'  (index)
00060                  'ant1'='antenna1'   (index)
00061                  'ant2'='antenna2'   (index)
00062                  'baseline'  (a baseline index) 
00063                  'row'  (absoute row Id from the MS)
00064                Visibility values, flags:
00065                  'amp'='amplitude'
00066                  'phase'  (deg)
00067                  'real'  
00068                  'imag'='imaginary'
00069                  'wt'='weight'
00070                  'flag'
00071                  'flagrow'
00072                Observational geometry:
00073                  'uvdist'  (meters)
00074                  'uvwave'='uvdistl'='uvdist_l'  (wavelengths, per channel)
00075                  'u'  (meters)
00076                  'v'  (meters)
00077                  'w'  (meters)
00078                  'uwave'  ('u' in wavelengths, per channel)
00079                  'vwave'  ('v' in wavelengths, per channel)
00080                  'wwave'  ('w' in wavelengths, per channel)
00081                  'azimuth'  (at array reference; degrees)
00082                  'elevation'  (at array reference; degrees)
00083                  'hourang'='hourangle'  (at array reference; hours)
00084                  'parang'='parangle'='parallacticangle'  (at array reference; degrees)
00085                Antenna-based (only works vs. data Ids):
00086                  'ant'='antenna'
00087                  'ant-azimuth' 
00088                  'ant-elevation'
00089                  'ant-parang'='ant-parangle'
00090 
00091       >>> xaxis, yaxis expandable parameters
00092         xdatacolumn, 
00093         ydatacolumn  -- which data column to use for Visibility values:
00094                         default: '' ('data' on first execuation;
00095                                      thereafter the most recent
00096                                      setting is used)
00097                         valid options:  'data'      (observed)
00098                                         'corrected'='corr'
00099                                         'model'
00100                                         'residual'  (corrected - model)
00101     
00102     selectdata -- data selection parameters flag
00103                   default: True  (reveals data selection parameters
00104                                   described below)
00105                   Consult listobs output for data selection values,
00106                   and see help par.selectdata for more detailed 
00107                   information on syntax; also, visit
00108                   http://casa.nrao.edu/other_doc.shtml and click
00109                   on "Measurement Set selection syntax" for more
00110                   tips on using data selection parameters in CASA)
00111 
00112       >>> selectdata expandable parameters:
00113 
00114       field -- Select field using field id(s) or field name(s).
00115               default: ''=all fields
00116               If field string is a non-negative integer, it is assumed a
00117                 field index,  otherwise, it is assumed a field name
00118               field='0~2'; field ids 0,1,2
00119               field='0,4,5~7'; field ids 0,4,5,6,7
00120               field='3C286,3C295'; field named 3C286 and 3C295
00121               field = '3,4C*'; field id 3, all names starting with 4C
00122       spw -- Select spectral window/channels
00123                type 'help par.selection' for more examples.
00124              spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
00125              spw='<2';  spectral windows less than 2 (i.e. 0,1)
00126              spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE
00127              spw='*:5~61'; all spw with channels 5 to 61
00128              spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45.
00129              spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
00130              spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60
00131                        NOTE ';' to separate channel selections
00132 
00133       timerange  -- Select data based on time range:
00134               default = '' (all); examples,
00135               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
00136               Note: if YYYY/MM/DD is missing date defaults to first day in data set
00137               timerange='09:14:0~09:54:0' picks 40 min on first day
00138               timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on NEXT day
00139               timerange='09:44:00' pick data within one integration of time
00140               timerange='>10:24:00' data after this time
00141       uvrange -- Select data within uvrange (default units meters)
00142               default: '' (all); example:
00143               uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda
00144               uvrange='>4klambda';uvranges greater than 4 kilo lambda
00145 
00146       antenna -- Select data based on antenna/baseline
00147               default: '' (all, including auto-correlations, if present)
00148               If antenna string is a non-negative integer, it is assumed an
00149                 antenna index, otherwise, it is assumed as an antenna name
00150               antenna='5&6'; baseline between antenna index 5 and index 6.
00151               antenna='!ea02'; exclude EVLA antenna 2.
00152               antenna='ea13;!ea22'; EVLA antenna 13, excluding antenna 22.
00153               antenna='VA05&VA06'; baseline between VLA antenna 5 and 6.
00154               antenna='5&6;7&8'; baselines with indices 5-6 and 7-8
00155               antenna='5'; all baselines with antenna index 5
00156               antenna='05'; all baselines with antenna number 05 (VLA old name)
00157               antenna='5,6,10'; all baselines with antennas 5,6,10 index numbers
00158               NB: For explicit selections, use a single ampersand (&) to
00159               select only cross-correlations among the specified antennas, 
00160               double ampersands (&&) to select cross- and
00161               auto-correlations among the specified antennas, and
00162               triple ampersands (&&&) to select only
00163               auto-correlations.  E.g.:
00164               antenna='*&'; selects all cross-correlation baseline
00165                             (excludes all auto-correlations)
00166               antenna='*&&&'; selects all auto-correlation baselines
00167                               (excludes all cross-correlations)
00168               antenna='1&&1,2,3'; selects baselines 1-1 (auto), 1-2,1-3 (cross)
00169               antenna='VA05&&&'; selects the VA05 autocorrelation
00170               See the link noted above for more information.
00171       scan -- Scan numbers or ranges.
00172               default: ''  (all scans)
00173               scan='1,2,6,43'; scans 1, 2, 6, and 43
00174               scan='3~14'; scans 3 through 14, inclusive
00175       correlation -- Select by correlation
00176                      default: ''  (all correlations)
00177                      options: 'RR','RL','LR','LL','XX','XY','YX','YY',
00178                                or any comma-separated combination; use
00179                                basis (R/L or X/Y) appropriate to the MS)
00180       array -- Select the array id
00181                default: ''  (all array ids)
00182       observation Select by observation ID(s).
00183                   default: ''-->all;
00184                   example: observation='0' (select obsID 0)
00185       msselect -- Optional TaQL data selection
00186 
00187     averagedata -- data averaing parameters flag
00188                    default: True   (reveals expandable parameters
00189                                     described below)
00190       >>> averagedata expandable parameters
00191         avgchannel -- average over channel?  either blank for none, or a value
00192                       in channels.
00193                       default: '' (no channel averaging).
00194         avgtime -- average over time?  either blank for none, or a value in
00195                    seconds.
00196                    default: '' (no time averaging).
00197         avgscan -- average over scans?  only valid if time averaging is turned
00198                    on.
00199                    default: False.
00200         avgfield -- average over fields?  only valid if time averaging is
00201                     turned on.
00202                     default: False.
00203         avgbaseline -- average over selected baselines; mutually 
00204                        exclusive with avgantenna.
00205                        default: False.  (no averaging over baseline)
00206         avgantenna -- form per-antenna averages; mutually exclusive with
00207                       avgbaseline.
00208                       default: False.   (no per-antenna averaging)
00209         avgspw -- average over selected spectral windows?
00210                   default: False.  (no average of spectral windows)
00211         scalar -- scalar averaging?
00212                   default: False  (i.e., do vector averaging)
00213     
00214     transform -- apply various transformations on data for plotting
00215                  default: False.
00216       >>> transform expandable parameters
00217         freqframe -- the coordinate frame in which to render frequency and velocity axes
00218                  default: ''  (unspecified: will use frame in which data were taken)
00219                  options: TOPO, GEO, BARY, LSRK, LSRD
00220         restfreq -- the rest frequency to use in velocity conversions (MHz)
00221                  default: '' (use spw central frequency and show relative velocity)
00222                  example: '22235.08MHz'
00223         veldef -- the velocity definition to use
00224                  default: 'RADIO'
00225                  options: 'RADIO','OPT','TRUE'
00226         shift -- adjust phase according to a phase center shift [dx,dy] (arcsec)
00227                  default: [0,0]  (no shift)
00228 
00229     extendflag -- have flagging extend to other data points?
00230                   default: False.
00231       >>> extendflag expandable parameters
00232         extcorr -- extend flags based on correlation? 
00233                    default: False.
00234         extchannel -- extend flags based on channel?
00235 
00236     iteraxis -- axis upon which iterate plots (one plot per page, for now)
00237                 default: '' (no iteration)
00238                 options: 'scan','field','spw','baseline','antenna',''
00239       >>> iteraxis expandable parameters
00240         xselfscale -- If true, self-scale each iterated plot on the x axis
00241         yselfscale -- If true, self-scale each iterated plot on the y axis
00242                       default: false, which will scale all plots globally
00243 
00244     customsymbol -- If true, use a custom symbol for drawing unflagged points
00245                     default: True
00246       >>> customsymbol expandable parameters
00247         symbolshape -- If true, use a custom shape to draw unflagged symbols
00248                        default: 'autoscaling' (ignores symbolsize)
00249                        options: 'autoscaling', 'circle', 'square', 'diamond', 'pixel', 'nosymbol'
00250         symbolsize -- size of the unflagged symbols in pixels
00251                       default: 2
00252         symbolcolor -- color to use for unflagged symbols; can be a RGB hex code or a color name
00253                        default: '0000ff'
00254                        example: 'purple'
00255         symbolfill -- type of fill to use for unflagged symbols
00256                       default: 'fill'
00257                       options: 'fill', 'mesh1', 'mesh2', 'mesh3', 'nofill'
00258         symboloutline -- If true, outline unflagged symbols in black
00259 
00260     coloraxis -- axis upon which to colorize the plotted points
00261                 options (= indicates synonyms):
00262                     'scan',  'field',  'spw',  'antenna1'='ant1',  'antenna2'='ant2',
00263                     'baseline',  'channel'='chan',  'corr'='correlation'
00264                 default: ''  (use a single color for all points)
00265 
00266     customflaggedsymbol -- If true, use a custom symbol for drawing flagged points
00267                            default: False
00268       >>> customflaggedsymbol expandable parameters
00269         symbolshape -- If true, use a custom shape to draw flagged symbols
00270                        default: 'nosymbol'
00271                        options: 'autoscaling', 'circle', 'square', 'diamond', 'pixel', 'nosymbol'
00272         symbolsize -- size of the flagged symbols in pixels
00273                       default: 2
00274         symbolcolor -- color to use for flagged symbols; can be a RGB hex code or a color name
00275                        default: '0000ff'
00276                        example: 'purple'
00277         symbolfill -- type of fill to use for flagged symbols
00278                       default: 'fill'
00279                       options: 'fill', 'mesh1', 'mesh2', 'mesh3', 'nofill'
00280         symboloutline -- If true, outline flagged symbols in black
00281 
00282     plotrange -- manual plot axis ranges: [xmin,xmax,ymin,ymax]
00283                  Does not affect data selection.
00284                  default: []; both axes will be autoscaled according
00285                  to the ranges found in the selected data
00286                  If xmin=xmax (or ymin=ymax) then that axis will
00287                  be autoscaled, e.g.:
00288                  [0,0,-2.0,14.0]; autoscale the xaxis, and use 
00289                                   ymin=-2.0, ymax=14.0
00290 
00291     title  -- title along top of plot (called "canvas" in some places)
00292     
00293     xlabel -- text to label horizontal axis, with formatting using '%%' 
00294     ylabel -- text to label horizontal axis, with formatting using '%%' 
00295     
00296     showmajorgrid  -- show major grid lines (horiz and vert.)
00297                   default: False.
00298       >>>  major grid expandable parameters
00299         majorwidth  -- line width in pixels of major grid lines
00300         majorstyle  -- major grid line style: solid dash dot none
00301         majorcolor  -- color in hex code of major grid lines
00302 
00303     showminorgrid  -- show minor grid lines (horiz and vert.)
00304                   default: False.
00305       >>>  minor grid expandable parameters
00306         minorwidth  --  line width in pixels of minor grid lines
00307         minorstyle  --  minor grid line style: solid dash dot none
00308         minorcolor  --  color in hex code of minor grid lines
00309 
00310     plotfile -- name of plot file to save automatically
00311                 default: ''  (i.e., draw an interactive plot in the gui)
00312       >>> plotfile expandable parameters
00313         expformat -- export format type; if 'txt' is used an ASCII dump of the plotted points is generated (also available in the export tab)
00314                      default:  ''   (plotfile extension will be used)
00315                      options: 'jpg', 'png', 'ps', 'pdf', 'txt'
00316         highres -- use high resolution? Always true for jpg and png.
00317                    default: false
00318         interactive  -- interactive mode? (pop up confirmation window)
00319                         default: false (e.g., for automated scripts to prevent blocking).
00320         overwrite -- Overwrite plot file if it already exists?
00321                      default: false
00322 
00323 
00324 
00325         """
00326         a=inspect.stack()
00327         stacklevel=0
00328         for k in range(len(a)):
00329           if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0):
00330                 stacklevel=k
00331                 break
00332         myf=sys._getframe(stacklevel).f_globals
00333         myf['__last_task'] = 'plotms'
00334         myf['taskname'] = 'plotms'
00335         ###
00336         myf['update_params'](func=myf['taskname'],printtext=False)
00337         ###
00338         ###
00339         #Handle globals or user over-ride of arguments
00340         #
00341         function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults))
00342         useLocalDefaults = False
00343 
00344         for item in function_signature_defaults.iteritems():
00345                 key,val = item
00346                 keyVal = eval(key)
00347                 if (keyVal == None):
00348                         #user hasn't set it - use global/default
00349                         pass
00350                 else:
00351                         #user has set it - use over-ride
00352                         if (key != 'self') :
00353                            useLocalDefaults = True
00354                         #myf[key]=keyVal
00355 
00356         myparams = {}
00357         if useLocalDefaults :
00358            for item in function_signature_defaults.iteritems():
00359                key,val = item
00360                keyVal = eval(key)
00361                exec('myparams[key] = keyVal')
00362                if (keyVal == None):
00363                    exec('myparams[key] = '+ key + ' = self.itsdefault(key)')
00364                    keyVal = eval(key)
00365                    if(type(keyVal) == dict) :
00366                       exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']')
00367 
00368         else :
00369             uselessvariable = None 
00370             myparams['vis'] = vis = myf['vis']
00371             myparams['xaxis'] = xaxis = myf['xaxis']
00372             myparams['xdatacolumn'] = xdatacolumn = myf['xdatacolumn']
00373             myparams['yaxis'] = yaxis = myf['yaxis']
00374             myparams['ydatacolumn'] = ydatacolumn = myf['ydatacolumn']
00375             myparams['selectdata'] = selectdata = myf['selectdata']
00376             myparams['field'] = field = myf['field']
00377             myparams['spw'] = spw = myf['spw']
00378             myparams['timerange'] = timerange = myf['timerange']
00379             myparams['uvrange'] = uvrange = myf['uvrange']
00380             myparams['antenna'] = antenna = myf['antenna']
00381             myparams['scan'] = scan = myf['scan']
00382             myparams['correlation'] = correlation = myf['correlation']
00383             myparams['array'] = array = myf['array']
00384             myparams['observation'] = observation = myf['observation']
00385             myparams['msselect'] = msselect = myf['msselect']
00386             myparams['averagedata'] = averagedata = myf['averagedata']
00387             myparams['avgchannel'] = avgchannel = myf['avgchannel']
00388             myparams['avgtime'] = avgtime = myf['avgtime']
00389             myparams['avgscan'] = avgscan = myf['avgscan']
00390             myparams['avgfield'] = avgfield = myf['avgfield']
00391             myparams['avgbaseline'] = avgbaseline = myf['avgbaseline']
00392             myparams['avgantenna'] = avgantenna = myf['avgantenna']
00393             myparams['avgspw'] = avgspw = myf['avgspw']
00394             myparams['scalar'] = scalar = myf['scalar']
00395             myparams['transform'] = transform = myf['transform']
00396             myparams['freqframe'] = freqframe = myf['freqframe']
00397             myparams['restfreq'] = restfreq = myf['restfreq']
00398             myparams['veldef'] = veldef = myf['veldef']
00399             myparams['shift'] = shift = myf['shift']
00400             myparams['extendflag'] = extendflag = myf['extendflag']
00401             myparams['extcorr'] = extcorr = myf['extcorr']
00402             myparams['extchannel'] = extchannel = myf['extchannel']
00403             myparams['iteraxis'] = iteraxis = myf['iteraxis']
00404             myparams['xselfscale'] = xselfscale = myf['xselfscale']
00405             myparams['yselfscale'] = yselfscale = myf['yselfscale']
00406             myparams['customsymbol'] = customsymbol = myf['customsymbol']
00407             myparams['symbolshape'] = symbolshape = myf['symbolshape']
00408             myparams['symbolsize'] = symbolsize = myf['symbolsize']
00409             myparams['symbolcolor'] = symbolcolor = myf['symbolcolor']
00410             myparams['symbolfill'] = symbolfill = myf['symbolfill']
00411             myparams['symboloutline'] = symboloutline = myf['symboloutline']
00412             myparams['coloraxis'] = coloraxis = myf['coloraxis']
00413             myparams['customflaggedsymbol'] = customflaggedsymbol = myf['customflaggedsymbol']
00414             myparams['flaggedsymbolshape'] = flaggedsymbolshape = myf['flaggedsymbolshape']
00415             myparams['flaggedsymbolsize'] = flaggedsymbolsize = myf['flaggedsymbolsize']
00416             myparams['flaggedsymbolcolor'] = flaggedsymbolcolor = myf['flaggedsymbolcolor']
00417             myparams['flaggedsymbolfill'] = flaggedsymbolfill = myf['flaggedsymbolfill']
00418             myparams['flaggedsymboloutline'] = flaggedsymboloutline = myf['flaggedsymboloutline']
00419             myparams['plotrange'] = plotrange = myf['plotrange']
00420             myparams['title'] = title = myf['title']
00421             myparams['xlabel'] = xlabel = myf['xlabel']
00422             myparams['ylabel'] = ylabel = myf['ylabel']
00423             myparams['showmajorgrid'] = showmajorgrid = myf['showmajorgrid']
00424             myparams['majorwidth'] = majorwidth = myf['majorwidth']
00425             myparams['majorstyle'] = majorstyle = myf['majorstyle']
00426             myparams['majorcolor'] = majorcolor = myf['majorcolor']
00427             myparams['showminorgrid'] = showminorgrid = myf['showminorgrid']
00428             myparams['minorwidth'] = minorwidth = myf['minorwidth']
00429             myparams['minorstyle'] = minorstyle = myf['minorstyle']
00430             myparams['minorcolor'] = minorcolor = myf['minorcolor']
00431             myparams['plotfile'] = plotfile = myf['plotfile']
00432             myparams['expformat'] = expformat = myf['expformat']
00433             myparams['highres'] = highres = myf['highres']
00434             myparams['interactive'] = interactive = myf['interactive']
00435             myparams['overwrite'] = overwrite = myf['overwrite']
00436 
00437         if type(shift)==float: shift=[shift]
00438         if type(plotrange)==float: plotrange=[plotrange]
00439 
00440         result = None
00441 
00442 #
00443 #    The following is work around to avoid a bug with current python translation
00444 #
00445         mytmp = {}
00446 
00447         mytmp['vis'] = vis
00448         mytmp['xaxis'] = xaxis
00449         mytmp['xdatacolumn'] = xdatacolumn
00450         mytmp['yaxis'] = yaxis
00451         mytmp['ydatacolumn'] = ydatacolumn
00452         mytmp['selectdata'] = selectdata
00453         mytmp['field'] = field
00454         mytmp['spw'] = spw
00455         mytmp['timerange'] = timerange
00456         mytmp['uvrange'] = uvrange
00457         mytmp['antenna'] = antenna
00458         mytmp['scan'] = scan
00459         mytmp['correlation'] = correlation
00460         mytmp['array'] = array
00461         mytmp['observation'] = observation
00462         mytmp['msselect'] = msselect
00463         mytmp['averagedata'] = averagedata
00464         mytmp['avgchannel'] = avgchannel
00465         mytmp['avgtime'] = avgtime
00466         mytmp['avgscan'] = avgscan
00467         mytmp['avgfield'] = avgfield
00468         mytmp['avgbaseline'] = avgbaseline
00469         mytmp['avgantenna'] = avgantenna
00470         mytmp['avgspw'] = avgspw
00471         mytmp['scalar'] = scalar
00472         mytmp['transform'] = transform
00473         mytmp['freqframe'] = freqframe
00474         mytmp['restfreq'] = restfreq
00475         mytmp['veldef'] = veldef
00476         mytmp['shift'] = shift
00477         mytmp['extendflag'] = extendflag
00478         mytmp['extcorr'] = extcorr
00479         mytmp['extchannel'] = extchannel
00480         mytmp['iteraxis'] = iteraxis
00481         mytmp['xselfscale'] = xselfscale
00482         mytmp['yselfscale'] = yselfscale
00483         mytmp['customsymbol'] = customsymbol
00484         mytmp['symbolshape'] = symbolshape
00485         mytmp['symbolsize'] = symbolsize
00486         mytmp['symbolcolor'] = symbolcolor
00487         mytmp['symbolfill'] = symbolfill
00488         mytmp['symboloutline'] = symboloutline
00489         mytmp['coloraxis'] = coloraxis
00490         mytmp['customflaggedsymbol'] = customflaggedsymbol
00491         mytmp['flaggedsymbolshape'] = flaggedsymbolshape
00492         mytmp['flaggedsymbolsize'] = flaggedsymbolsize
00493         mytmp['flaggedsymbolcolor'] = flaggedsymbolcolor
00494         mytmp['flaggedsymbolfill'] = flaggedsymbolfill
00495         mytmp['flaggedsymboloutline'] = flaggedsymboloutline
00496         mytmp['plotrange'] = plotrange
00497         mytmp['title'] = title
00498         mytmp['xlabel'] = xlabel
00499         mytmp['ylabel'] = ylabel
00500         mytmp['showmajorgrid'] = showmajorgrid
00501         mytmp['majorwidth'] = majorwidth
00502         mytmp['majorstyle'] = majorstyle
00503         mytmp['majorcolor'] = majorcolor
00504         mytmp['showminorgrid'] = showminorgrid
00505         mytmp['minorwidth'] = minorwidth
00506         mytmp['minorstyle'] = minorstyle
00507         mytmp['minorcolor'] = minorcolor
00508         mytmp['plotfile'] = plotfile
00509         mytmp['expformat'] = expformat
00510         mytmp['highres'] = highres
00511         mytmp['interactive'] = interactive
00512         mytmp['overwrite'] = overwrite
00513         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00514         trec = casac.utils().torecord(pathname+'plotms.xml')
00515 
00516         casalog.origin('plotms')
00517         if not trec.has_key('plotms') or not casac.utils().verify(mytmp, trec['plotms']) :
00518             return False
00519 
00520 
00521         try :
00522           casalog.post('')
00523           casalog.post('##########################################')
00524           casalog.post('##### Begin Task: plotms           #####')
00525           casalog.post('')
00526           result = plotms(vis, xaxis, xdatacolumn, yaxis, ydatacolumn, selectdata, field, spw, timerange, uvrange, antenna, scan, correlation, array, observation, msselect, averagedata, avgchannel, avgtime, avgscan, avgfield, avgbaseline, avgantenna, avgspw, scalar, transform, freqframe, restfreq, veldef, shift, extendflag, extcorr, extchannel, iteraxis, xselfscale, yselfscale, customsymbol, symbolshape, symbolsize, symbolcolor, symbolfill, symboloutline, coloraxis, customflaggedsymbol, flaggedsymbolshape, flaggedsymbolsize, flaggedsymbolcolor, flaggedsymbolfill, flaggedsymboloutline, plotrange, title, xlabel, ylabel, showmajorgrid, majorwidth, majorstyle, majorcolor, showminorgrid, minorwidth, minorstyle, minorcolor, plotfile, expformat, highres, interactive, overwrite)
00527           casalog.post('')
00528           casalog.post('##### End Task: plotms           #####')
00529           casalog.post('##########################################')
00530 
00531 
00532 # saveinputs for individule engine has no use
00533 # saveinputs should alos be removed from casa_in_py.py
00534 #
00535 #
00536 #          saveinputs = myf['saveinputs']
00537 #          saveinputs('plotms', 'plotms.last', myparams)
00538 #
00539 #
00540         except Exception, instance:
00541           #print '**** Error **** ',instance
00542           pass
00543 
00544         gc.collect()
00545         return result
00546 #
00547 #
00548 ##
00549 #    def paramgui(self, useGlobals=True):
00550 #        """
00551 #        Opens a parameter GUI for this task.  If useGlobals is true, then any relevant global parameter settings are used.
00552 #        """
00553 #        import paramgui
00554 #
00555 #        a=inspect.stack()
00556 #        stacklevel=0
00557 #        for k in range(len(a)):
00558 #          if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0):
00559 #            stacklevel=k
00560 #            break
00561 #        myf = sys._getframe(stacklevel).f_globals
00562 #
00563 #        if useGlobals:
00564 #            paramgui.setGlobals(myf)
00565 #        else:
00566 #            paramgui.setGlobals({})
00567 #
00568 #        paramgui.runTask('plotms', myf['_ip'])
00569 #        paramgui.setGlobals({})
00570 #
00571 #
00572 #
00573 #
00574     def defaults(self, param=None):
00575         a=inspect.stack()
00576         stacklevel=0
00577         for k in range(len(a)):
00578           if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0):
00579                 stacklevel=k
00580                 break
00581         myf=sys._getframe(stacklevel).f_globals
00582         a = odict()
00583         a['vis']  = ''
00584         a['xaxis']  = ''
00585         a['yaxis']  = ''
00586         a['selectdata']  = True
00587         a['averagedata']  = True
00588         a['transform']  = False
00589         a['extendflag']  = False
00590         a['iteraxis']  = ''
00591         a['customsymbol']  = True
00592         a['coloraxis']  = ''
00593         a['customflaggedsymbol']  = False
00594         a['plotrange']  = [
00595         ]
00596         a['title']  = ''
00597         a['xlabel']  = ''
00598         a['ylabel']  = ''
00599         a['showmajorgrid']  = False
00600         a['showminorgrid']  = False
00601         a['plotfile']  = ''
00602 
00603         a['async']=False
00604         a['xaxis'] = {
00605                     0:{'value':''}, 
00606                     1:odict([{'value':'amp'}, {'xdatacolumn':''}]), 
00607                     2:odict([{'value':'amplitude'}, {'xdatacolumn':''}]), 
00608                     3:odict([{'value':'phase'}, {'xdatacolumn':''}]), 
00609                     4:odict([{'value':'real'}, {'xdatacolumn':''}]), 
00610                     5:odict([{'value':'imag'}, {'xdatacolumn':''}]), 
00611                     6:odict([{'value':'imaginary'}, {'xdatacolumn':''}]), 
00612                     7:{'value':'scan'}, 
00613                     8:{'value':'field'}, 
00614                     9:{'value':'time'}, 
00615                     10:{'value':'time_interval'}, 
00616                     11:{'value':'timeinterval'}, 
00617                     12:{'value':'timeint'}, 
00618                     13:{'value':'spw'}, 
00619                     14:{'value':'channel'}, 
00620                     15:{'value':'chan'}, 
00621                     16:{'value':'frequency'}, 
00622                     17:{'value':'freq'}, 
00623                     18:{'value':'correlation'}, 
00624                     19:{'value':'corr'}, 
00625                     20:{'value':'antenna1'}, 
00626                     21:{'value':'ant1'}, 
00627                     22:{'value':'antenna2'}, 
00628                     23:{'value':'ant2'}, 
00629                     24:{'value':'baseline'}, 
00630                     25:{'value':'uvdist'}, 
00631                     26:{'value':'uvwave'}, 
00632                     27:{'value':'uvdist_l'}, 
00633                     28:{'value':'uvdistl'}, 
00634                     29:{'value':'u'}, 
00635                     30:{'value':'v'}, 
00636                     31:{'value':'w'}, 
00637                     32:{'value':'uwave'}, 
00638                     33:{'value':'vwave'}, 
00639                     34:{'value':'wwave'}, 
00640                     35:{'value':'velocity'}, 
00641                     36:{'value':'vel'}, 
00642                     37:{'value':'wt'}, 
00643                     38:{'value':'weight'}, 
00644                     39:{'value':'imwt'}, 
00645                     40:{'value':'flag'}, 
00646                     41:{'value':'azimuth'}, 
00647                     42:{'value':'elevation'}, 
00648                     43:{'value':'hourang'}, 
00649                     44:{'value':'hourangle'}, 
00650                     45:{'value':'parang'}, 
00651                     46:{'value':'parangle'}, 
00652                     47:{'value':'parallacticangle'}, 
00653                     48:{'value':'antenna'}, 
00654                     49:{'value':'ant'}, 
00655                     50:{'value':'ant-azimuth'}, 
00656                     51:{'value':'ant-elevation'}, 
00657                     52:{'value':'ant-hourang'}, 
00658                     53:{'value':'ant-hourangle'}, 
00659                     54:{'value':'ant-parang'}, 
00660                     55:{'value':'ant-parangle'}, 
00661                     56:{'value':'ant-parallacticangle'}, 
00662                     57:{'value':'row'}, 
00663                     58:{'value':'flagrow'}}
00664         a['yaxis'] = {
00665                     0:{'value':''}, 
00666                     1:odict([{'value':'amp'}, {'ydatacolumn':''}]), 
00667                     2:odict([{'value':'amplitude'}, {'ydatacolumn':''}]), 
00668                     3:odict([{'value':'phase'}, {'ydatacolumn':''}]), 
00669                     4:odict([{'value':'real'}, {'ydatacolumn':''}]), 
00670                     5:odict([{'value':'imag'}, {'ydatacolumn':''}]), 
00671                     6:odict([{'value':'imaginary'}, {'ydatacolumn':''}]), 
00672                     7:{'value':'scan'}, 
00673                     8:{'value':'field'}, 
00674                     9:{'value':'time'}, 
00675                     10:{'value':'time_interval'}, 
00676                     11:{'value':'timeinterval'}, 
00677                     12:{'value':'timeint'}, 
00678                     13:{'value':'spw'}, 
00679                     14:{'value':'channel'}, 
00680                     15:{'value':'chan'}, 
00681                     16:{'value':'frequency'}, 
00682                     17:{'value':'freq'}, 
00683                     18:{'value':'correlation'}, 
00684                     19:{'value':'corr'}, 
00685                     20:{'value':'antenna1'}, 
00686                     21:{'value':'ant1'}, 
00687                     22:{'value':'antenna2'}, 
00688                     23:{'value':'ant2'}, 
00689                     24:{'value':'baseline'}, 
00690                     25:{'value':'uvdist'}, 
00691                     26:{'value':'uvwave'}, 
00692                     27:{'value':'uvdist_l'}, 
00693                     28:{'value':'uvdistl'}, 
00694                     29:{'value':'u'}, 
00695                     30:{'value':'v'}, 
00696                     31:{'value':'w'}, 
00697                     32:{'value':'uwave'}, 
00698                     33:{'value':'vwave'}, 
00699                     34:{'value':'wwave'}, 
00700                     35:{'value':'velocity'}, 
00701                     36:{'value':'vel'}, 
00702                     37:{'value':'wt'}, 
00703                     38:{'value':'imwt'}, 
00704                     39:{'value':'flag'}, 
00705                     40:{'value':'azimuth'}, 
00706                     41:{'value':'elevation'}, 
00707                     42:{'value':'hourang'}, 
00708                     43:{'value':'hourangle'}, 
00709                     44:{'value':'parang'}, 
00710                     45:{'value':'parangle'}, 
00711                     46:{'value':'parallacticangle'}, 
00712                     47:{'value':'antenna'}, 
00713                     48:{'value':'ant'}, 
00714                     49:{'value':'ant-azimuth'}, 
00715                     50:{'value':'ant-elevation'}, 
00716                     51:{'value':'ant-hourang'}, 
00717                     52:{'value':'ant-hourangle'}, 
00718                     53:{'value':'ant-parang'}, 
00719                     54:{'value':'ant-parangle'}, 
00720                     55:{'value':'ant-parallacticangle'}, 
00721                     56:{'value':'row'}, 
00722                     57:{'value':'flagrow'}}
00723         a['selectdata'] = {
00724                     0:odict([{'value':True}, {'field':''}, {'spw':''}, {'timerange':''}, {'uvrange':''}, {'antenna':''}, {'scan':''}, {'correlation':''}, {'array':''}, {'observation':''}, {'msselect':''}]), 
00725                     1:{'value':False}}
00726         a['averagedata'] = {
00727                     0:odict([{'value':True}, {'avgchannel':''}, {'avgtime':''}, {'avgscan':False}, {'avgfield':False}, {'avgbaseline':False}, {'avgantenna':False}, {'avgspw':False}, {'scalar':False}]), 
00728                     1:{'value':False}}
00729         a['transform'] = {
00730                     0:{'value':False}, 
00731                     1:odict([{'value':True}, {'freqframe':''}, {'restfreq':''}, {'veldef':'RADIO'}, {'shift':[0.0, 0.0]}])}
00732         a['extendflag'] = {
00733                     0:{'value':False}, 
00734                     1:odict([{'value':True}, {'extcorr':False}, {'extchannel':False}])}
00735         a['iteraxis'] = {
00736                     0:odict([{'notvalue':''}, {'xselfscale':False}, {'yselfscale':False}])}
00737         a['customsymbol'] = {
00738                     0:odict([{'value':True}, {'symbolshape':'autoscaling'}, {'symbolsize':2}, {'symbolcolor':'0000ff'}, {'symbolfill':'fill'}, {'symboloutline':False}]), 
00739                     1:{'value':False}}
00740         a['customflaggedsymbol'] = {
00741                     0:{'value':False}, 
00742                     1:odict([{'value':True}, {'flaggedsymbolshape':'nosymbol'}, {'flaggedsymbolsize':2}, {'flaggedsymbolcolor':'ff0000'}, {'flaggedsymbolfill':'fill'}, {'flaggedsymboloutline':False}])}
00743         a['plotfile'] = {
00744                     0:odict([{'notvalue':''}, {'expformat':''}, {'highres':False}, {'interactive':False}, {'overwrite':False}])}
00745         a['showmajorgrid'] = {
00746                     0:{'value':False}, 
00747                     1:odict([{'value':True}, {'majorwidth':0}, {'majorstyle':''}, {'majorcolor':''}])}
00748         a['showminorgrid'] = {
00749                     0:{'value':False}, 
00750                     1:odict([{'value':True}, {'minorwidth':0}, {'minorstyle':''}, {'minorcolor':''}])}
00751 
00752 ### This function sets the default values but also will return the list of
00753 ### parameters or the default value of a given parameter
00754         if(param == None):
00755                 myf['__set_default_parameters'](a)
00756         elif(param == 'paramkeys'):
00757                 return a.keys()
00758         else:
00759                 if(a.has_key(param)):
00760                    #if(type(a[param]) == dict) :
00761                    #   return a[param][len(a[param])-1]['value']
00762                    #else :
00763                       return a[param]
00764 
00765 
00766 #
00767 #
00768     def check_params(self, param=None, value=None):
00769       a=inspect.stack() 
00770       stacklevel=0
00771       for k in range(len(a)):
00772         if (string.find(a[k][1], 'ipython console') > 0) or (string.find(a[k][1], '<string>') >= 0):
00773             stacklevel=k
00774             break
00775       myf=sys._getframe(stacklevel).f_globals
00776 
00777 #      print 'param:', param, 'value:', value
00778       try :
00779          if str(type(value)) != "<type 'instance'>" :
00780             value0 = value
00781             value = myf['cu'].expandparam(param, value)
00782             matchtype = False
00783             if(type(value) == numpy.ndarray):
00784                if(type(value) == type(value0)):
00785                   myf[param] = value.tolist()
00786                else:
00787                   #print 'value:', value, 'value0:', value0
00788                   #print 'type(value):', type(value), 'type(value0):', type(value0)
00789                   myf[param] = value0
00790                   if type(value0) != list :
00791                      matchtype = True
00792             else :
00793                myf[param] = value
00794             value = myf['cu'].verifyparam({param:value})
00795             if matchtype:
00796                value = False
00797       except Exception, instance:
00798          #ignore the exception and just return it unchecked
00799          myf[param] = value
00800       return value
00801 
00802 #
00803 #
00804     def description(self, key='plotms', subkey=None):
00805         desc={'plotms': 'A plotter/interactive flagger for visibility data.',
00806                'vis': 'input visibility dataset (blank for none)',
00807                'xaxis': 'plot x-axis (blank for default/current)',
00808                'xdatacolumn': 'data column to use for x-axis (blank for default/current)',
00809                'yaxis': 'plot y-axis (blank for default/current)',
00810                'ydatacolumn': 'data column to use for y-axis (blank for default/current)',
00811                'selectdata': 'data selection parameters',
00812                'field': 'field names or field index numbers (blank for all)',
00813                'spw': 'spectral windows:channels (blank for all)',
00814                'timerange': 'time range (blank for all)',
00815                'uvrange': 'uv range (blank for all)',
00816                'antenna': 'antenna/baselines (blank for all)',
00817                'scan': 'scan numbers (blank for all)',
00818                'correlation': 'correlations (blank for all)',
00819                'array': '(sub)array numbers (blank for all)',
00820                'observation': 'Select by observation ID(s)',
00821                'msselect': 'MS selection (blank for all)',
00822                'averagedata': 'data averaging parameters',
00823                'avgchannel': 'average over channel?  (blank = False, otherwise value in channels)',
00824                'avgtime': 'average over time? (blank = False, other value in seconds)',
00825                'avgscan': 'only valid if time averaging is turned on.  average over scans?',
00826                'avgfield': 'only valid if time averaging is turned on.  average over fields?',
00827                'avgbaseline': 'average over all baselines?  (mutually exclusive with avgantenna)',
00828                'avgantenna': 'average by per-antenna?  (mutually exclusive with avgbaseline)',
00829                'avgspw': 'average over all spectral windows?',
00830                'scalar': 'Do scalar averaging?',
00831                'transform': 'transform data in various ways?',
00832                'freqframe': 'the frame in which to render frequency and velocity axes ',
00833                'restfreq': 'Rest frequency to use for velocity conversions ',
00834                'veldef': 'the definition in which to render velocity ',
00835                'shift': 'Adjust phases by this phase center shift [dx,dy] (arcsec)',
00836                'extendflag': 'have flagging extend to other data points?',
00837                'extcorr': 'extend flags based on correlation? ',
00838                'extchannel': 'extend flags based on channel?',
00839                'iteraxis': 'the axis over which to iterate',
00840                'xselfscale': 'Self-scale X axis in each plot ',
00841                'yselfscale': 'Self-scale Y axis in each plot ',
00842                'customsymbol': 'set a custom symbol for unflagged points',
00843                'symbolshape': 'shape of plotted unflagged symbols',
00844                'symbolsize': 'size of plotted unflagged symbols',
00845                'symbolcolor': 'color of plotted unflagged symbols',
00846                'symbolfill': 'fill type of plotted unflagged symbols',
00847                'symboloutline': 'selects outlining plotted unflagged points',
00848                'coloraxis': 'selects which data to use for colorizing',
00849                'customflaggedsymbol': 'set a custom plot symbol for flagged points',
00850                'flaggedsymbolshape': 'shape of plotted flagged symbols',
00851                'flaggedsymbolsize': 'size of plotted flagged symbols',
00852                'flaggedsymbolcolor': 'color of plotted flagged symbols',
00853                'flaggedsymbolfill': 'fill type of plotted flagged symbols',
00854                'flaggedsymboloutline': 'selects outlining plotted flagged points',
00855                'plotrange': 'plot axes ranges: [xmin,xmax,ymin,ymax]',
00856                'title': 'Title written along top of plot',
00857                'xlabel': 'Text for horizontal axis. Blank for default.',
00858                'ylabel': 'Text for vertical axis. Blank for default.',
00859                'showmajorgrid': 'Show major grid lines (horiz and vert.)',
00860                'majorwidth': 'Line width in pixels of major grid lines',
00861                'majorstyle': 'Major grid line style: solid dash dot none',
00862                'majorcolor': 'Color as name or hex code of major grid lines',
00863                'showminorgrid': 'Show minor grid lines (horiz and vert.)',
00864                'minorwidth': 'Line width in pixels of minor grid lines',
00865                'minorstyle': 'Minor grid line style: solid dash dot none',
00866                'minorcolor': 'Color as name or hex code of minor grid lines',
00867                'plotfile': 'Name of plot file to save automatically.',
00868                'expformat': 'Export format type (jpg, png, ps, pdf, txt), if not provided, plotfile extension will be used.',
00869                'highres': 'Use high resolution? Always true for jpg and png.',
00870                'interactive': 'Interactive mode (pop up confirmation window if true, set false for automated scripts to prevent blocking).',
00871                'overwrite': 'Overwrite plot file if it already exists?',
00872 
00873                'async': 'If true the taskname must be started using plotms(...)'
00874               }
00875 
00876 #
00877 # Set subfields defaults if needed
00878 #
00879 
00880         if(desc.has_key(key)) :
00881            return desc[key]
00882 
00883     def itsdefault(self, paramname) :
00884         a = {}
00885         a['vis']  = ''
00886         a['xaxis']  = ''
00887         a['xdatacolumn']  = ''
00888         a['yaxis']  = ''
00889         a['ydatacolumn']  = ''
00890         a['selectdata']  = True
00891         a['field']  = ''
00892         a['spw']  = ''
00893         a['timerange']  = ''
00894         a['uvrange']  = ''
00895         a['antenna']  = ''
00896         a['scan']  = ''
00897         a['correlation']  = ''
00898         a['array']  = ''
00899         a['observation']  = ''
00900         a['msselect']  = ''
00901         a['averagedata']  = True
00902         a['avgchannel']  = ''
00903         a['avgtime']  = ''
00904         a['avgscan']  = False
00905         a['avgfield']  = False
00906         a['avgbaseline']  = False
00907         a['avgantenna']  = False
00908         a['avgspw']  = False
00909         a['scalar']  = False
00910         a['transform']  = False
00911         a['freqframe']  = ''
00912         a['restfreq']  = ''
00913         a['veldef']  = 'RADIO'
00914         a['shift']  = [0.0, 0.0]
00915         a['extendflag']  = False
00916         a['extcorr']  = False
00917         a['extchannel']  = False
00918         a['iteraxis']  = ''
00919         a['xselfscale']  = False
00920         a['yselfscale']  = False
00921         a['customsymbol']  = True
00922         a['symbolshape']  = 'autoscaling'
00923         a['symbolsize']  = 2
00924         a['symbolcolor']  = '0000ff'
00925         a['symbolfill']  = 'fill'
00926         a['symboloutline']  = False
00927         a['coloraxis']  = ''
00928         a['customflaggedsymbol']  = False
00929         a['flaggedsymbolshape']  = 'nosymbol'
00930         a['flaggedsymbolsize']  = 2
00931         a['flaggedsymbolcolor']  = 'ff0000'
00932         a['flaggedsymbolfill']  = 'fill'
00933         a['flaggedsymboloutline']  = False
00934         a['plotrange']  = [
00935         ]
00936         a['title']  = ''
00937         a['xlabel']  = ''
00938         a['ylabel']  = ''
00939         a['showmajorgrid']  = False
00940         a['majorwidth']  = 1
00941         a['majorstyle']  = ''
00942         a['majorcolor']  = 'B0B0B0'
00943         a['showminorgrid']  = False
00944         a['minorwidth']  = 1
00945         a['minorstyle']  = ''
00946         a['minorcolor']  = 'D0D0D0'
00947         a['plotfile']  = ''
00948         a['expformat']  = ''
00949         a['highres']  = False
00950         a['interactive']  = False
00951         a['overwrite']  = False
00952 
00953         if a.has_key(paramname) :
00954               return a[paramname]
00955 plotms_pg = plotms_pg_()