|
|||
NRAO Home > CASA > CASA Toolkit Reference Manual |
|
tableplot.plotdata - Function
3.2.2 Plot the result of a general TaQL expression.
Description
This function evaluates the specified TaQL expressions for the X and Y
axes of a two-dimensional plot,extracts the resulting columns, and plots
them.
- TaQL expressions resulting in scalars are plotted as a single X-Y plot. Expressions involving Array-Columns can result in arrays which are then plotted as overlays.
- The default mode of operation is to plot one expression against another. In the case of Array-Columns (ex. DATA column of a measurement set with each row containing an array of shape NColumns x NPolarzations), a Cross-plot mode allows plots with the x-axis representing one axes of the Array-Column. (ex. X-axis is channel number or polarization number).
- If multiple tables are specified in tp.open(), then the TaQL expressions are applied to all tables and overlay plots are generated.
- Plots can be made to separate panels whose locations on the plot window are user specified as a 3-tuple [nrows, ncolumns, panelnumber].
- Multiple plots can be stacked upon each other on a panel (overplot mode).
- Plotter options can be specifed to control appearance, plot-style, labels, etc.
Valid TaQL strings must satisfy the following conditions.
-
Each
TaQL
string
must
result
in
a
Double
scalar
or
array.
’AMPLITUDE(DATA[1,1])’ results in a Double scalar (valid).
’AMPLITUDE(DATA[1:2,1])’ results in a Double array (valid).
’MEAN(AMPLITUDE(DATA[1:2,1]))’ results in a Double scalar (valid).
’DATA[1,1]’ results in a Complex scalar (NOT valid).
’AMPLITUDE(DATA[1,1])<10’ results in a Bool scalar (NOT valid). - All TaQL functions resulting in Double Scalars/Arrays are allowed, except for those involving an explicit collapse axis (means,sums,etc..). Note that these functions are different from mean,sum,etc.. which are supported.
-
TaQL
strings
must
be
provided
as
pairs
of
strings,
with
the
X-TaQL
first,
followed
by
the
Y-TaQL.
There
are
3
cases.
X-TaQL - Scalar, Y-TaQL - Scalar (one-to-one single plot)
X-TaQL - Scalar, Y-TaQL - Array (one-to-many overlay plot)
X-TaQL - Array, Y-TaQL - Array (if the shapes are the same, then a one-to-one mapping is done, otherwise only the first X-TaQL result is used for a one-to-many mapping with the Y-TaQL Array.) - For cross plots (for example amplitude vs channel plots in an MS), the X-TaQL must be a string containing ’CROSS’. The Y-TaQL is used to read out the data from the table, and the x-values are the column indices (channel numbers) chosen by the Y-TaQL.
Plotting options (’poption’ entries) are listed below.
Default values are indicated within [ ] when present. nrows [ 1 ] : Number of rows of
panels ncols [ 1 ] : Number of columns of panels panel [ 1 ] : Panel index. Must be in
[1,nrows x ncols] plotcolour [ 1 ] : Plot colour. Codes for matplotlib are [0:black,
1:red, 2:green, 3:blue, 4:cyan, 5:yellow] [magenta is reserved for plotting
flagged values if showflags = 1 , and cannot be set by the user as a plot
colour] If the plotcolour field is left out from ’poption’, colours are chosen
automatically. multicolour [ False ] : True -¿ Each channel,pol appears in a
different colour. False -¿ Data from all pols and channels appear in the same
colour. Different colours appear for different layers (overplot). or data from
different tables. timeplot [ False ] : True -¿ Turn on date/time formatting
for the x-axis. overplot [ False ] : True -¿ Overlay on an existing plot. All
layers will remain active for data editing via flagging. Labels will be those of
the top-most layer. False -¿ Replace an existing plot with a new one. In
the case of an existing stack of plots, the top-most layer is replaced. For
example, this can be used to modify the colour of the top-most layer without
creating an additional layer. py_plotsymbol [ , ] : Plot markers. Options for
matplotlib are [[,]:pixel, [.]:point, [o]:circle, [x]:cross, [+]:plus, [:triangle up,
[v]:triangle down, [¡]:triangle left, [¿]:triangle right, [-]:solid line, [–]:dashed line,
[-.]:dash-dot line, [:]:dotted line, [s]:square, [D]:diamond, [d]:thin diamond,
[1]:tripod down, [2]:tripod up, [3]:tripod left, [4]:tripod right, [h]:hexagon,
[H]:rotated hexagon, [p]:pentagon, [—]:vertical line symbol, [_]:horizontal line
symbol. markersize [ 10.0 ] : The size (in pixels) of the markers being plotted.
Markers are specified by the py_plotsymbol option. For example, ’+’, ’o’, and
’d’ linewidth [ 2.0 ] The width of the lines that are drawn, lines are if the
py_plotsymbol chosen is a line. For example, ’-’, ’–’, and ’:’. plotrange [ ] :
Only data within this specific range of values [xmin,xmax,ymin,ymax] will
be plotted. Default is the data range. showflags [ 0 ] : True -¿ Plot only
unflagged data. False -¿ Plot only flagged data. crossdirection [ False ] :
Applies only with CROSS-plots on table ArrayColumns. False -¿ use column
number as the x-axis (ex. channel no.). True -¿ use row number as the x-axis
(ex. polarization no.). pointlabels [ ] : Data points can be annotated by
supplying a list of labels. If N labels are supplied, the first N data points plotted
will be annotated. (Note that if data is edited via flagging,the points are
relabeled to label the first N points.) windowsize [ 8.0 ] : horizontal size of plot
window (inches) aspectratio [ 0.8 ] : aspect-ratio of the plot window (dx/dy)
fontsize [ 12.0 ] : Font size of title text. Font size of x,y labels are 80% of
this.
Returns true if plotting is successful, false otherwise.
Arguments
Inputs |
| ||
poption |
| Record of plot options
| |
| allowed: | record | |
| Default: | 1 1 6 0.8 1.0
|
|
labels |
| List of strings : Title,Xlabel,Ylabel
| |
| allowed: | stringArray |
|
| Default: |
|
|
datastr |
| List of TaQL strings : X,Y
| |
| allowed: | stringArray |
|
| Default: |
|
|
bool
Example
Plot data amplitude vs uv-distance for two Measurement set tables as a
single panel plot. Operate on channel 1 for Stokes 1 and 2 using the
DATA column.
tp.open(tabnames=[’3c273.ms’,’3c48.ms’])
pop = { ’nrows’:1, ’ncols’:1,’panel’:1}
labels = [’Amplitude vs UVdist’,’uvdist’,’amplitude’]
xystr = [’SQRT(SUMSQUARE(UVW[1:2]))’,’AMPLITUDE(DATA[1,1:2])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
TaQL strings for the above example can also be written as follows.
xystr = [’SQRT(UVW[1]*UVW[1]+UVW[2]*UVW[2])’,’AMPLITUDE(DATA[1,1:2])’]
Example
Multi-panel plotting
# uvdist for pol 1 and chan 1,2 on panel 211
pop = { ’nrows’:2, ’ncols’:1,’panel’:1}
labels = [’Amplitude vs UVdist’,’uvdist’,’amplitude’]
xystr = [’SQRT(SUMSQUARE(UVW[1:2]))’,’AMPLITUDE(DATA[1,1:2])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
# uvdist for pol 2 and chan 1,2 (overplot=1) on panel 211
pop = { ’nrows’:2, ’ncols’:1,’panel’:1, ’overplot’:True}
labels = [’Amplitude vs UVdist’,’uvdist’,’amplitude’]
xystr = [’SQRT(SUMSQUARE(UVW[1:2]))’,’AMPLITUDE(DATA[2,1:2])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
# uv coverage on panel 223
pop = { ’nrows’:2, ’ncols’:2,’panel’:3, ’plotcolour’:4}
labels = [’UV Coverage’,’u’,’v’]
xystr = [’UVW[1]’,’UVW[2]’,’-UVW[1]’,’-UVW[2]’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
# amp(data[1:2,1:10]) vs channel number on panel 224
pop = { ’nrows’:2, ’ncols’:2,’panel’:4, ’plotcolour’:1}
labels = [’Amplitude vs Baseline number’,’baseline number’,’amplitude’]
xystr = [’28*ANTENNA1+ANTENNA2-(ANTENNA1-1)*(ANTENNA1+2)/2’,
’AMPLITUDE(DATA[1:2,1:10])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
Example
Plotting with time formatting
# vistime for 10 chans (timeplot=1)
pop = { ’nrows’:1, ’ncols’:1,’panel’:1,’timeplot’:True}
labels = [’Timeplot’,’time’,’amplitude’]
xystr = [’TIME’,’AMPLITUDE(DATA[1:2,1:10])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
Example
Cross-plots - take in a single TaQL expression involving an ArrayColumn,
and use the column numbers of each Array per row of the table as the x-axis.
In a measurement set, the DATA ArrayColumn contains 2D Arrays, each with
NCHAN columns and NPOL rows. Plotting with ’CROSS’ as the X-TaQL, uses
channel numbers as the x-axis. The option ’crossdirection=True’ can be used
to plot with polarization on the x-axis.
pop = { ’nrows’:2, ’ncols’:1,’panel’:1, ’plotcolour’:2}
labels = [’Amplitude vs Channel number’,’chan’,’amplitude’]
xystr = [’CROSS’,’AMPLITUDE(DATA[1:2,1:10])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
pop = { ’nrows’:2, ’ncols’:1,’panel’:1, ’plotcolour’:2, ’crossdirection’:True}
labels = [’Amplitude vs Polarization number’,’pol’,’amplitude’]
xystr = [’CROSS’,’AMPLITUDE(DATA[1:2,1:10])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
Example
Individual points can be annotated by specifying the ’pointlabels’ parameter.
If N labels are specified, the first N data points to be plotted, are annotated.
pop = {’nrows’:1,’ncols’:1, ’panel’:1, ’plotcolour’:1,’py_plotsymbol’:’o’,
’pointlabels’:[’ A1’,’ A2’,’ A3’,’ A4’,’ A5’,’ A6’,’ A7’,’ A8’,
’ A9’,’ B1’,’ B2’,’ B3’,’ B4’,’ B5’,’ B6’,’ B7’,
’ B8’,’ B9’,’ C1’,’ C2’,’ C3’,’ C4’,’ C5’,’ C6’,
’ C7’,’ C8’,’ C9’,’ D1’,’ D2’,’ D3’,’ D4’]}
xystr = [’POSITION[1]’,’POSITION[2]’]
labels = [’Antenna positions’,’x’,’y’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
Example
To plot with multiple colours for each channel and polarization of an MS.
#(multicolour=1, plotcolour > 5)
pop = { ’nrows’:1, ’ncols’:1,’panel’:1, ’plotcolour’:6,
’showflags’:0, ’multicolour’:True}
labels = [’Amplitude vs UVdist’,’uvdist’,’amplitude’]
xystr = [’SQRT(SUMSQUARE(UVW[1:2]))’,’AMPLITUDE(DATA[1:2,1:2])’]
tp.plotdata(poption=pop,labels=labels,datastr=xystr)
__________________________________________________________________
More information about CASA may be found at the
CASA web page
Copyright © 2016 Associated Universities Inc., Washington, D.C.
This code is available under the terms of the GNU General Public Lincense
Home |
Contact Us |
Directories |
Site Map |
Help |
Privacy Policy |
Search