from __future__ import absolute_import
from __future__ import print_function
import sys
import os
from numpy import unique
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import calibrater
_cb = calibrater( )
else:
from taskinit import *
_cb = cbtool( )
def accum(vis=None,tablein=None,incrtable=None,caltable=None,field=None,calfield=None,interp=None,accumtime=None,spwmap=None):
""" Accumulate incremental calibration solutions into a calibration table:
Accum will interpolate and extrapolate a temporal calibration
table onto a new table that has a regularly-space time grid.
The first run of accum defines the time grid and fills this
table with the results from the input table.
Subsequent use of accum will combine additional calibration
tables onto the same grid of the initial accum table to obtain
an output accum table. See below for a concrete example.
Keyword arguments:
vis -- Name of input visibility file
default: none; example: vis='ngc5921.ms'
tablein -- Input cumulative calibration table
''=> first
in accumtime. Then use output table from previous runs.
accumtime -- Time sampling (sec) of the output table.
Used only if tablein=''.
default: 1.0
example: accumtime=40.0
accumtime ~ data sampling time is recommended
incrtable -- incremental calibration table name
default: none; example: incrtable='ngc5921_phase.gcal'
on first use of accum, incrtable will be
resampled onto caltable with the timescale given
by accumtime
caltable -- Output cumulative calibration table
default: none; example: caltable='ngc5921.Cgcal'
caltable = complex multiplication of incrtable with tablein
tablein and caltable have the same time grid;
incrtable time stamps are arbitrary.
field -- List of field names from tablein to process
default: ''==>all; (most likely)
example: field='0957+561 3C286'
usual syntax for field selection
calfield -- List of field names in incremental table to use.
default: ''==>all; example: calfield='0957*,3C2*'
usual syntax for field selection
interp -- Interpolation mode to use on incremental solutions
default: 'linear'; example: interp='nearest'
'linear' linearly interpolates the amplitude and
phase in incrtable to add to tablein. RECOMMENDED
'nearest' chooses the nearest value in incrtable to
add to tablein
'aipsline' is similar to linear, but does interpolated
real and imaginary parts. NOT RECOMMENDED
spwmap -- Spectral windows combinations to form
default: [-1];
default means process spws independently
example: spwmap=[0,0,1,1] means apply results from
spw = 0,0,1,1 to spw 0,1,2,3
defaults is equivalent to spwmap = [0,1,2,3]
Example use: Doing a phase cal with short solution interval and then
an amplitude solution on a longer integration time.
First, generate the calibration tables for phase and flux cal
taskname = 'gaincal'
default
cal1 = 'J1335-331,3C286' # phase and flux calibrator
taskname = 'gaincal'
default
vis = '3C219.ms'
gaintype = 'G'
calmode = 'p' # do a phase cal on raw data
caltable = 'phase.cal' # output phase calibration table
field = cal1 # calibrator names
solint = -1 # calibrate each point
refant = 'VA04' # reference antenna
go
calmode = 'ap' # do an amp/phase cal removing first phase cal
caltable = 'amp.cal' # output amplitude calibration table