casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
plotxy_cli.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 casac
00010 import string
00011 import time
00012 import inspect
00013 import gc
00014 import numpy
00015 from odict import odict
00016 from taskmanager import tm
00017 from task_plotxy import plotxy
00018 class plotxy_cli_:
00019     __name__ = "plotxy"
00020     __async__ = {}
00021     rkey = None
00022     i_am_a_casapy_task = None
00023     # The existence of the i_am_a_casapy_task attribute allows help()
00024     # (and other) to treat casapy tasks as a special case.
00025 
00026     def __init__(self) :
00027        self.__bases__ = (plotxy_cli_,)
00028        self.__doc__ = self.__call__.__doc__
00029 
00030        self.parameters={'vis':None, 'xaxis':None, 'yaxis':None, 'datacolumn':None, 'iteration':None, 'selectdata':None, 'antenna':None, 'spw':None, 'field':None, 'uvrange':None, 'timerange':None, 'correlation':None, 'scan':None, 'feed':None, 'array':None, 'averagemode':None, 'width':None, 'timebin':None, 'crossscans':None, 'crossbls':None, 'crossarrays':None, 'stackspw':None, 'restfreq':None, 'frame':None, 'doppler':None, 'extendflag':None, 'extendcorr':None, 'extendchan':None, 'extendspw':None, 'extendant':None, 'extendtime':None, 'subplot':None, 'plotsymbol':None, 'plotcolor':None, 'markersize':None, 'linewidth':None, 'plotrange':None, 'multicolor':None, 'selectplot':None, 'overplot':None, 'newplot':None, 'clearpanel':None, 'skipnrows':None, 'title':None, 'xlabels':None, 'ylabels':None, 'fontsize':None, 'windowsize':None, 'showflags':None, 'interactive':None, 'figfile':None, 'end':None,  'async':None}
00031 
00032 
00033     def result(self, key=None):
00034             #### here we will scan the task-ids in __async__
00035             #### and add any that have completed...
00036             if key is not None and self.__async__.has_key(key) and self.__async__[key] is not None:
00037                ret = tm.retrieve(self.__async__[key])
00038                if ret['state'] == "done" :
00039                   self.__async__[key] = None
00040                elif ret['state'] == 'crashed' :
00041                   self.__async__[key] = None
00042                return ret
00043             return None
00044 
00045 
00046     def __call__(self, vis=None, xaxis=None, yaxis=None, datacolumn=None, iteration=None, selectdata=None, antenna=None, spw=None, field=None, uvrange=None, timerange=None, correlation=None, scan=None, feed=None, array=None, averagemode=None, width=None, timebin=None, crossscans=None, crossbls=None, crossarrays=None, stackspw=None, restfreq=None, frame=None, doppler=None, extendflag=None, extendcorr=None, extendchan=None, extendspw=None, extendant=None, extendtime=None, subplot=None, plotsymbol=None, plotcolor=None, markersize=None, linewidth=None, plotrange=None, multicolor=None, selectplot=None, overplot=None, newplot=None, clearpanel=None, skipnrows=None, title=None, xlabels=None, ylabels=None, fontsize=None, windowsize=None, showflags=None, interactive=None, figfile=None, end=None,  async=None):
00047 
00048         """An X-Y plotter/interactive flagger for visibility data.
00049 
00050         An X-Y plotter/interactive flagger for visibility data. 
00051 
00052              Selected data can be flexibly plotted with a wide variety
00053              of axes and averaging options, including iteration over
00054              antennas and fields.  Data may be listed, flagged or
00055              unflagged interactively.  The plots can be zoomed and
00056              also saved to a file.  
00057 
00058              It is advisable to run flagmanager before using plotxy to
00059              flag data in order to save the current flag state before
00060              altering:
00061              flagmanager(vis='vis_name',mode='save',versionname='before_plotxy',
00062              comment=versionname)
00063 
00064              See hints on using plotxy at the end.
00065 
00066              
00067      Keyword arguments:
00068      vis -- Name of input visibility file
00069              default: none.  example: vis='ngc5921.ms'
00070      xaxis -- Visibility data to plot along the x-axis
00071              default: 'time'
00072 
00073              Options for BOTH x-axis and y-axis
00074                 'time','uvdist','chan', 'corr','freq','velo', 'u','v','w',
00075                 'azimuth','elevation','baseline','hourangle','parallacticangle'
00076                 'amp','phase','real','imag','weight'.  'x' gives antenna array
00077              
00078      yaxis -- Visibility data to plot along the y-axis
00079              default: 'amp'
00080              Options: same as on xaxis:
00081 
00082        >>> yaxis expandable parameter
00083          datacolumn -- Visibility file data column
00084              Note: this parameter is automatically shown whenever the
00085              chosen yaxis is a data quantity (i.e. amp)
00086              default: 'data'; example: datacolumn='model'
00087              Options: 'data' (raw),'corrected','model','residual'(corrected-model)
00088 
00089       --- Data Selection (see help par.selectdata for more detailed information)
00090 
00091      field -- Select field using field id(s) or field name(s).
00092               ['go listobs' to obtain the list id's or names]
00093             default: ''=all fields
00094             If field string is a non-negative integer, it is assumed to
00095                be a field index otherwise, it is assumed to be a field name
00096             field='0~2'; field ids 0,1,2
00097             field='0,4,5~7'; field ids 0,4,5,6,7
00098             field='3C286,3C295'; field named 3C286 and 3C295
00099             field = '3,4C*'; field id 3, all names starting with 4C
00100      spw -- Select spectral window/channels 
00101              spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
00102              spw='<2';  spectral windows less than 2 (i.e. 0,1)
00103              spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE
00104              spw='*:5~61'; all spw with channels 5 to 61
00105              spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45.
00106              spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
00107              spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60
00108                        NOTE ';' to separate channel selections
00109              spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10,
00110                    spw 1, channels 20,25,30
00111      selectdata -- Other data selection parameters
00112             default: True
00113        >>> selectdata expandable parameters
00114          timerange  -- Select data based on time range:
00115             default = '' (all); examples,
00116             timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
00117             Note: if YYYY/MM/DD is missing date defaults to first day in data set
00118             timerange='09:14:0~09:54:0' picks 40 min on first day
00119             timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day
00120             timerange='09:44:00' data within one integration of time
00121             timerange='>10:24:00' data after this time
00122          antenna -- Select data based on antenna/baseline
00123             default: ''=all
00124             If antenna string is a non-negative integer, it is assumed
00125               to be an antenna index, otherwise it is assumed to be an
00126               antenna name
00127             antenna='5&6'; baseline between antenna index 5 and index 6.
00128             antenna='VA05&VA06'; baseline between VLA antenna 5 and 6.
00129             antenna='5&6;7&8'; baseline 5-6 and 7-8
00130             antenna='5'; all baselines with antenna index 5
00131             antenna= '05'; all baselines with antenna named 05
00132             antenna='5,6,9'; all baselines with antennas indices 5,6 and 9
00133          correlation -- Select correlations:
00134             default: '' = all correlations. Other options are any combination
00135                           of values from one of the valid lists:
00136                           'RR','LL','RL','LR','RR LL','RL LR',
00137                           'XX','YY','XY','YX','XX YY','XY YX'
00138          uvrange -- Select data within uvrange (default units meters)
00139             default: ''=all; example:
00140             uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda
00141             uvrange='>4klambda';uvranges greater than 4 kilo-lambda
00142             uvrange='0~1000km'; uvrange in kilometers
00143          scan -- Scan number range
00144          array -- (Sub)-array number range - under development
00145          feed -- Multi-feed number range - under development
00146          
00147      averagemode -- Select average mode
00148             default: 'vector' 
00149             Options: 'vector' = average over real and image part separately.
00150                      'scalar' = scalar average of amplitude, vector
00151                                     average of the phase.
00152                      ''       = no averaging
00153        >>> averagemode expandable parameters
00154          timebin -- length of time intervals to average
00155                   default: '0'= no time averaging
00156                   example: timebin='60' (average over 60 second interval).
00157                   example: timebin='all' (all times obeying other selection
00158                          parameters, i.e. timerange and crossscans)
00159          crossscans -- Have time averaging cross scan boundaries? 
00160               default: False=time averaging does not cross scan boundaries 
00161          crossbls -- Have averaging cross baseline boundaries? 
00162               default: False= averaging does not cross baseline boundaries 
00163          crossarrays -- Have averaging cross array boundaries? 
00164               default: False=averaging does not cross array boundaries 
00165          stackspw -- Stack multiple spw on top of each other?
00166               default: False= layout spws side-by-side for xaxis='channel'
00167          width -- number of channels to average
00168               default: '1'= no channel averaging
00169               example: width='32' (average 32 channels together).
00170               example: width='all' (all channels within each selected spw)
00171               example: width='allspw' (all channels and all spw averaged.)
00172      restfreq -- Set rest frequency or transition name
00173               options: (str) '' a frequency quanta or transition name
00174               default: currently set rest frequency and frame in MS
00175                      see measures for known lines, e.g.
00176                      me.linelist() to list lines
00177                      me.me.spectralline to get frequency
00178               example: restfreq='1420405751.786Hz' 21cm HI frequency
00179                      restfreq='HI'               21cm HI transition name
00180                      restfreq='115.2712GHz'      CO line
00181        >>> restfreq expandable parameters
00182          frame -- frequency frame for spectral axis
00183               options: (str) 'LSRK','REST','TOPO','LSRD','BARY',
00184                        'GEO','GALACTO','LGROUP','CMB'
00185               default: currently set frequency frame in MS
00186                        see measures (me.frequency) for description
00187          doppler -- doppler mode
00188               options: (str) 'RADIO','Z','RATIO','BETA','GAMMA',
00189                        'OPTICAL','TRUE','RELATIVISTIC'
00190               default: currently set doppler system in MS
00191                        see measures (me.doppler) for description
00192      extendflag -- flagging extension parameters
00193          default: False= no extension, only flag selected data; 
00194          example: extendflag=True 
00195        >>> extendflag expandable parameters
00196          extendcorr  -- Extend flagging based on correlation:
00197             default: ''= no correlation based extension
00198             examples:
00199             extendcorr = 'all'
00200             extendcorr = 'half' flags RR and LL
00201          extendchan -- Extend flagging based on channel:
00202             default: ''= no channel based extension
00203             example:
00204             extendchan = 'all'
00205          extendspw -- Extend flagging based on spectral window:
00206             default: '' = no spectral window based extension
00207             example:
00208             extendspw = 'all'
00209          extendant -- Extend flagging based on antenna (baseline):
00210             default: ''= no antenna based extension
00211             example:
00212             extendant = 'all'
00213          extendtime -- Extend flagging based on time:
00214             default: ''= no time based extension
00215             example:
00216             extendant = 'all'
00217      subplot -- Panel number on the display screen
00218             default: 111 (full screen display); example:
00219             if iteration is non-blank, then
00220                subplot=yx1 window will produce y by x plots in the window.
00221             if iteration = '', then
00222                subplot=yxn; means the window will have y rows, and x columns
00223                with the present execution placing the plot in location n
00224                n = 1,..., xy, in order upper left to right, then down.  An
00225                example is the plotting of four fields on one frame
00226                field='0'; subplot=221; plotxy()
00227                field='1'; subplot=222; plotxy()
00228                field='2'; subplot=223; plotxy()
00229                field='3'; subplot=224; plotxy()
00230      overplot -- Overplot on current plot (if possible)
00231             default: False; example: overplot= True
00232      showflags -- Show the flagged and unflagged data.
00233             default: False; example: showflags=True
00234      iteration -- Iterate plots:
00235             default: ''; no iteration
00236             Options: 'field', 'antenna', 'baseline'.
00237             Use the 'NEXT' button on gui to iterate through values.
00238             To abort an iteration, close the gui window.
00239      plotsymbol -- plot symbol. (Options include .:,o^v><s+xDd234hH|_ or
00240                    optionally preceded by one of color code k, r, g, b, c, y) 
00241             default: '.': points, medium-sized dots
00242             example: plotsymbol='bo' (blue points, large-sized dots
00243               r=red, b=blue, g=green, y=yellow
00244               ',' = small points
00245               '.' = medium points
00246               'o' = large points
00247      plotcolor -- color.  Overrides plotsymbol color settings.
00248             default: 'darkcyan'
00249             example: plotcolor='g' (green)
00250                      plotcolor='slateblue'
00251                      plotcolor='#7FFF34' (RGB tuple)
00252      multicolor -- Multi-color plotting of channels and correlations
00253              options: 'none','both','chan','corr'
00254              default: 'corr'; example: multicolor='chan'
00255      plotrange -- Specifies the size of the plot [xmin, xmax, ymin, ymax]
00256             default: [0,0,0,0];  Range is self-selected
00257             example: [0,0,0.00,0.20]  only y axis is specified 
00258             To use a time range (NOTE: somewhat different sytax from timerange
00259                ['22:23:24, 23:42:20', 0.02, 0.20]
00260                The day must be included if the visibility data span more than one day
00261                ['1997/05/09/22:02:00, 1997/05/09/23:00:00', 0.02, 0.20]
00262      selectplot -- Additional plot control parameters
00263             default: False; example: selectplot=true
00264        >>> selectplot expandable parameters
00265          markersize -- Size of the plotted marks
00266             default: 5.0; example: markersize=10.0
00267          linewidth -- Width of plotted lines.
00268             default: 1; example: linewidth=2.0
00269          skipnrows -- # of points to skip
00270             default: 0
00271             example: skipnrows=100 (plots every 100th point)
00272          newplot -- When overplotting, replace the last plot only
00273             default: False; can be useful when doing subplots
00274          clearpanel -- Clear nothing on the plot window, automatically
00275                   clear plotting area, clear the current plot area, or
00276                   clear the whole plot panel.
00277                options: None, Auto, Current, All
00278                default: Auto
00279                example: clearpanel='Current'
00280          title -- Plot title (above plot)
00281             default: ''; example: title='This is my title'
00282          xlabels -- Label for x axis
00283             default: ''; example: xlabels='X Axis'
00284          ylabels -- Label for y axis
00285             default: ''; example: ylabels='Y Axis'
00286          fontsize -- Font size for labels
00287             default: 10; example: fontsize=2
00288          windowsize -- Window size
00289             default: 1.0; not yet implemented
00290          interactive -- turn on/off on screen display
00291             options: True = interactively flag data
00292                      False = direct output to a file without on screen display
00293             default: True;
00294          figfile -- File name to save the plotted figure to.
00295             default: '' = do not save figure; 
00296             example: figfile='myPlot.png' save figure to png file
00297                      figfile='myPlot.txt' append plotted xy to an ascii file
00298          end -- File name to save the plotted figure to.
00299             default: False = do not quit, keep plotting; 
00300             example: end=True no more plotting to do
00301 
00302          Hints on using plotxy (see section 3.4 in cookbook)
00303 
00304          Useful Buttons at bottom left:
00305               5th--magnifying glass.  Click on this,
00306                        left mouse button rectangle drag will zoom
00307                        right mose button rectangle drag will unzoom a certain amount
00308               1st--restore original magnification
00309 
00310          Useful regions just above:
00311               Quit will terminate plotter
00312               Next will go to next plot as specified by iteration
00313               To flag, unflag, locate, you must click 'Mark Region' first
00314                  then make appropriate region(s)
00315                  then click flag, unflag, locate for the desired operation
00316                  plot will then refrest
00317             
00318  
00319         """
00320         if not hasattr(self, "__globals__") or self.__globals__ == None :
00321            self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals
00322         #casac = self.__globals__['casac']
00323         casalog = self.__globals__['casalog']
00324         #casalog = casac.casac.logsink()
00325         self.__globals__['__last_task'] = 'plotxy'
00326         self.__globals__['taskname'] = 'plotxy'
00327         ###
00328         self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__)
00329         ###
00330         ###
00331         #Handle globals or user over-ride of arguments
00332         #
00333         function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults))
00334         useLocalDefaults = False
00335 
00336         for item in function_signature_defaults.iteritems():
00337                 key,val = item
00338                 keyVal = eval(key)
00339                 if (keyVal == None):
00340                         #user hasn't set it - use global/default
00341                         pass
00342                 else:
00343                         #user has set it - use over-ride
00344                         if (key != 'self') :
00345                            useLocalDefaults = True
00346 
00347         myparams = {}
00348         if useLocalDefaults :
00349            for item in function_signature_defaults.iteritems():
00350                key,val = item
00351                keyVal = eval(key)
00352                exec('myparams[key] = keyVal')
00353                self.parameters[key] = keyVal
00354                if (keyVal == None):
00355                    exec('myparams[key] = '+ key + ' = self.itsdefault(key)')
00356                    keyVal = eval(key)
00357                    if(type(keyVal) == dict) :
00358                       if len(keyVal) > 0 :
00359                          exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']')
00360                       else :
00361                          exec('myparams[key] = ' + key + ' = {}')
00362 
00363         else :
00364             async = self.parameters['async']
00365             myparams['vis'] = vis = self.parameters['vis']
00366             myparams['xaxis'] = xaxis = self.parameters['xaxis']
00367             myparams['yaxis'] = yaxis = self.parameters['yaxis']
00368             myparams['datacolumn'] = datacolumn = self.parameters['datacolumn']
00369             myparams['iteration'] = iteration = self.parameters['iteration']
00370             myparams['selectdata'] = selectdata = self.parameters['selectdata']
00371             myparams['antenna'] = antenna = self.parameters['antenna']
00372             myparams['spw'] = spw = self.parameters['spw']
00373             myparams['field'] = field = self.parameters['field']
00374             myparams['uvrange'] = uvrange = self.parameters['uvrange']
00375             myparams['timerange'] = timerange = self.parameters['timerange']
00376             myparams['correlation'] = correlation = self.parameters['correlation']
00377             myparams['scan'] = scan = self.parameters['scan']
00378             myparams['feed'] = feed = self.parameters['feed']
00379             myparams['array'] = array = self.parameters['array']
00380             myparams['averagemode'] = averagemode = self.parameters['averagemode']
00381             myparams['width'] = width = self.parameters['width']
00382             myparams['timebin'] = timebin = self.parameters['timebin']
00383             myparams['crossscans'] = crossscans = self.parameters['crossscans']
00384             myparams['crossbls'] = crossbls = self.parameters['crossbls']
00385             myparams['crossarrays'] = crossarrays = self.parameters['crossarrays']
00386             myparams['stackspw'] = stackspw = self.parameters['stackspw']
00387             myparams['restfreq'] = restfreq = self.parameters['restfreq']
00388             myparams['frame'] = frame = self.parameters['frame']
00389             myparams['doppler'] = doppler = self.parameters['doppler']
00390             myparams['extendflag'] = extendflag = self.parameters['extendflag']
00391             myparams['extendcorr'] = extendcorr = self.parameters['extendcorr']
00392             myparams['extendchan'] = extendchan = self.parameters['extendchan']
00393             myparams['extendspw'] = extendspw = self.parameters['extendspw']
00394             myparams['extendant'] = extendant = self.parameters['extendant']
00395             myparams['extendtime'] = extendtime = self.parameters['extendtime']
00396             myparams['subplot'] = subplot = self.parameters['subplot']
00397             myparams['plotsymbol'] = plotsymbol = self.parameters['plotsymbol']
00398             myparams['plotcolor'] = plotcolor = self.parameters['plotcolor']
00399             myparams['markersize'] = markersize = self.parameters['markersize']
00400             myparams['linewidth'] = linewidth = self.parameters['linewidth']
00401             myparams['plotrange'] = plotrange = self.parameters['plotrange']
00402             myparams['multicolor'] = multicolor = self.parameters['multicolor']
00403             myparams['selectplot'] = selectplot = self.parameters['selectplot']
00404             myparams['overplot'] = overplot = self.parameters['overplot']
00405             myparams['newplot'] = newplot = self.parameters['newplot']
00406             myparams['clearpanel'] = clearpanel = self.parameters['clearpanel']
00407             myparams['skipnrows'] = skipnrows = self.parameters['skipnrows']
00408             myparams['title'] = title = self.parameters['title']
00409             myparams['xlabels'] = xlabels = self.parameters['xlabels']
00410             myparams['ylabels'] = ylabels = self.parameters['ylabels']
00411             myparams['fontsize'] = fontsize = self.parameters['fontsize']
00412             myparams['windowsize'] = windowsize = self.parameters['windowsize']
00413             myparams['showflags'] = showflags = self.parameters['showflags']
00414             myparams['interactive'] = interactive = self.parameters['interactive']
00415             myparams['figfile'] = figfile = self.parameters['figfile']
00416             myparams['end'] = end = self.parameters['end']
00417 
00418 
00419         result = None
00420 
00421 #
00422 #    The following is work around to avoid a bug with current python translation
00423 #
00424         mytmp = {}
00425 
00426         mytmp['vis'] = vis
00427         mytmp['xaxis'] = xaxis
00428         mytmp['yaxis'] = yaxis
00429         mytmp['datacolumn'] = datacolumn
00430         mytmp['iteration'] = iteration
00431         mytmp['selectdata'] = selectdata
00432         mytmp['antenna'] = antenna
00433         mytmp['spw'] = spw
00434         mytmp['field'] = field
00435         mytmp['uvrange'] = uvrange
00436         mytmp['timerange'] = timerange
00437         mytmp['correlation'] = correlation
00438         mytmp['scan'] = scan
00439         mytmp['feed'] = feed
00440         mytmp['array'] = array
00441         mytmp['averagemode'] = averagemode
00442         mytmp['width'] = width
00443         mytmp['timebin'] = timebin
00444         mytmp['crossscans'] = crossscans
00445         mytmp['crossbls'] = crossbls
00446         mytmp['crossarrays'] = crossarrays
00447         mytmp['stackspw'] = stackspw
00448         mytmp['restfreq'] = restfreq
00449         mytmp['frame'] = frame
00450         mytmp['doppler'] = doppler
00451         mytmp['extendflag'] = extendflag
00452         mytmp['extendcorr'] = extendcorr
00453         mytmp['extendchan'] = extendchan
00454         mytmp['extendspw'] = extendspw
00455         mytmp['extendant'] = extendant
00456         mytmp['extendtime'] = extendtime
00457         mytmp['subplot'] = subplot
00458         mytmp['plotsymbol'] = plotsymbol
00459         mytmp['plotcolor'] = plotcolor
00460         mytmp['markersize'] = markersize
00461         mytmp['linewidth'] = linewidth
00462         mytmp['plotrange'] = plotrange
00463         mytmp['multicolor'] = multicolor
00464         mytmp['selectplot'] = selectplot
00465         mytmp['overplot'] = overplot
00466         mytmp['newplot'] = newplot
00467         mytmp['clearpanel'] = clearpanel
00468         mytmp['skipnrows'] = skipnrows
00469         mytmp['title'] = title
00470         mytmp['xlabels'] = xlabels
00471         mytmp['ylabels'] = ylabels
00472         mytmp['fontsize'] = fontsize
00473         mytmp['windowsize'] = windowsize
00474         mytmp['showflags'] = showflags
00475         mytmp['interactive'] = interactive
00476         mytmp['figfile'] = figfile
00477         mytmp['end'] = end
00478         #
00479         # This task is never suppose to use the task manager to run async
00480         #
00481         async=False
00482         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00483         trec = casac.casac.utils().torecord(pathname+'plotxy.xml')
00484 
00485         casalog.origin('plotxy')
00486         try :
00487           #if not trec.has_key('plotxy') or not casac.casac.utils().verify(mytmp, trec['plotxy']) :
00488             #return False
00489 
00490           casac.casac.utils().verify(mytmp, trec['plotxy'], True)
00491           scriptstr=['']
00492           saveinputs = self.__globals__['saveinputs']
00493           saveinputs('plotxy', 'plotxy.last', myparams, self.__globals__,scriptstr=scriptstr)
00494           if async :
00495             count = 0
00496             keybase =  time.strftime("%y%m%d.%H%M%S")
00497             key = keybase + "_" + str(count)
00498             while self.__async__.has_key(key) :
00499                count += 1
00500                key = keybase + "_" + str(count)
00501             result = tm.execute('plotxy', vis, xaxis, yaxis, datacolumn, iteration, selectdata, antenna, spw, field, uvrange, timerange, correlation, scan, feed, array, averagemode, width, timebin, crossscans, crossbls, crossarrays, stackspw, restfreq, frame, doppler, extendflag, extendcorr, extendchan, extendspw, extendant, extendtime, subplot, plotsymbol, plotcolor, markersize, linewidth, plotrange, multicolor, selectplot, overplot, newplot, clearpanel, skipnrows, title, xlabels, ylabels, fontsize, windowsize, showflags, interactive, figfile, end)
00502             print "Use: "
00503             print "      tm.retrieve(return_value) # to retrieve the status"
00504             print 
00505             self.rkey = key
00506             self.__async__[key] = result
00507           else :
00508               tname = 'plotxy'
00509               spaces = ' '*(18-len(tname))
00510               casalog.post('\n##########################################'+
00511                            '\n##### Begin Task: ' + tname + spaces + ' #####')
00512               casalog.post(scriptstr[1][1:]+'\n', 'INFO')
00513               result = plotxy(vis, xaxis, yaxis, datacolumn, iteration, selectdata, antenna, spw, field, uvrange, timerange, correlation, scan, feed, array, averagemode, width, timebin, crossscans, crossbls, crossarrays, stackspw, restfreq, frame, doppler, extendflag, extendcorr, extendchan, extendspw, extendant, extendtime, subplot, plotsymbol, plotcolor, markersize, linewidth, plotrange, multicolor, selectplot, overplot, newplot, clearpanel, skipnrows, title, xlabels, ylabels, fontsize, windowsize, showflags, interactive, figfile, end)
00514               casalog.post('##### End Task: ' + tname + '  ' + spaces + ' #####'+
00515                            '\n##########################################')
00516 
00517         except Exception, instance:
00518           if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) :
00519              raise
00520           else :
00521              #print '**** Error **** ',instance
00522              tname = 'plotxy'
00523              casalog.post('An error occurred running task '+tname+'.', 'ERROR')
00524              pass
00525 
00526         gc.collect()
00527         return result
00528 #
00529 #
00530 #
00531     def paramgui(self, useGlobals=True, ipython_globals=None):
00532         """
00533         Opens a parameter GUI for this task.  If useGlobals is true, then any relevant global parameter settings are used.
00534         """
00535         import paramgui
00536         if not hasattr(self, "__globals__") or self.__globals__ == None :
00537            self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals
00538 
00539         if useGlobals:
00540             if ipython_globals == None:
00541                 myf=self.__globals__
00542             else:
00543                 myf=ipython_globals
00544 
00545             paramgui.setGlobals(myf)
00546         else:
00547             paramgui.setGlobals({})
00548 
00549         paramgui.runTask('plotxy', myf['_ip'])
00550         paramgui.setGlobals({})
00551 
00552 #
00553 #
00554 #
00555     def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None):
00556         if not hasattr(self, "__globals__") or self.__globals__ == None :
00557            self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals
00558         if ipython_globals == None:
00559             myf=self.__globals__
00560         else:
00561             myf=ipython_globals
00562 
00563         a = odict()
00564         a['vis']  = ''
00565         a['xaxis']  = 'time'
00566         a['yaxis']  = 'amp'
00567         a['iteration']  = ''
00568         a['selectdata']  = True
00569         a['spw']  = ''
00570         a['field']  = ''
00571         a['averagemode']  = ''
00572         a['restfreq']  = ''
00573         a['extendflag']  = False
00574         a['subplot']  = 111
00575         a['plotsymbol']  = '.'
00576         a['plotcolor']  = 'darkcyn'
00577         a['plotrange']  = [-1, -1, -1, -1]
00578         a['multicolor']  = 'corr'
00579         a['selectplot']  = False
00580         a['overplot']  = False
00581         a['showflags']  = False
00582         a['interactive']  = True
00583         a['figfile']  = ''
00584         a['end']  = False
00585 
00586         a['async']=False
00587         a['yaxis'] = {
00588                     0:odict([{'value':'amp'}, {'datacolumn':'data'}]), 
00589                     1:odict([{'value':'phase'}, {'datacolumn':'data'}]), 
00590                     2:odict([{'value':'imag'}, {'datacolumn':'data'}]), 
00591                     3:odict([{'value':'real'}, {'datacolumn':'data'}]), 
00592                     4:{'value':'time'}, 
00593                     5:{'value':'uvdist'}, 
00594                     6:{'value':'chan'}, 
00595                     7:{'value':'corr'}, 
00596                     8:{'value':'freq'}, 
00597                     9:{'value':'velo'}, 
00598                     10:{'value':'u'}, 
00599                     11:{'value':'v'}, 
00600                     12:{'value':'w'}, 
00601                     13:{'value':'azimuth'}, 
00602                     14:{'value':'elevation'}, 
00603                     15:{'value':'baseline'}, 
00604                     16:{'value':'hourangle'}, 
00605                     17:{'value':'parallacticangle'}, 
00606                     18:{'value':'weight'}}
00607         a['selectdata'] = {
00608                     0:odict([{'value':True}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'feed':''}, {'array':''}, {'uvrange':''}]), 
00609                     1:{'value':False}}
00610         a['averagemode'] = {
00611                     0:{'value':''}, 
00612                     1:odict([{'value':'vector'}, {'timebin':'0'}, {'crossscans':False}, {'crossbls':False}, {'crossarrays':False}, {'stackspw':False}, {'width':'1'}]), 
00613                     2:odict([{'value':'scalar'}, {'timebin':'0'}, {'crossscans':False}, {'crossbls':False}, {'crossarrays':False}, {'stackspw':False}, {'width':'1'}])}
00614         a['restfreq'] = {
00615                     0:odict([{'notvalue':''}, {'frame':'LSRK'}, {'doppler':'RADIO'}])}
00616         a['extendflag'] = {
00617                     0:{'value':False}, 
00618                     1:odict([{'value':True}, {'extendcorr':''}, {'extendchan':''}, {'extendspw':''}, {'extendant':''}, {'extendtime':''}])}
00619         a['selectplot'] = {
00620                     0:{'value':False}, 
00621                     1:odict([{'value':True}, {'markersize':5.0}, {'linewidth':1.0}, {'skipnrows':1}, {'newplot':False}, {'clearpanel':'Auto'}, {'title':''}, {'xlabels':''}, {'ylabels':''}, {'fontsize':10.0}, {'windowsize':5.0}])}
00622 
00623 ### This function sets the default values but also will return the list of
00624 ### parameters or the default value of a given parameter
00625         if(param == None):
00626                 myf['__set_default_parameters'](a)
00627         elif(param == 'paramkeys'):
00628                 return a.keys()
00629         else:
00630             if(paramvalue==None and subparam==None):
00631                if(a.has_key(param)):
00632                   return a[param]
00633                else:
00634                   return self.itsdefault(param)
00635             else:
00636                retval=a[param]
00637                if(type(a[param])==dict):
00638                   for k in range(len(a[param])):
00639                      valornotval='value'
00640                      if(a[param][k].has_key('notvalue')):
00641                         valornotval='notvalue'
00642                      if((a[param][k][valornotval])==paramvalue):
00643                         retval=a[param][k].copy()
00644                         retval.pop(valornotval)
00645                         if(subparam != None):
00646                            if(retval.has_key(subparam)):
00647                               retval=retval[subparam]
00648                            else:
00649                               retval=self.itsdefault(subparam)
00650                      else:
00651                         retval=self.itsdefault(subparam)
00652                return retval
00653 
00654 
00655 #
00656 #
00657     def check_params(self, param=None, value=None, ipython_globals=None):
00658       if ipython_globals == None:
00659           myf=self.__globals__
00660       else:
00661           myf=ipython_globals
00662 #      print 'param:', param, 'value:', value
00663       try :
00664          if str(type(value)) != "<type 'instance'>" :
00665             value0 = value
00666             value = myf['cu'].expandparam(param, value)
00667             matchtype = False
00668             if(type(value) == numpy.ndarray):
00669                if(type(value) == type(value0)):
00670                   myf[param] = value.tolist()
00671                else:
00672                   #print 'value:', value, 'value0:', value0
00673                   #print 'type(value):', type(value), 'type(value0):', type(value0)
00674                   myf[param] = value0
00675                   if type(value0) != list :
00676                      matchtype = True
00677             else :
00678                myf[param] = value
00679             value = myf['cu'].verifyparam({param:value})
00680             if matchtype:
00681                value = False
00682       except Exception, instance:
00683          #ignore the exception and just return it unchecked
00684          myf[param] = value
00685       return value
00686 #
00687 #
00688     def description(self, key='plotxy', subkey=None):
00689         desc={'plotxy': 'An X-Y plotter/interactive flagger for visibility data.',
00690                'vis': 'Name of input visibility dataset',
00691                'xaxis': 'X-axis: def = \'time\': see help for options',
00692                'yaxis': 'Y-axis: def = \'amp\': see help for options',
00693                'datacolumn': 'data (raw), corrected, model, residual (corrected - model)',
00694                'iteration': 'Plot separate panels by field, antenna, baseline, scan, feed',
00695                'selectdata': 'More data selection parameters (antenna, timerange etc)',
00696                'antenna': 'antenna/baselines: \'\'==>all, antenna = \'3,VA04\'',
00697                'spw': 'Spectral windows:channels: \'\'==>all, spw=\'2:5~57\'',
00698                'field': 'Field names or field index numbers: \'\'==>all, field=\'0~2,3C286\'',
00699                'uvrange': 'uv range: \'\'==>all; uvrange = \'0~100klambda\'',
00700                'timerange': 'time range: \'\'==>all, timerange=\'09:14:0~09:54:0\'',
00701                'correlation': 'correlations: \'\'==>all, correlations=\'RR LL\'',
00702                'scan': 'scan numbers: \'\'==>all',
00703                'feed': 'multi-feed numbers: Not yet implemented',
00704                'array': '(sub)array numbers: \'\'==>all',
00705                'averagemode': 'Select averaging type: \'vector\', \'scalar\'',
00706                'width': 'number of channels to average, default: \'1\', Also: \'all\', \'allspw\'',
00707                'timebin': 'Averaging time in seconds, default=\'0\', also: \'all\'',
00708                'crossscans': 'have time averaging cross over scans?',
00709                'crossbls': 'have averaging cross over baselines?',
00710                'crossarrays': 'have averaging cross over arrays?',
00711                'stackspw': 'stack multiple spw on top of each other?',
00712                'restfreq': 'a frequency quanta or transition name. see help for options',
00713                'frame': 'frequency frame for spectral axis. see help for options',
00714                'doppler': 'doppler mode. see help for options',
00715                'extendflag': 'have flagging extend to other data points?',
00716                'extendcorr': 'extend flags based on correlation: \'\'==> selectdata,\'half\', or \'all\' ',
00717                'extendchan': 'extend flags based on channel: \'\'==> selectdata or \'all\'',
00718                'extendspw': 'extend flags based on spw: \'\'==> selectdata or \'all\'',
00719                'extendant': 'extend flags based on antenna: \'\'==> selectdata or \'all\'',
00720                'extendtime': 'extend flags based on time: \'\'==> selectdata or \'all\'',
00721                'subplot': 'Multipanel display scheme (yxn)',
00722                'plotsymbol': 'Options include . : , o ^ v > < s + x D d 2 3 4 h H | _',
00723                'plotcolor': 'Plot color',
00724                'markersize': 'Size of plotted marks',
00725                'linewidth': 'Width of plotted lines',
00726                'plotrange': 'The range of data to be plotted (see help)',
00727                'multicolor': 'Plot in different colors: Options: none, both, chan, corr',
00728                'selectplot': 'Select additional plotting options (e.g, fontsize, title,etc)',
00729                'overplot': 'Overplot on current plot (if possible)',
00730                'newplot': 'Replace the last plot or not when overplotting',
00731                'clearpanel': 'Specify if old plots are cleared or not',
00732                'skipnrows': 'Plot every nth point',
00733                'title': 'Plot title (above plot)',
00734                'xlabels': 'Label for x-axis',
00735                'ylabels': 'Label for y-axis',
00736                'fontsize': 'Font size for labels',
00737                'windowsize': 'Window size: not yet implemented',
00738                'showflags': 'Show flagged data?',
00739                'interactive': 'Show plot on gui?',
00740                'figfile': '\'\'= no plot hardcopy, otherwise supply name',
00741                'end': 'Quit plotting?',
00742 
00743                'async': 'If true the taskname must be started using plotxy(...)'
00744               }
00745 
00746 #
00747 # Set subfields defaults if needed
00748 #
00749 
00750         if(desc.has_key(key)) :
00751            return desc[key]
00752 
00753     def itsdefault(self, paramname) :
00754         a = {}
00755         a['vis']  = ''
00756         a['xaxis']  = 'time'
00757         a['yaxis']  = 'amp'
00758         a['datacolumn']  = 'data'
00759         a['iteration']  = ''
00760         a['selectdata']  = True
00761         a['antenna']  = ''
00762         a['spw']  = ''
00763         a['field']  = ''
00764         a['uvrange']  = ''
00765         a['timerange']  = ''
00766         a['correlation']  = ''
00767         a['scan']  = ''
00768         a['feed']  = ''
00769         a['array']  = ''
00770         a['averagemode']  = ''
00771         a['width']  = '1'
00772         a['timebin']  = '0'
00773         a['crossscans']  = False
00774         a['crossbls']  = False
00775         a['crossarrays']  = False
00776         a['stackspw']  = False
00777         a['restfreq']  = ''
00778         a['frame']  = ''
00779         a['doppler']  = ''
00780         a['extendflag']  = False
00781         a['extendcorr']  = ''
00782         a['extendchan']  = ''
00783         a['extendspw']  = ''
00784         a['extendant']  = ''
00785         a['extendtime']  = ''
00786         a['subplot']  = 111
00787         a['plotsymbol']  = '.'
00788         a['plotcolor']  = 'darkcyn'
00789         a['markersize']  = 5.0
00790         a['linewidth']  = 1.0
00791         a['plotrange']  = [-1, -1, -1, -1]
00792         a['multicolor']  = 'corr'
00793         a['selectplot']  = False
00794         a['overplot']  = False
00795         a['newplot']  = False
00796         a['clearpanel']  = 'Auto'
00797         a['skipnrows']  = 0
00798         a['title']  = ''
00799         a['xlabels']  = ''
00800         a['ylabels']  = ''
00801         a['fontsize']  = 10.0
00802         a['windowsize']  = 1.0
00803         a['showflags']  = False
00804         a['interactive']  = True
00805         a['figfile']  = ''
00806         a['end']  = False
00807 
00808         #a = sys._getframe(len(inspect.stack())-1).f_globals
00809 
00810         if self.parameters['yaxis']  == 'amp':
00811             a['datacolumn'] = 'data'
00812 
00813         if self.parameters['yaxis']  == 'phase':
00814             a['datacolumn'] = 'data'
00815 
00816         if self.parameters['yaxis']  == 'imag':
00817             a['datacolumn'] = 'data'
00818 
00819         if self.parameters['yaxis']  == 'real':
00820             a['datacolumn'] = 'data'
00821 
00822         if self.parameters['selectdata']  == True:
00823             a['antenna'] = ''
00824             a['timerange'] = ''
00825             a['correlation'] = ''
00826             a['scan'] = ''
00827             a['feed'] = ''
00828             a['array'] = ''
00829             a['uvrange'] = ''
00830 
00831         if self.parameters['averagemode']  == 'vector':
00832             a['timebin'] = '0'
00833             a['crossscans'] = False
00834             a['crossbls'] = False
00835             a['crossarrays'] = False
00836             a['stackspw'] = False
00837             a['width'] = '1'
00838 
00839         if self.parameters['averagemode']  == 'scalar':
00840             a['timebin'] = '0'
00841             a['crossscans'] = False
00842             a['crossbls'] = False
00843             a['crossarrays'] = False
00844             a['stackspw'] = False
00845             a['width'] = '1'
00846 
00847         if self.parameters['restfreq']  != '':
00848             a['frame'] = 'LSRK'
00849             a['doppler'] = 'RADIO'
00850 
00851         if self.parameters['extendflag']  == True:
00852             a['extendcorr'] = ''
00853             a['extendchan'] = ''
00854             a['extendspw'] = ''
00855             a['extendant'] = ''
00856             a['extendtime'] = ''
00857 
00858         if self.parameters['selectplot']  == True:
00859             a['markersize'] = 5.0
00860             a['linewidth'] = 1.0
00861             a['skipnrows'] = 1
00862             a['newplot'] = False
00863             a['clearpanel'] = 'Auto'
00864             a['title'] = ''
00865             a['xlabels'] = ''
00866             a['ylabels'] = ''
00867             a['fontsize'] = 10.0
00868             a['windowsize'] = 5.0
00869 
00870         if a.has_key(paramname) :
00871               return a[paramname]
00872 plotxy_cli = plotxy_cli_()