This example7.1originates from Misty Lavigne and Stuart Vogel and uses a dataset taken in hybrid passband mode in order to calibrate the phase offsets between the different bands. This is often the case when a single ``narrow band'' is not able to catch the velocity range of the object of interest, in the current correlator galaxies appear to be the primary victim of this.
It assumes that a relatively bright quasar has been observed in the following modes:
Some further comments:
There are various other assumptions in the procedure below that almost never apply exactly to your data. We also assume that the data have been properly flagged and that self cal solutions are good, and that the reference antenna is a proper choice. The script also assumes only one visibility calibrator.
The script first sets a few parameters, but note that some of these parameters (e.g. superwidechan, narrowline) depend on the specific correlator mode that was choosen.
set vis = alldata.vis # visibility file
set refant = 10 # reference antenna
set cal = 3C273 # passband calibrator
set viscal = 1058+015 # visibility (phase) calibrator
set fluxcal = 3C273 # flux calibrator
set source = N3627 # source
set nb_array = ( 4 5 6 ) # spectral line bands to calibrate
set wide_array = ( 5 4 5 ) # hybrid band with wide setup
# For each element in nb_array, the
# corresponding element in wide_array
# should be the hybrid band that is wideband
set superwidewin = 4,5 # windows to use for super-wideband
set superwidechan = 1,1,30 # Channels for superwide
set bw = 64 # Spectral Line bandwidth
set wideline = 1,3,11,11 # line type for 500 MHz
set narrowline = 1,3,58,58 # line type for narrow band
set sideband = usb # Sideband (used for noise conjugation)
set calint = 0.2 # passband calibration interval (minutes)
set vcalint = 30 # visibility calibrator cal interval
set fcalint = 30 # flux calibrator interval
set ampcalint = 30 # selfcal amplitude interval
set flux = 18 # flux of flux calibrator (SMA or Woojin)
set visflux = 5.1 # flux of vlisibility calibrator, calculated from fluxcal.csh
set order = 1 # polynomial order for smamfcal fit
set edge = 3 # of edge channels to discard in smamfcal
set badants = 2,15 # bad antennas to flag
# Do heavy uvflagging prior to script
set badchan1 = 6,61,1,1 # bad overlap channels between 1st 2 bands
set badchan2 = 6,124,1,1 # bad overlap channels between 2nd 2 bands
set restfreq = 115.271203 # rest frequency of line
set gv=ghostview # your postscript viewer
Although you very most likely will have inspected the visibility data and perhaps had to flag bad data in time, frequency and/or baseline/antennae space, here is a simple example to flag two antennas:
uvflag vis=$vis select=ant'('$badants')' flagval=flag
Select the bands
# Select all-wideband and all-narrowband data
rm -rf all.wide all.nb $cal.wide* $cal.nb* $cal.hyb*
bwsel vis=$vis bw=500,500,500 nspect=6 out=all.wide
bwsel vis=$vis bw=$bw,$bw,$bw nspect=6 out=all.nb
# First get super-wideband on passband calibrator and phase calibrator
rm -rf $cal.wide $cal.wide.0 $viscal.v.wide $viscal.v.wide.0
uvcat vis=all.wide out=$cal.wide.0 \
"select=-auto,source($cal),win($superwidewin)" options=nocal,nopass
uvcat vis=all.wide out=$cal.wide.1 \
"select=-auto,source($cal)" options=nocal,nopass
uvcat vis=all.wide out=$viscal.v.wide.0 \
"select=-auto,source($viscal)" options=nocal,nopass
Run mfcal on the superwideband (500/500/500) data. Don't bother using the noise source for the superwideband. Inspect the antenna based solutions in both frequency and time.
mfcal vis=$cal.wide.0 interval=$calint refant=$refant
# Inspect super-wideband passband
gpplt vis=$cal.wide.0 options=bandpass yaxis=phase nxy=4,4 yrange=-360,360 device=bp$cal.wide.0.ps/ps
$gv bp$cal.wide.0.ps
# Inspect temporal phase variation on superwideband
gpplt vis=$cal.wide.0 yaxis=phase yrange=-360,360 nxy=4,4 device=p$cal.wide.0.ps/ps
$gv p$cal.wide.0.ps
# Apply superwideband passband for later use in band offset cal
gpcopy vis=$cal.wide.0 out=$cal.wide.1
uvcat vis=$cal.wide.1 out=$cal.wide options=nocal
# Copy wideband passband to visibility calibrator
gpcopy vis=$cal.wide.0 out=$viscal.v.wide.0 options=nocal,nopol
uvcat vis=$viscal.v.wide.0 out=$viscal.v.wide options=nocal
# Determine phase gain variations on visibility calibrator using superwide
rm -rf $viscal.v.wide.sw $viscal.v.wide.sw.test
uvcat vis=$viscal.v.wide out=$viscal.v.wide.sw select='win('$superwidewin')'
uvcat vis=$viscal.v.wide out=$viscal.v.wide.sw.test select='win('$superwidewin')'
selfcal vis=$viscal.v.wide.sw.test interval=0.1 refant=$refant
gpplt vis=$viscal.v.wide.sw.test yaxis=phase yrange=-360,360 device=testphase.ps/ps nxy=4,4
$gv testphase.ps
selfcal vis=$viscal.v.wide.sw line=channel,$superwidechan \
interval=$vcalint options=phase refant=$refant
echo "**** Phases on the superwideband visibility calibrator $viscal.v.wide.sw"
gpplt vis=$viscal.v.wide.sw device=p$viscal.v.wide.sw.ps/ps yaxis=phase yrange=-360,360 nxy=4,4
$gv p$viscal.v.wide.sw.ps
Checking the phase calibrator:does it look like a nice point source. Notice we don't use mosaicing here, since it is a point source, though for extended sources you will want to use that option in invert when the source is mapped.
rm -rf $viscal.v.wide.sw.mp $viscal.v.wide.sw.bm $viscal.v.wide.sw.cl $viscal.v.wide.sw.r
invert vis=$viscal.v.wide.sw cell=0.5 imsize=257 line=chan,$superwidechan \
map=$viscal.v.wide.sw.mp beam=$viscal.v.wide.sw.bm options=system,double sup=0
set rms = `histo in=$viscal.v.wide.sw.mp | grep Rms | awk '{print$4}'`
clean map=$viscal.v.wide.sw.mp beam=$viscal.v.wide.sw.bm out=$viscal.v.wide.sw.cl \
niters=1000 cutoff=$rms
restor map=$viscal.v.wide.sw.mp beam=$viscal.v.wide.sw.bm model=$viscal.v.wide.sw.cl \
out=$viscal.v.wide.sw.r
cgdisp in=$viscal.v.wide.sw.r,$viscal.v.wide.sw.r nxy=1,1 range=-.5,2,lin,3 \
region=quart device=$viscal.ps/ps cols1=1 \
type=grey,cont slev=p,5 levs1=50,15,10,5,-5 \
options=full,noepoch,beambl csize=1,1 labtyp=arcsec
$gv $viscal.ps
For flux calibration, we offer two methods, depending if the flux calibrator is the same as the passband calibrator. At the end ask the user if the phasecal gains are acceptable and need to be applied later
if ($cal == $fluxcal) then
rm -r $cal.wide.gain $viscal.v.wide.sw.gain $viscal.v.wide.sw.gain.applied
# Calculating Gains on Fluxcal
uvcat vis=$cal.wide.1 out=$cal.wide.gain options=nocal "select=win($superwidewin)"
selfcal vis=$cal.wide.gain refant=$refant interval=$fcalint "select=source($fluxcal)" \
options=noscale,amplitude flux=$flux
gplist vis=$cal.wide.gain options=zeropha,amp > $fluxcal.gains
less $fluxcal.gains
# Calculating Gains on Phasecal
uvcat vis=$viscal.v.wide out=$viscal.v.wide.sw.gain select='win('$superwidewin')'
selfcal vis=$viscal.v.wide.sw.gain interval=$vcalint \
refant=$refant options=noscale,amp flux=$visflux
gplist vis=$viscal.v.wide.sw.gain options=zeropha,amp > $viscal.gains
less $viscal.gains
else
rm -r $viscal.v.wide.sw.gain $fluxcal.wide.0 $fluxcal.wide.gain $fluxcal.gains $viscal.gains
# Fluxcal different from Pbcal"
uvcat vis=all.wide out=$fluxcal.wide.0 \
"select=-auto,source($fluxcal)" options=nocal,nopass
# Passband correcting Fluxcal"
gpcopy vis=$cal.wide.0 out=$fluxcal.wide.0 options=nocal,nopol
uvcat vis=$fluxcal.wide.0 out=$fluxcal.wide.gain options=nocal "select=win($superwidewin)"
# Calculating Gains on Fluxcal
selfcal vis=$fluxcal.wide.gain refant=$refant interval=$fcalint "select=source($fluxcal)" \
options=noscale,amplitude flux=$flux
gplist vis=$fluxcal.wide.gain options=zeropha,amp > $fluxcal.gains
less $fluxcal.gains
# Calculating Gains on Phasecal
uvcat vis=$viscal.v.wide out=$viscal.v.wide.sw.gain select='win('$superwidewin')'
selfcal vis=$viscal.v.wide.sw.gain line=channel,$superwidechan \
interval=$vcalint options=phase refant=$refant
selfcal vis=$viscal.v.wide.sw.gain interval=$ampcalint \
refant=$refant options=noscale,amp flux=$visflux
gplist vis=$viscal.v.wide.sw.gain options=zeropha,amp > $viscal.gains
less $viscal.gains
endif
# now ask the user if this should be applied later
echo -n "Apply Phasecal Gains to data? (y or n): " ; set apply_gains=$<
Loop over each of the narrow bands and assemble the hybrid data
set nblength = $#nb_array
set list=(`awk "BEGIN{for(i=1;i<=$nblength;i++)print i}"`)
# start nb loop
foreach i ( $list )
set nb = $nb_array[$i]
set wide = $wide_array[$i]
rm -r all.hyb
# Select hybrid data
# NB: assumes only 1 band is in wideband mode; if two bands are in wideband
# mode, change hybrid selection to select on nb and modify bw=
if ( $wide == 1 || $wide == 4 ) then
if ($nb == 2 || $nb == 5) then
bwsel vis=$vis nspect=6 bw=500,$bw,0 out=all.hyb
else
bwsel vis=$vis nspect=6 bw=500,0,$bw out=all.hyb
endif
endif
if ( $wide == 2 || $wide == 5 ) then
if ($nb == 1 || $nb == 4) then
bwsel vis=$vis nspect=6 bw=$bw,500,0 out=all.hyb
else
bwsel vis=$vis nspect=6 bw=0,500,$bw out=all.hyb
endif
endif
if ( $wide == 3 || $wide == 6 ) then
if ($nb == 1 || $nb == 4) then
bwsel vis=$vis nspect=6 bw=$bw,0,500 out=all.hyb
else
bwsel vis=$vis nspect=6 bw=0,$bw,500 out=all.hyb
endif
endif
Two sanity tests to make sure you have data and that the bands are present.
set test = `uvio vis=all.hyb | grep -i source | awk '{if (NR==1) print $4}'`
if ($test == "") then
echo
echo "FATAL! There appears to be no valid data in all.hyb"
echo "This is likely to be because wide_array[$i] = $wide is not valid"
echo "(i.e. band $wide is not really wideband), or one of the other "
echo "bands is not really narrowband. Use uvindex to sort this out"
exit 1
endif
uvlist vis=all.hyb options=spectra
Now we need to select single bands to process in this pass Select by source and band. First get the two bands in all-wideband mode Note that we use super-wideband calibrated file for the wide mode.
rm -rf $cal.win$nb* $cal.win$wide* $cal.wide.win$wide* $cal.wide.win$nb* rm -rf $cal.hyb.win$nb* $cal.hyb.win$wide* noise.nb.win$nb* uvcat vis=$cal.wide out=$cal.wide.win$wide "select=-auto,source($cal),win($wide)" \ options=nocal,nopass uvcat vis=$cal.wide out=$cal.wide.win$nb "select=-auto,source($cal),win($nb)" \ options=nocal,nopass # select hybrid wideband band uvcat vis=all.hyb out=$cal.hyb.win$wide.0 "select=-auto,source($cal),win($wide)" \ options=nocal,nopass # select the hybrid and all-narrowband narrow bands # nb bands require extra step (applying noise source) # we did not bother with noise source for wideband uvcat vis=all.hyb out=$cal.hyb.win$nb.00 "select=-auto,source($cal),win($nb)" \ options=nocal,nopass uvcat vis=all.nb out=$cal.nb.win$nb.00 "select=-auto,source($cal),win($nb)" \ options=nocal,nopass # copy wideband passband determined from all-wideband mode to hybrid wideband gpcopy vis=$cal.wide.0 out=$cal.hyb.win$wide.0 options=nocal,nopol uvcat vis=$cal.hyb.win$wide.0 out=$cal.hyb.win$wide options=nocal
Now get the noise source data. Use the noise source data obtained in all narrowband mode, and assume it also can be applied to hybrid narrowband.
if ($sideband == "USB" || $sideband == "usb" ) then
rm -rf noise.lsb noise.usb
@ lsbnb = $nb - 3
uvcat vis=all.nb out=noise.lsb "select=-auto,source(NOISE),win($lsbnb)" \
options=nocal,nopass
uvcat vis=all.nb out=noise.usb "select=-auto,source(NOISE),win($nb)" \
options=nocal,nopass
set sdf = `uvio vis=noise.usb | grep sdf | grep DATA | awk '{print $5}'`
set sfreq = `uvio vis=noise.usb | grep sfreq | grep DATA | awk '{if (NR==1) print $5}'`
uvcal vis=noise.lsb out=noise.nb.win$nb.00 options=conjugate
puthd in=noise.nb.win$nb.00/sfreq value=$sfreq type=d
puthd in=noise.nb.win$nb.00/sdf value=$sdf type=d
else
uvcat vis=all.nb out=noise.nb.win$nb.00 "select=-auto,source(NOISE),win($nb)" \
options=nocal,nopass
endif
For the narrowband windows, first do a passband cal using the noise source
mfcal vis=noise.nb.win$nb.00 refant=$refant
# Passband cal using noise source
gpplt vis=noise.nb.win$nb.00 device=bpnoise.nb.win$nb.00.ps/ps options=bandpass yaxis=phase nxy=4,4 \
yrange=-90,90
$gv bpnoise.nb.win$nb.00.ps
# Copy noise passband to astronomical all-narrowband and hybrid narrowbands, and apply
gpcopy vis=noise.nb.win$nb.00 out=$cal.nb.win$nb.00 options=nocal,nopol
gpcopy vis=noise.nb.win$nb.00 out=$cal.hyb.win$nb.00 options=nocal,nopol
uvcat vis=$cal.nb.win$nb.00 out=$cal.nb.win$nb.0 options=nocal
uvcat vis=$cal.hyb.win$nb.00 out=$cal.hyb.win$nb.0 options=nocal
# use smamfcal with 1st order polynomial to
# get passband on hybrid narrowband and copy to all narrowband
smamfcal vis=$cal.hyb.win$nb.0 line=chan,19,4,3 interval=1 refant=$refant edge=$edge options=opolyfit \
polyfit=$order
gpplt vis=$cal.hyb.win$nb.0 options=bandpass yaxis=phase nxy=4,4 yrange=-90,90 \
device=bp$cal.hyb.win$nb.0.ps/ps
$gv bp$cal.hyb.win$nb.0.ps
# Copy narrowband passband from hybrid to all-narrowband mode
gpcopy vis=$cal.hyb.win$nb.0 out=$cal.nb.win$nb.0 options=nocal,nopol
# check that all-narrowband passband is flat
rm -rf test.pass
uvcat vis=$cal.nb.win$nb.0 out=test.pass
mfcal vis=test.pass refant=$refant
gpplt vis=test.pass options=bandpass yaxis=phase nxy=4,4 yrange=-90,90 \
device=bptest.ps/ps
$gv bptest.ps
# Apply astronomical narrowband passband to hybrid and all-narrowband
uvcat vis=$cal.hyb.win$nb.0 out=$cal.hyb.win$nb options=nocal
uvcat vis=$cal.nb.win$nb.0 out=$cal.nb.win$nb options=nocal
# Selfcal on hybrid wideband to remove temporal variations
# prior to band offset calibration
selfcal vis=$cal.hyb.win$wide line=channel,$wideline \
interval=$calint options=phase refant=$refant
# Copy selfcal solution over to narrow hybrid band and apply
copyhd in=$cal.hyb.win$wide out=$cal.hyb.win$nb items=gains,ngains,nsols,interval
uvcat vis=$cal.hyb.win$nb out=$cal.hyb.win$nb.a
# Selfcal on narrow band of hybrid to determine band offset
selfcal vis=$cal.hyb.win$nb.a line=channel,$narrowline \
interval=9999 options=phase refant=$refant
# Band offset between hybrid-narrowband $cal.hyb.win$nb.a
# and hybrid-wideband $cal.hyb.win$nb
gplist vis=$cal.hyb.win$nb.a options=phase
# Also copy band offset to text file
gplist vis=$cal.hyb.win$nb.a options=phase >! mnband_offset.$cal.hybwin$nb.txt
# Test by applying to calibrator observed in all-narrowband mode
copyhd in=$cal.hyb.win$nb.a out=$cal.nb.win$nb items=gains,ngains,nsols,interval
uvcat vis=$cal.nb.win$nb out=$cal.nb.win$nb.a
# Remove antenna phase gain using super-wideband
rm -rf $cal.wide.sw
uvcat vis=$cal.wide out=$cal.wide.sw select='win('$superwidewin')'
selfcal vis=$cal.wide.sw line=channel,$superwidechan \
interval=9999 options=phase refant=$refant
# Copy super-wideband gain to narrowband and apply
copyhd in=$cal.wide.sw out=$cal.nb.win$nb.a items=gains,ngains,nsols,interval
uvcat vis=$cal.nb.win$nb.a out=$cal.nb.win$nb.a.sc
# Selfcal to check that phases are roughly zero
# to within amount expected given temporal variations over interval
# between superwideband and all-narrowband observerations
selfcal vis=$cal.nb.win$nb.a.sc line=channel,$narrowline \
interval=9999 options=phase refant=$refant
# List gains, which should be near zero except for temporal variations
# over interval between wideband and narrow band observations of cal
echo "**** Phase offset between super-wideband $cal.wide.sw "
echo "**** and all-narrow narrow band $cal.nb.win$nb.a.sc "
echo "**** Check that phases are near zero, limited by atmospheric flucatuations"
gplist vis=$cal.nb.win$nb.a.sc options=phase
# Now apply calibrations to source data
rm -rf $source.win$nb* $source.win$nb.bcal
# First select source data
uvcat vis=all.nb out=$source.win$nb.00 \
"select=-auto,source($source),win($nb)" options=nocal,nopass
# Copy and apply noise passband to source
gpcopy vis=noise.nb.win$nb.00 out=$source.win$nb.00 options=nocal,nopol
uvcat vis=$source.win$nb.00 out=$source.win$nb.0 options=nocal
# Copy and apply astronomical passband
gpcopy vis=$cal.hyb.win$nb.0 out=$source.win$nb.0 options=nocal,nopol
uvcat vis=$source.win$nb.0 out=$source.win$nb options=nocal
# Copy band offset to source
copyhd in=$cal.hyb.win$nb.a out=$source.win$nb items=gains,ngains,nsols,interval
rm -rf $source.win_$i
# Apply band offset using smachunkglue naming convention
uvcat vis=$source.win$nb out=$source.win_$i
# end nb loop
end
This end looping over the bands. The three bands can be glued back together, though the complexity below depends on how many files (bands) we had. It also flags the (bad) overlapping channels between bands that were glued together.
if ($nblength == 2) then set cfile=$source.$nb_array[1]$nb_array[2] rm -rf $cfile smachunkglue vis=$source.win nfiles=$nblength out=$cfile uvflag vis=$cfile line=channel,$badchan1 flagval=flag else if ($nblength == 3) then set cfile=$source.$nb_array[1]$nb_array[2]$nb_array[3] rm -r $cfile smachunkglue vis=$source.win nfiles=$nblength out=$cfile # flag bad overlap channels uvflag vis=$cfile line=channel,$badchan1 flagval=flag uvflag vis=$cfile line=channel,$badchan2 flagval=flag else set cfile=$source.$nb_array[1] rm -rf $cfile uvcat vis=$source.win_$nblength[1] out=$cfile endif # put in restfreq, using UV override principle puthd in=$cfile/restfreq type=double value=$restfreq
To apply we are using a handy little c-shell alias:
rm -rf tmptmp.mir alias apply 'uvcat vis=\!* out=tmptmp.mir; rm -rf \!*; mv tmptmp.mir \!*'
Phase and Amp calibration can now commence, if it was so selected earlier:
if ($apply_gains == 'y') then # copy super-wideband gains to source # Apply Phase Gains gpcopy vis=$viscal.v.wide.sw out=$cfile options=nopol,nopass #apply $cfile # Apply amplitude calibration rm -r medianflux # Apply Amplitude Gains from Phasecal: $viscal #gpcopy vis=$viscal.v.wide.sw.gain out=$cfile options=nopol,nopass set medianflux = `grep Medians $viscal.gains | tr -d Medians:` echo $medianflux > medianflux gplist vis=$cfile options=replace jyperk=@medianflux apply $cfile endif if ($apply_gains == 'n' && $cal == $fluxcal) then # copy super-wideband gains to source # Apply Phase Gains gpcopy vis=$viscal.v.wide.sw out=$cfile options=nopol,nopass rm -r medianflux # Apply Amplitude Gains from Passband Cal: $cal set medianflux = `grep Medians $fluxcal.gains | tr -d Medians:` echo $medianflux > medianflux gplist vis=$cfile options=replace jyperk=@medianflux apply $cfile endif if ($apply_gains == 'n' && $cal != $fluxcal) then # copy super-wideband gains to source # Apply Phase Gains gpcopy vis=$viscal.v.wide.sw out=$cfile options=nopol,nopass rm -r medianflux # Apply Amplitude Gains from Fluxcal: $fluxcal set medianflux = `grep Medians $fluxcal.gains | tr -d Medians:` echo $medianflux > medianflux gplist vis=$cfile options=replace jyperk=@medianflux apply $cfile endif