casa
$Rev:20696$
|
00001 import sys 00002 import os 00003 from taskinit import * 00004 00005 def accum(vis=None,tablein=None,incrtable=None,caltable=None,field=None,calfield=None,interp=None,accumtime=None,spwmap=None): 00006 00007 """ Accumulate incremental calibration solutions into a calibration table: 00008 00009 Accum will interpolate and extrapolate a temporal calibration 00010 table onto a new table that has a regularly-space time grid. 00011 00012 The first run of accum defines the time grid and fills this 00013 table with the results from the input table. 00014 00015 Subsequent use of accum will combine additional calibration 00016 tables onto the same grid of the initial accum table to obtain 00017 an output accum table. See below for a concrete example. 00018 00019 Keyword arguments: 00020 vis -- Name of input visibility file 00021 default: none; example: vis='ngc5921.ms' 00022 tablein -- Input cumulative calibration table 00023 ''=> first 00024 in accumtime. Then use output table from previous runs. 00025 accumtime -- Time sampling (sec) of the output table. 00026 Used only if tablein=''. 00027 default: 1.0 00028 example: accumtime=40.0 00029 accumtime ~ data sampling time is recommended 00030 incrtable -- incremental calibration table name 00031 default: none; example: incrtable='ngc5921_phase.gcal' 00032 on first use of accum, incrtable will be 00033 resampled onto caltable with the timescale given 00034 by accumtime 00035 caltable -- Output cumulative calibration table 00036 default: none; example: caltable='ngc5921.Cgcal' 00037 caltable = complex multiplication of incrtable with tablein 00038 tablein and caltable have the same time grid; 00039 incrtable time stamps are arbitrary. 00040 field -- List of field names from tablein to process 00041 default: ''==>all; (most likely) 00042 example: field='0957+561 3C286' 00043 usual syntax for field selection 00044 calfield -- List of field names in incremental table to use. 00045 default: ''==>all; example: calfield='0957*,3C2*' 00046 usual syntax for field selection 00047 interp -- Interpolation mode to use on incremental solutions 00048 default: 'linear'; example: interp='nearest' 00049 'linear' linearly interpolates the amplitude and 00050 phase in incrtable to add to tablein. RECOMMENDED 00051 'nearest' chooses the nearest value in incrtable to 00052 add to tablein 00053 'aipsline' is similar to linear, but does interpolated 00054 real and imaginary parts. NOT RECOMMENDED 00055 spwmap -- Spectral windows combinations to form 00056 default: [-1]; 00057 default means process spws independently 00058 example: spwmap=[0,0,1,1] means apply results from 00059 spw = 0,0,1,1 to spw 0,1,2,3 00060 defaults is equivalent to spwmap = [0,1,2,3] 00061 Example use: Doing a phase cal with short solution interval and then 00062 an amplitude solution on a longer integration time. 00063 00064 First, generate the calibration tables for phase and flux cal 00065 00066 taskname = 'gaincal' 00067 default 00068 cal1 = 'J1335-331,3C286' # phase and flux calibrator 00069 taskname = 'gaincal' 00070 default 00071 vis = '3C219.ms' 00072 gaintype = 'G' 00073 calmode = 'p' # do a phase cal on raw data 00074 caltable = 'phase.cal' # output phase calibration table 00075 field = cal1 # calibrator names 00076 solint = -1 # calibrate each point 00077 refant = 'VA04' # reference antenna 00078 go 00079 00080 calmode = 'ap' # do an amp/phase cal removing first phase cal 00081 caltable = 'amp.cal' # output amplitude calibration table 00082 solint = 0 # solution for each scan 00083 gaincurve = false 00084 opacity =0.0 # no opacity correction 00085 gaintable = 'phase.cal' # First, apply previous phase calibration on the fly 00086 go 00087 00088 taskname = 'fluxscale' # Determine the flux of phase calibrator 00089 default 00090 vis = '3C219.ms' 00091 caltable = 'amp.cal' # amp cal input 00092 fluxtable = 'flux.cal' # calibration table with phase cal flux adjusted 00093 reference = '3C286' # Sources to use as amplitude standard. 00094 # Should have used setjy on these sources 00095 transfer = 'J1335-331' # Sources to be scaled to flux density 00096 go 00097 00098 taskname = 'smoothcal' # Smooth amplitude and phases 00099 vis = '3C219.ms' 00100 tablein = 'flux.cal' 00101 caltable = 'smooth.cal' # smooths amplitude and phase 00102 field = 'J1334-331' # Only smooth phase calibrator 00103 smoothtype = 'median' 00104 smoothtime = 600.0 # Desired smoothing time. Usually contains 00105 # several calibration points 00106 00107 00108 # Define accum table from first phase only cal 00109 taskname = 'accum' 00110 default 00111 vis = '3C219.ms' 00112 tablein = '' # No input table on first run 00113 accumtime = -1 # grid time defaults to sampling time 00114 incrtable = 'phase.cal' # Input phase cal 00115 caltable = 'accum1.cal' # Output accum table with phase cal 00116 field = '' # All sources in phase.cal 00117 interp = 'linear' 00118 go 00119 00120 tablein = accum1.cal' # input is output from above accum run 00121 incrtable = 'amp.cal' # Input amplitude cal 00122 caltable = 'accum2.cal' # Vector produce of tablein and incrtable 00123 field = '' # Determine cal values for all field 00124 calfield = 'J1334-331' # Only interpolate from phase cal 00125 interp = 'linear' 00126 go 00127 00128 # accum2.cal contains the calibration of the raw data. The amplitudes have 00129 # been smooths to 600 seconds, the phases have not. 00130 00131 00132 00133 00134 """ 00135 00136 #Python script 00137 try: 00138 if(tablein != '') : 00139 accumtime=-1.0 00140 00141 if ((type(vis)==str) & (os.path.exists(vis))): 00142 cb.open(filename=vis,compress=False,addcorr=False,addmodel=False) 00143 else: 00144 raise Exception, 'Visibility data set not found - please verify the name' 00145 00146 cb.accumulate(tablein=tablein,incrtable=incrtable,tableout=caltable, 00147 field=field,calfield=calfield,interp=interp,t=accumtime,spwmap=spwmap) 00148 cb.close() 00149 00150 except Exception, instance: 00151 print '*** Error ***',instance 00152 cb.close() 00153 raise Exception, instance 00154