Source
print 'Fld=%i, Spw=%i, PA Offset=%5.1f, Gx/Gy=%5.3f, Q=%5.3f, U=%5.3f, P=%5.3f, X=%5.1f' % (ifld,ispw,paoff[ispw],R[ispw,ifld],Q[ispw,ifld],U[ispw,ifld],P,X)
#!/usr/bin/env python
#
# atcapolhelpers.py
#
# History:
# v1.0 (gmoellen, 2012Oct24) == initial version (linpolhelpers)
# V1.2 (mwiering, 2016Aug01) updated for ATCA use
#
# This script defines the qufromgain method currently needed for
# instrumental polarization calibration for the linear
# feed basis.
# To import this function, type (at the CASA prompt):
#
# from recipes.atcapolhelpers import *
#
#
import os
from math import pi,floor,atan2,sin,cos,sqrt
import taskinit
import pylab as pl
def qufromgain(caltable,badspw=[],badant=[],fieldids=[],paoffset=None):
mytb=taskinit.tbtool()
myme=taskinit.metool()
pos=myme.observatory('atca')
myme.doframe(pos)
# _geodetic_ latitude
latr=myme.measure(pos,'WGS84')['m1']['value']
#print 'latitude: ',latr*180/pi
mytb.open(caltable+'/FIELD')
nfld=mytb.nrows()
dirs=mytb.getcol('DELAY_DIR')[:,0,:]
mytb.close()
print 'Found '+str(nfld)+' fields.'
mytb.open(caltable+'/SPECTRAL_WINDOW')
freq=mytb.getcol('REF_FREQUENCY')
nspw=mytb.nrows()
mytb.close()
print 'Found '+str(nspw)+' spws.'
#sort out pa offset to apply
paoff=pl.zeros(nspw)
if paoffset==None:
# use defaults for ATCA
# (should get these from Feed subtable, but cal table doesn't have one)
for ispw in range(nspw):
if freq[ispw]<30e9 or freq[ispw]>50e9:
paoff[ispw]=45.
else:
paoff[ispw]=135.
else:
paoff=paoffset
R=pl.zeros((nspw,nfld))
Q=pl.zeros((nspw,nfld))
U=pl.zeros((nspw,nfld))
mask=pl.ones((nspw,nfld),dtype=bool)