casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
plotms.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_plotms
00013 def plotms(vis='', xaxis='', xdatacolumn='', yaxis='', ydatacolumn='', selectdata=True, field='', spw='', timerange='', uvrange='', antenna='', scan='', correlation='', array='', observation='', msselect='', averagedata=True, avgchannel='', avgtime='', avgscan=False, avgfield=False, avgbaseline=False, avgantenna=False, avgspw=False, scalar=False, transform=False, freqframe='', restfreq='', veldef='RADIO', shift=[0.0, 0.0], extendflag=False, extcorr=False, extchannel=False, iteraxis='', xselfscale=False, yselfscale=False, customsymbol=True, symbolshape='autoscaling', symbolsize=2, symbolcolor='0000ff', symbolfill='fill', symboloutline=False, coloraxis='', customflaggedsymbol=False, flaggedsymbolshape='nosymbol', flaggedsymbolsize=2, flaggedsymbolcolor='ff0000', flaggedsymbolfill='fill', flaggedsymboloutline=False, plotrange=[
00014         ], title='', xlabel='', ylabel='', showmajorgrid=False, majorwidth=1, majorstyle='', majorcolor='B0B0B0', showminorgrid=False, minorwidth=1, minorstyle='', minorcolor='D0D0D0', plotfile='', expformat='', highres=False, interactive=False, overwrite=False):
00015 
00016         """A plotter/interactive flagger for visibility data.
00017 
00018             Task for plotting and interacting with visibility data.  A variety
00019         of axes choices (including data column) along with MS selection and
00020         averaging options are provided for data selection.  Flag extension
00021         parameters are also available for flagging operations in the plotter.
00022         
00023             All of the provided parameters can also be set using the GUI once
00024         the application has been launched.  Additional and more specific
00025         operations are available through the GUI and/or through the plotms
00026         tool (pm).
00027         
00028 
00029     Keyword arguments:
00030     vis -- input visibility dataset
00031            default: ''
00032     xaxis, yaxis -- what to plot on the two axes
00033                     default: '' (defaults are xaxis='time',
00034                                  yaxis='amp' on first execution;
00035                                  thereafter the most recent
00036                                  settings are used)
00037               valid options (=indicates valid synonyms): 
00038                MS Ids and other meta info:
00039                  'scan'   (number)
00040                  'field'  (index)
00041                  'time',  
00042                  'interval'='timeint'='timeinterval'='time_interval'
00043                  'spw'    (index)
00044                  'chan'='channel'    (index)  
00045                  'freq'='frequency'  (GHz)
00046                  'vel'='velocity'   (km/s)
00047                  'corr'='correlation'  (index)
00048                  'ant1'='antenna1'   (index)
00049                  'ant2'='antenna2'   (index)
00050                  'baseline'  (a baseline index) 
00051                  'row'  (absoute row Id from the MS)
00052                Visibility values, flags:
00053                  'amp'='amplitude'
00054                  'phase'  (deg)
00055                  'real'  
00056                  'imag'='imaginary'
00057                  'wt'='weight'
00058                  'flag'
00059                  'flagrow'
00060                Observational geometry:
00061                  'uvdist'  (meters)
00062                  'uvwave'='uvdistl'='uvdist_l'  (wavelengths, per channel)
00063                  'u'  (meters)
00064                  'v'  (meters)
00065                  'w'  (meters)
00066                  'uwave'  ('u' in wavelengths, per channel)
00067                  'vwave'  ('v' in wavelengths, per channel)
00068                  'wwave'  ('w' in wavelengths, per channel)
00069                  'azimuth'  (at array reference; degrees)
00070                  'elevation'  (at array reference; degrees)
00071                  'hourang'='hourangle'  (at array reference; hours)
00072                  'parang'='parangle'='parallacticangle'  (at array reference; degrees)
00073                Antenna-based (only works vs. data Ids):
00074                  'ant'='antenna'
00075                  'ant-azimuth' 
00076                  'ant-elevation'
00077                  'ant-parang'='ant-parangle'
00078 
00079       >>> xaxis, yaxis expandable parameters
00080         xdatacolumn, 
00081         ydatacolumn  -- which data column to use for Visibility values:
00082                         default: '' ('data' on first execuation;
00083                                      thereafter the most recent
00084                                      setting is used)
00085                         valid options:  'data'      (observed)
00086                                         'corrected'='corr'
00087                                         'model'
00088                                         'residual'  (corrected - model)
00089     
00090     selectdata -- data selection parameters flag
00091                   default: True  (reveals data selection parameters
00092                                   described below)
00093                   Consult listobs output for data selection values,
00094                   and see help par.selectdata for more detailed 
00095                   information on syntax; also, visit
00096                   http://casa.nrao.edu/other_doc.shtml and click
00097                   on "Measurement Set selection syntax" for more
00098                   tips on using data selection parameters in CASA)
00099 
00100       >>> selectdata expandable parameters:
00101 
00102       field -- Select field using field id(s) or field name(s).
00103               default: ''=all fields
00104               If field string is a non-negative integer, it is assumed a
00105                 field index,  otherwise, it is assumed a field name
00106               field='0~2'; field ids 0,1,2
00107               field='0,4,5~7'; field ids 0,4,5,6,7
00108               field='3C286,3C295'; field named 3C286 and 3C295
00109               field = '3,4C*'; field id 3, all names starting with 4C
00110       spw -- Select spectral window/channels
00111                type 'help par.selection' for more examples.
00112              spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
00113              spw='<2';  spectral windows less than 2 (i.e. 0,1)
00114              spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE
00115              spw='*:5~61'; all spw with channels 5 to 61
00116              spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45.
00117              spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
00118              spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60
00119                        NOTE ';' to separate channel selections
00120 
00121       timerange  -- Select data based on time range:
00122               default = '' (all); examples,
00123               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
00124               Note: if YYYY/MM/DD is missing date defaults to first day in data set
00125               timerange='09:14:0~09:54:0' picks 40 min on first day
00126               timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on NEXT day
00127               timerange='09:44:00' pick data within one integration of time
00128               timerange='>10:24:00' data after this time
00129       uvrange -- Select data within uvrange (default units meters)
00130               default: '' (all); example:
00131               uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda
00132               uvrange='>4klambda';uvranges greater than 4 kilo lambda
00133 
00134       antenna -- Select data based on antenna/baseline
00135               default: '' (all, including auto-correlations, if present)
00136               If antenna string is a non-negative integer, it is assumed an
00137                 antenna index, otherwise, it is assumed as an antenna name
00138               antenna='5&6'; baseline between antenna index 5 and index 6.
00139               antenna='!ea02'; exclude EVLA antenna 2.
00140               antenna='ea13;!ea22'; EVLA antenna 13, excluding antenna 22.
00141               antenna='VA05&VA06'; baseline between VLA antenna 5 and 6.
00142               antenna='5&6;7&8'; baselines with indices 5-6 and 7-8
00143               antenna='5'; all baselines with antenna index 5
00144               antenna='05'; all baselines with antenna number 05 (VLA old name)
00145               antenna='5,6,10'; all baselines with antennas 5,6,10 index numbers
00146               NB: For explicit selections, use a single ampersand (&) to
00147               select only cross-correlations among the specified antennas, 
00148               double ampersands (&&) to select cross- and
00149               auto-correlations among the specified antennas, and
00150               triple ampersands (&&&) to select only
00151               auto-correlations.  E.g.:
00152               antenna='*&'; selects all cross-correlation baseline
00153                             (excludes all auto-correlations)
00154               antenna='*&&&'; selects all auto-correlation baselines
00155                               (excludes all cross-correlations)
00156               antenna='1&&1,2,3'; selects baselines 1-1 (auto), 1-2,1-3 (cross)
00157               antenna='VA05&&&'; selects the VA05 autocorrelation
00158               See the link noted above for more information.
00159       scan -- Scan numbers or ranges.
00160               default: ''  (all scans)
00161               scan='1,2,6,43'; scans 1, 2, 6, and 43
00162               scan='3~14'; scans 3 through 14, inclusive
00163       correlation -- Select by correlation
00164                      default: ''  (all correlations)
00165                      options: 'RR','RL','LR','LL','XX','XY','YX','YY',
00166                                or any comma-separated combination; use
00167                                basis (R/L or X/Y) appropriate to the MS)
00168       array -- Select the array id
00169                default: ''  (all array ids)
00170       observation Select by observation ID(s).
00171                   default: ''-->all;
00172                   example: observation='0' (select obsID 0)
00173       msselect -- Optional TaQL data selection
00174 
00175     averagedata -- data averaing parameters flag
00176                    default: True   (reveals expandable parameters
00177                                     described below)
00178       >>> averagedata expandable parameters
00179         avgchannel -- average over channel?  either blank for none, or a value
00180                       in channels.
00181                       default: '' (no channel averaging).
00182         avgtime -- average over time?  either blank for none, or a value in
00183                    seconds.
00184                    default: '' (no time averaging).
00185         avgscan -- average over scans?  only valid if time averaging is turned
00186                    on.
00187                    default: False.
00188         avgfield -- average over fields?  only valid if time averaging is
00189                     turned on.
00190                     default: False.
00191         avgbaseline -- average over selected baselines; mutually 
00192                        exclusive with avgantenna.
00193                        default: False.  (no averaging over baseline)
00194         avgantenna -- form per-antenna averages; mutually exclusive with
00195                       avgbaseline.
00196                       default: False.   (no per-antenna averaging)
00197         avgspw -- average over selected spectral windows?
00198                   default: False.  (no average of spectral windows)
00199         scalar -- scalar averaging?
00200                   default: False  (i.e., do vector averaging)
00201     
00202     transform -- apply various transformations on data for plotting
00203                  default: False.
00204       >>> transform expandable parameters
00205         freqframe -- the coordinate frame in which to render frequency and velocity axes
00206                  default: ''  (unspecified: will use frame in which data were taken)
00207                  options: TOPO, GEO, BARY, LSRK, LSRD
00208         restfreq -- the rest frequency to use in velocity conversions (MHz)
00209                  default: '' (use spw central frequency and show relative velocity)
00210                  example: '22235.08MHz'
00211         veldef -- the velocity definition to use
00212                  default: 'RADIO'
00213                  options: 'RADIO','OPT','TRUE'
00214         shift -- adjust phase according to a phase center shift [dx,dy] (arcsec)
00215                  default: [0,0]  (no shift)
00216 
00217     extendflag -- have flagging extend to other data points?
00218                   default: False.
00219       >>> extendflag expandable parameters
00220         extcorr -- extend flags based on correlation? 
00221                    default: False.
00222         extchannel -- extend flags based on channel?
00223 
00224     iteraxis -- axis upon which iterate plots (one plot per page, for now)
00225                 default: '' (no iteration)
00226                 options: 'scan','field','spw','baseline','antenna',''
00227       >>> iteraxis expandable parameters
00228         xselfscale -- If true, self-scale each iterated plot on the x axis
00229         yselfscale -- If true, self-scale each iterated plot on the y axis
00230                       default: false, which will scale all plots globally
00231 
00232     customsymbol -- If true, use a custom symbol for drawing unflagged points
00233                     default: True
00234       >>> customsymbol expandable parameters
00235         symbolshape -- If true, use a custom shape to draw unflagged symbols
00236                        default: 'autoscaling' (ignores symbolsize)
00237                        options: 'autoscaling', 'circle', 'square', 'diamond', 'pixel', 'nosymbol'
00238         symbolsize -- size of the unflagged symbols in pixels
00239                       default: 2
00240         symbolcolor -- color to use for unflagged symbols; can be a RGB hex code or a color name
00241                        default: '0000ff'
00242                        example: 'purple'
00243         symbolfill -- type of fill to use for unflagged symbols
00244                       default: 'fill'
00245                       options: 'fill', 'mesh1', 'mesh2', 'mesh3', 'nofill'
00246         symboloutline -- If true, outline unflagged symbols in black
00247 
00248     coloraxis -- axis upon which to colorize the plotted points
00249                 options (= indicates synonyms):
00250                     'scan',  'field',  'spw',  'antenna1'='ant1',  'antenna2'='ant2',
00251                     'baseline',  'channel'='chan',  'corr'='correlation'
00252                 default: ''  (use a single color for all points)
00253 
00254     customflaggedsymbol -- If true, use a custom symbol for drawing flagged points
00255                            default: False
00256       >>> customflaggedsymbol expandable parameters
00257         symbolshape -- If true, use a custom shape to draw flagged symbols
00258                        default: 'nosymbol'
00259                        options: 'autoscaling', 'circle', 'square', 'diamond', 'pixel', 'nosymbol'
00260         symbolsize -- size of the flagged symbols in pixels
00261                       default: 2
00262         symbolcolor -- color to use for flagged symbols; can be a RGB hex code or a color name
00263                        default: '0000ff'
00264                        example: 'purple'
00265         symbolfill -- type of fill to use for flagged symbols
00266                       default: 'fill'
00267                       options: 'fill', 'mesh1', 'mesh2', 'mesh3', 'nofill'
00268         symboloutline -- If true, outline flagged symbols in black
00269 
00270     plotrange -- manual plot axis ranges: [xmin,xmax,ymin,ymax]
00271                  Does not affect data selection.
00272                  default: []; both axes will be autoscaled according
00273                  to the ranges found in the selected data
00274                  If xmin=xmax (or ymin=ymax) then that axis will
00275                  be autoscaled, e.g.:
00276                  [0,0,-2.0,14.0]; autoscale the xaxis, and use 
00277                                   ymin=-2.0, ymax=14.0
00278 
00279     title  -- title along top of plot (called "canvas" in some places)
00280     
00281     xlabel -- text to label horizontal axis, with formatting using '%%' 
00282     ylabel -- text to label horizontal axis, with formatting using '%%' 
00283     
00284     showmajorgrid  -- show major grid lines (horiz and vert.)
00285                   default: False.
00286       >>>  major grid expandable parameters
00287         majorwidth  -- line width in pixels of major grid lines
00288         majorstyle  -- major grid line style: solid dash dot none
00289         majorcolor  -- color in hex code of major grid lines
00290 
00291     showminorgrid  -- show minor grid lines (horiz and vert.)
00292                   default: False.
00293       >>>  minor grid expandable parameters
00294         minorwidth  --  line width in pixels of minor grid lines
00295         minorstyle  --  minor grid line style: solid dash dot none
00296         minorcolor  --  color in hex code of minor grid lines
00297 
00298     plotfile -- name of plot file to save automatically
00299                 default: ''  (i.e., draw an interactive plot in the gui)
00300       >>> plotfile expandable parameters
00301         expformat -- export format type; if 'txt' is used an ASCII dump of the plotted points is generated (also available in the export tab)
00302                      default:  ''   (plotfile extension will be used)
00303                      options: 'jpg', 'png', 'ps', 'pdf', 'txt'
00304         highres -- use high resolution? Always true for jpg and png.
00305                    default: false
00306         interactive  -- interactive mode? (pop up confirmation window)
00307                         default: false (e.g., for automated scripts to prevent blocking).
00308         overwrite -- Overwrite plot file if it already exists?
00309                      default: false
00310 
00311 
00312 
00313         """
00314         if type(shift)==float: shift=[shift]
00315         if type(plotrange)==float: plotrange=[plotrange]
00316 
00317 #
00318 #    The following is work around to avoid a bug with current python translation
00319 #
00320         mytmp = {}
00321 
00322         mytmp['vis'] = vis
00323         mytmp['xaxis'] = xaxis
00324         mytmp['xdatacolumn'] = xdatacolumn
00325         mytmp['yaxis'] = yaxis
00326         mytmp['ydatacolumn'] = ydatacolumn
00327         mytmp['selectdata'] = selectdata
00328         mytmp['field'] = field
00329         mytmp['spw'] = spw
00330         mytmp['timerange'] = timerange
00331         mytmp['uvrange'] = uvrange
00332         mytmp['antenna'] = antenna
00333         mytmp['scan'] = scan
00334         mytmp['correlation'] = correlation
00335         mytmp['array'] = array
00336         mytmp['observation'] = observation
00337         mytmp['msselect'] = msselect
00338         mytmp['averagedata'] = averagedata
00339         mytmp['avgchannel'] = avgchannel
00340         mytmp['avgtime'] = avgtime
00341         mytmp['avgscan'] = avgscan
00342         mytmp['avgfield'] = avgfield
00343         mytmp['avgbaseline'] = avgbaseline
00344         mytmp['avgantenna'] = avgantenna
00345         mytmp['avgspw'] = avgspw
00346         mytmp['scalar'] = scalar
00347         mytmp['transform'] = transform
00348         mytmp['freqframe'] = freqframe
00349         mytmp['restfreq'] = restfreq
00350         mytmp['veldef'] = veldef
00351         mytmp['shift'] = shift
00352         mytmp['extendflag'] = extendflag
00353         mytmp['extcorr'] = extcorr
00354         mytmp['extchannel'] = extchannel
00355         mytmp['iteraxis'] = iteraxis
00356         mytmp['xselfscale'] = xselfscale
00357         mytmp['yselfscale'] = yselfscale
00358         mytmp['customsymbol'] = customsymbol
00359         mytmp['symbolshape'] = symbolshape
00360         mytmp['symbolsize'] = symbolsize
00361         mytmp['symbolcolor'] = symbolcolor
00362         mytmp['symbolfill'] = symbolfill
00363         mytmp['symboloutline'] = symboloutline
00364         mytmp['coloraxis'] = coloraxis
00365         mytmp['customflaggedsymbol'] = customflaggedsymbol
00366         mytmp['flaggedsymbolshape'] = flaggedsymbolshape
00367         mytmp['flaggedsymbolsize'] = flaggedsymbolsize
00368         mytmp['flaggedsymbolcolor'] = flaggedsymbolcolor
00369         mytmp['flaggedsymbolfill'] = flaggedsymbolfill
00370         mytmp['flaggedsymboloutline'] = flaggedsymboloutline
00371         mytmp['plotrange'] = plotrange
00372         mytmp['title'] = title
00373         mytmp['xlabel'] = xlabel
00374         mytmp['ylabel'] = ylabel
00375         mytmp['showmajorgrid'] = showmajorgrid
00376         mytmp['majorwidth'] = majorwidth
00377         mytmp['majorstyle'] = majorstyle
00378         mytmp['majorcolor'] = majorcolor
00379         mytmp['showminorgrid'] = showminorgrid
00380         mytmp['minorwidth'] = minorwidth
00381         mytmp['minorstyle'] = minorstyle
00382         mytmp['minorcolor'] = minorcolor
00383         mytmp['plotfile'] = plotfile
00384         mytmp['expformat'] = expformat
00385         mytmp['highres'] = highres
00386         mytmp['interactive'] = interactive
00387         mytmp['overwrite'] = overwrite
00388         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00389         trec = casac.utils().torecord(pathname+'plotms.xml')
00390 
00391         casalog.origin('plotms')
00392         if trec.has_key('plotms') and casac.utils().verify(mytmp, trec['plotms']) :
00393             result = task_plotms.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)
00394 
00395         else :
00396           result = False
00397         return result