From CASA Guides
Revision as of 11:18, 4 January 2012 by Jcrossle (talk | contribs)
Jump to: navigation, search

Return to Analysis Utilities

This page documents the plotbandpass function of Python module analysisUtils.

The plotbandpass function provides extended capabilities beyond those of CASA's plotcal. It was written to facilitate rapid visualization of ALMA's bandpass and spectral Tsys measurements in Science Verification and Early Science data, but it can be used on EVLA data as well. It is distributed with the analysisUtils Python module which provides numerous other Python extensions callable from within CASA. Analysis Utilities has been tested on dual-polarization ALMA data, and single-, dual-, and full-polarization EVLA data. The function parameters can always be obtained by giving parameter: help=True. For example,

import analysisUtils as au
$Id:,v 1.118 2011/12/13 20:12:47 thunter Exp $
Usage: plotbandpass(caltable='', antenna='', field='', spw='', yaxis='amp',
   xaxis='chan', figfile='', plotrange=[0,0,0,0], help=False, caltable2='',
   overlay='', showflagged=False, timeranges='', buildpdf=False, caltable3='',
   markersize=3, density=108, interactive=True, showpoints='auto',
   showlines='auto', subplot='22', zoom='', poln='', showatm=False, pwv='1.0',
   gs='gs', convert='convert', chanrange='', debug=False, vm='',
   solutionTimeThresholdSeconds=60.0, phase='')
 antenna: must be ID (int or string or list), or a single antenna name or list
 atm: overlay the atmospheric transmission curve for the weather and elevation
 buildpdf: True/False, if True and figfile is set, assemble pngs into a pdf
 caltable: a bandpass table, of type B or BPOLY
 caltable2: a second cal table, of type BPOLY or B, to overlay on a B table
 caltable3: a third cal table, of type BPOLY, to overlay on the first two
 chanrange: set xrange (e.g. '5~100') over which to autoscale y-axis for xaxis='freq'
 convert: full path for convert command (in case it's not found)
 density: dpi to use in creating PNGs and PDFs (default=108)
 field: must be an ID, source name, or list thereof; can use trailing *: 'J*'
 figfile: the base_name of the png files to save: base_name.antX.spwY.png
 gs: full path for ghostscript command (in case it's not found)
 help: print this message
 interactive: if False, then figfile will run to completion automatically
 overlay: 'antenna' or 'time', make 1 plot with different items in colors
 showflagged:  show the values of data, even if flagged
 markersize: size of points (default=3)
 phase: the y-axis limits to use for phase plots when yaxis='both'
 plotrange: define axis limits: [x0,x1,y0,y1] where 0,0 means auto
 poln: polarizations to plot (e.g. 'XX','YY','RR','LL' or '' for both)
 pwv: define the pwv to use for the showatm option: 'auto' or value in mm
 showatm: compute and overlay the atmospheric transmission curve
 showlines: draw lines connecting the data (default=T for amp, F for phase)
 showpoints: draw points for the data (default=F for amp, T for phase)
 solutionTimeThresholdSeconds: consider 2 solutions simultaneous if within this interval (default=60)
 spw: must be single ID or list or range (e.g. 0~4, not the original ID)
 subplot: 11,22,32 or 42 for rows x columns; options: 11,22,32 or 42 (default=22)
 timeranges: show only these timeranges, the first timerange being 1
 vm: a result from ValueMapping, returned from a previous call
 xaxis: 'chan' or 'freq'
 yaxis: 'amp', 'phase', or 'both' == 'ap'; append 'db' for dB
 zoom: 'intersect' will zoom to overlap region of caltable with caltable2

If help is not True, the return value is the ValueMapping structure for the specified MS.

Regarding the showatm=True parameter, since most people reducing ALMA data do not load the ASDM_CALWVR table into the MS, the atmospheric transmission curve will be computed by default for 1.0 mm, but you can set the PWV to any value using the pwv option. If you want the fully correct curve for ALMA, then copy the CalWVR.xml file from your ASDM to the present working directory and specify pwv='auto' .

Most of the regular CASA list syntax is accepted (commas and tildes) but negation via exclamation point is not supported, nor is channel selection within an spw. You are welcome to submit a ticket to the ALMA helpdesk if you want either of these capabilities. If you find any problems or unexpected behavior, please include the following information in your bug or enhancement request and send to helpdesk:

  1. the version number you are using, which is printed as the first line of output;
  2. the exact command; and
  3. a pointer to the dataset.

How to speed up the performance on large datasets

The plotbandpass function first needs to call ValueMapping to learn about the dataset and create a structure for future reference. If you plan to run the function many times on the same dataset, then you should store the return value of the structure from ValueMapping, like so:

vm = au.ValueMapping(your_ms)

Now, you can pass the result back to plotbandpass via the optional vm argument to avoid having to run ValueMapping inside of plotbandpass each time. It will do a sanity check to see if the MS name in the vm structure matches the MS name stored inside the caltable.

# All subsequent calls to plotbandpass will now run faster, as long as the vm=vm argument is passed.
au.plotbandpass(caltable='bandpass.bcal', vm=vm)

Display a simple bandpass solution

Display different (fixed) y-axis ranges for amplitude and phase

Display a bandpass solution with a BPOLY solution overlaid

Overlay a bandpass solution with a smoothed version created by smoothbandpass

Display a Tsys solution for individual times for one field

Overlay Tsys values for all antennas, one plot per timerange

Overlay Tsys values for all timeranges, one plot per antenna

Overlay Tsys from TDM and interpolated result for FDM

Compute and overlay the atmospheric transmission cure

Clipping off the edge channels