casa
$Rev:20696$
|
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_plotxy 00013 def plotxy(vis='', xaxis='time', yaxis='amp', datacolumn='data', iteration='', selectdata=True, antenna='', spw='', field='', uvrange='', timerange='', correlation='', scan='', feed='', array='', averagemode='', width='1', timebin='0', crossscans=False, crossbls=False, crossarrays=False, stackspw=False, restfreq='', frame='', doppler='', extendflag=False, extendcorr='', extendchan='', extendspw='', extendant='', extendtime='', subplot=111, plotsymbol='.', plotcolor='darkcyn', markersize=5.0, linewidth=1.0, plotrange=[-1, -1, -1, -1], multicolor='corr', selectplot=False, overplot=False, newplot=False, clearpanel='Auto', skipnrows=0, title='', xlabels='', ylabels='', fontsize=10.0, windowsize=1.0, showflags=False, interactive=True, figfile='', end=False): 00014 00015 """An X-Y plotter/interactive flagger for visibility data. 00016 00017 An X-Y plotter/interactive flagger for visibility data. 00018 00019 Selected data can be flexibly plotted with a wide variety 00020 of axes and averaging options, including iteration over 00021 antennas and fields. Data may be listed, flagged or 00022 unflagged interactively. The plots can be zoomed and 00023 also saved to a file. 00024 00025 It is advisable to run flagmanager before using plotxy to 00026 flag data in order to save the current flag state before 00027 altering: 00028 flagmanager(vis='vis_name',mode='save',versionname='before_plotxy', 00029 comment=versionname) 00030 00031 See hints on using plotxy at the end. 00032 00033 00034 Keyword arguments: 00035 vis -- Name of input visibility file 00036 default: none. example: vis='ngc5921.ms' 00037 xaxis -- Visibility data to plot along the x-axis 00038 default: 'time' 00039 00040 Options for BOTH x-axis and y-axis 00041 'time','uvdist','chan', 'corr','freq','velo', 'u','v','w', 00042 'azimuth','elevation','baseline','hourangle','parallacticangle' 00043 'amp','phase','real','imag','weight'. 'x' gives antenna array 00044 00045 yaxis -- Visibility data to plot along the y-axis 00046 default: 'amp' 00047 Options: same as on xaxis: 00048 00049 >>> yaxis expandable parameter 00050 datacolumn -- Visibility file data column 00051 Note: this parameter is automatically shown whenever the 00052 chosen yaxis is a data quantity (i.e. amp) 00053 default: 'data'; example: datacolumn='model' 00054 Options: 'data' (raw),'corrected','model','residual'(corrected-model) 00055 00056 --- Data Selection (see help par.selectdata for more detailed information) 00057 00058 field -- Select field using field id(s) or field name(s). 00059 ['go listobs' to obtain the list id's or names] 00060 default: ''=all fields 00061 If field string is a non-negative integer, it is assumed to 00062 be a field index otherwise, it is assumed to be a field name 00063 field='0~2'; field ids 0,1,2 00064 field='0,4,5~7'; field ids 0,4,5,6,7 00065 field='3C286,3C295'; field named 3C286 and 3C295 00066 field = '3,4C*'; field id 3, all names starting with 4C 00067 spw -- Select spectral window/channels 00068 spw='0~2,4'; spectral windows 0,1,2,4 (all channels) 00069 spw='<2'; spectral windows less than 2 (i.e. 0,1) 00070 spw='0:5~61'; spw 0, channels 5 to 61, INCLUSIVE 00071 spw='*:5~61'; all spw with channels 5 to 61 00072 spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45. 00073 spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each. 00074 spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60 00075 NOTE ';' to separate channel selections 00076 spw='0:0~10^2,1:20~30^5'; spw 0, channels 0,2,4,6,8,10, 00077 spw 1, channels 20,25,30 00078 selectdata -- Other data selection parameters 00079 default: True 00080 >>> selectdata expandable parameters 00081 timerange -- Select data based on time range: 00082 default = '' (all); examples, 00083 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00084 Note: if YYYY/MM/DD is missing date defaults to first day in data set 00085 timerange='09:14:0~09:54:0' picks 40 min on first day 00086 timerange= '25:00:00~27:30:00' picks 1 hr to 3 hr 30min on next day 00087 timerange='09:44:00' data within one integration of time 00088 timerange='>10:24:00' data after this time 00089 antenna -- Select data based on antenna/baseline 00090 default: ''=all 00091 If antenna string is a non-negative integer, it is assumed 00092 to be an antenna index, otherwise it is assumed to be an 00093 antenna name 00094 antenna='5&6'; baseline between antenna index 5 and index 6. 00095 antenna='VA05&VA06'; baseline between VLA antenna 5 and 6. 00096 antenna='5&6;7&8'; baseline 5-6 and 7-8 00097 antenna='5'; all baselines with antenna index 5 00098 antenna= '05'; all baselines with antenna named 05 00099 antenna='5,6,9'; all baselines with antennas indices 5,6 and 9 00100 correlation -- Select correlations: 00101 default: '' = all correlations. Other options are any combination 00102 of values from one of the valid lists: 00103 'RR','LL','RL','LR','RR LL','RL LR', 00104 'XX','YY','XY','YX','XX YY','XY YX' 00105 uvrange -- Select data within uvrange (default units meters) 00106 default: ''=all; example: 00107 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 00108 uvrange='>4klambda';uvranges greater than 4 kilo-lambda 00109 uvrange='0~1000km'; uvrange in kilometers 00110 scan -- Scan number range 00111 array -- (Sub)-array number range - under development 00112 feed -- Multi-feed number range - under development 00113 00114 averagemode -- Select average mode 00115 default: 'vector' 00116 Options: 'vector' = average over real and image part separately. 00117 'scalar' = scalar average of amplitude, vector 00118 average of the phase. 00119 '' = no averaging 00120 >>> averagemode expandable parameters 00121 timebin -- length of time intervals to average 00122 default: '0'= no time averaging 00123 example: timebin='60' (average over 60 second interval). 00124 example: timebin='all' (all times obeying other selection 00125 parameters, i.e. timerange and crossscans) 00126 crossscans -- Have time averaging cross scan boundaries? 00127 default: False=time averaging does not cross scan boundaries 00128 crossbls -- Have averaging cross baseline boundaries? 00129 default: False= averaging does not cross baseline boundaries 00130 crossarrays -- Have averaging cross array boundaries? 00131 default: False=averaging does not cross array boundaries 00132 stackspw -- Stack multiple spw on top of each other? 00133 default: False= layout spws side-by-side for xaxis='channel' 00134 width -- number of channels to average 00135 default: '1'= no channel averaging 00136 example: width='32' (average 32 channels together). 00137 example: width='all' (all channels within each selected spw) 00138 example: width='allspw' (all channels and all spw averaged.) 00139 restfreq -- Set rest frequency or transition name 00140 options: (str) '' a frequency quanta or transition name 00141 default: currently set rest frequency and frame in MS 00142 see measures for known lines, e.g. 00143 me.linelist() to list lines 00144 me.me.spectralline to get frequency 00145 example: restfreq='1420405751.786Hz' 21cm HI frequency 00146 restfreq='HI' 21cm HI transition name 00147 restfreq='115.2712GHz' CO line 00148 >>> restfreq expandable parameters 00149 frame -- frequency frame for spectral axis 00150 options: (str) 'LSRK','REST','TOPO','LSRD','BARY', 00151 'GEO','GALACTO','LGROUP','CMB' 00152 default: currently set frequency frame in MS 00153 see measures (me.frequency) for description 00154 doppler -- doppler mode 00155 options: (str) 'RADIO','Z','RATIO','BETA','GAMMA', 00156 'OPTICAL','TRUE','RELATIVISTIC' 00157 default: currently set doppler system in MS 00158 see measures (me.doppler) for description 00159 extendflag -- flagging extension parameters 00160 default: False= no extension, only flag selected data; 00161 example: extendflag=True 00162 >>> extendflag expandable parameters 00163 extendcorr -- Extend flagging based on correlation: 00164 default: ''= no correlation based extension 00165 examples: 00166 extendcorr = 'all' 00167 extendcorr = 'half' flags RR and LL 00168 extendchan -- Extend flagging based on channel: 00169 default: ''= no channel based extension 00170 example: 00171 extendchan = 'all' 00172 extendspw -- Extend flagging based on spectral window: 00173 default: '' = no spectral window based extension 00174 example: 00175 extendspw = 'all' 00176 extendant -- Extend flagging based on antenna (baseline): 00177 default: ''= no antenna based extension 00178 example: 00179 extendant = 'all' 00180 extendtime -- Extend flagging based on time: 00181 default: ''= no time based extension 00182 example: 00183 extendant = 'all' 00184 subplot -- Panel number on the display screen 00185 default: 111 (full screen display); example: 00186 if iteration is non-blank, then 00187 subplot=yx1 window will produce y by x plots in the window. 00188 if iteration = '', then 00189 subplot=yxn; means the window will have y rows, and x columns 00190 with the present execution placing the plot in location n 00191 n = 1,..., xy, in order upper left to right, then down. An 00192 example is the plotting of four fields on one frame 00193 field='0'; subplot=221; plotxy() 00194 field='1'; subplot=222; plotxy() 00195 field='2'; subplot=223; plotxy() 00196 field='3'; subplot=224; plotxy() 00197 overplot -- Overplot on current plot (if possible) 00198 default: False; example: overplot= True 00199 showflags -- Show the flagged and unflagged data. 00200 default: False; example: showflags=True 00201 iteration -- Iterate plots: 00202 default: ''; no iteration 00203 Options: 'field', 'antenna', 'baseline'. 00204 Use the 'NEXT' button on gui to iterate through values. 00205 To abort an iteration, close the gui window. 00206 plotsymbol -- plot symbol. (Options include .:,o^v><s+xDd234hH|_ or 00207 optionally preceded by one of color code k, r, g, b, c, y) 00208 default: '.': points, medium-sized dots 00209 example: plotsymbol='bo' (blue points, large-sized dots 00210 r=red, b=blue, g=green, y=yellow 00211 ',' = small points 00212 '.' = medium points 00213 'o' = large points 00214 plotcolor -- color. Overrides plotsymbol color settings. 00215 default: 'darkcyan' 00216 example: plotcolor='g' (green) 00217 plotcolor='slateblue' 00218 plotcolor='#7FFF34' (RGB tuple) 00219 multicolor -- Multi-color plotting of channels and correlations 00220 options: 'none','both','chan','corr' 00221 default: 'corr'; example: multicolor='chan' 00222 plotrange -- Specifies the size of the plot [xmin, xmax, ymin, ymax] 00223 default: [0,0,0,0]; Range is self-selected 00224 example: [0,0,0.00,0.20] only y axis is specified 00225 To use a time range (NOTE: somewhat different sytax from timerange 00226 ['22:23:24, 23:42:20', 0.02, 0.20] 00227 The day must be included if the visibility data span more than one day 00228 ['1997/05/09/22:02:00, 1997/05/09/23:00:00', 0.02, 0.20] 00229 selectplot -- Additional plot control parameters 00230 default: False; example: selectplot=true 00231 >>> selectplot expandable parameters 00232 markersize -- Size of the plotted marks 00233 default: 5.0; example: markersize=10.0 00234 linewidth -- Width of plotted lines. 00235 default: 1; example: linewidth=2.0 00236 skipnrows -- # of points to skip 00237 default: 0 00238 example: skipnrows=100 (plots every 100th point) 00239 newplot -- When overplotting, replace the last plot only 00240 default: False; can be useful when doing subplots 00241 clearpanel -- Clear nothing on the plot window, automatically 00242 clear plotting area, clear the current plot area, or 00243 clear the whole plot panel. 00244 options: None, Auto, Current, All 00245 default: Auto 00246 example: clearpanel='Current' 00247 title -- Plot title (above plot) 00248 default: ''; example: title='This is my title' 00249 xlabels -- Label for x axis 00250 default: ''; example: xlabels='X Axis' 00251 ylabels -- Label for y axis 00252 default: ''; example: ylabels='Y Axis' 00253 fontsize -- Font size for labels 00254 default: 10; example: fontsize=2 00255 windowsize -- Window size 00256 default: 1.0; not yet implemented 00257 interactive -- turn on/off on screen display 00258 options: True = interactively flag data 00259 False = direct output to a file without on screen display 00260 default: True; 00261 figfile -- File name to save the plotted figure to. 00262 default: '' = do not save figure; 00263 example: figfile='myPlot.png' save figure to png file 00264 figfile='myPlot.txt' append plotted xy to an ascii file 00265 end -- File name to save the plotted figure to. 00266 default: False = do not quit, keep plotting; 00267 example: end=True no more plotting to do 00268 00269 Hints on using plotxy (see section 3.4 in cookbook) 00270 00271 Useful Buttons at bottom left: 00272 5th--magnifying glass. Click on this, 00273 left mouse button rectangle drag will zoom 00274 right mose button rectangle drag will unzoom a certain amount 00275 1st--restore original magnification 00276 00277 Useful regions just above: 00278 Quit will terminate plotter 00279 Next will go to next plot as specified by iteration 00280 To flag, unflag, locate, you must click 'Mark Region' first 00281 then make appropriate region(s) 00282 then click flag, unflag, locate for the desired operation 00283 plot will then refrest 00284 00285 00286 """ 00287 00288 # 00289 # The following is work around to avoid a bug with current python translation 00290 # 00291 mytmp = {} 00292 00293 mytmp['vis'] = vis 00294 mytmp['xaxis'] = xaxis 00295 mytmp['yaxis'] = yaxis 00296 mytmp['datacolumn'] = datacolumn 00297 mytmp['iteration'] = iteration 00298 mytmp['selectdata'] = selectdata 00299 mytmp['antenna'] = antenna 00300 mytmp['spw'] = spw 00301 mytmp['field'] = field 00302 mytmp['uvrange'] = uvrange 00303 mytmp['timerange'] = timerange 00304 mytmp['correlation'] = correlation 00305 mytmp['scan'] = scan 00306 mytmp['feed'] = feed 00307 mytmp['array'] = array 00308 mytmp['averagemode'] = averagemode 00309 mytmp['width'] = width 00310 mytmp['timebin'] = timebin 00311 mytmp['crossscans'] = crossscans 00312 mytmp['crossbls'] = crossbls 00313 mytmp['crossarrays'] = crossarrays 00314 mytmp['stackspw'] = stackspw 00315 mytmp['restfreq'] = restfreq 00316 mytmp['frame'] = frame 00317 mytmp['doppler'] = doppler 00318 mytmp['extendflag'] = extendflag 00319 mytmp['extendcorr'] = extendcorr 00320 mytmp['extendchan'] = extendchan 00321 mytmp['extendspw'] = extendspw 00322 mytmp['extendant'] = extendant 00323 mytmp['extendtime'] = extendtime 00324 mytmp['subplot'] = subplot 00325 mytmp['plotsymbol'] = plotsymbol 00326 mytmp['plotcolor'] = plotcolor 00327 mytmp['markersize'] = markersize 00328 mytmp['linewidth'] = linewidth 00329 mytmp['plotrange'] = plotrange 00330 mytmp['multicolor'] = multicolor 00331 mytmp['selectplot'] = selectplot 00332 mytmp['overplot'] = overplot 00333 mytmp['newplot'] = newplot 00334 mytmp['clearpanel'] = clearpanel 00335 mytmp['skipnrows'] = skipnrows 00336 mytmp['title'] = title 00337 mytmp['xlabels'] = xlabels 00338 mytmp['ylabels'] = ylabels 00339 mytmp['fontsize'] = fontsize 00340 mytmp['windowsize'] = windowsize 00341 mytmp['showflags'] = showflags 00342 mytmp['interactive'] = interactive 00343 mytmp['figfile'] = figfile 00344 mytmp['end'] = end 00345 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00346 trec = casac.utils().torecord(pathname+'plotxy.xml') 00347 00348 casalog.origin('plotxy') 00349 if trec.has_key('plotxy') and casac.utils().verify(mytmp, trec['plotxy']) : 00350 result = task_plotxy.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) 00351 00352 else : 00353 result = False 00354 return result