Source
print 'Fld=',ifld,'Spw=',ispw,'Gx/Gy=',R[ispw,ifld],'Q=',Q[ispw,ifld],'U=',U[ispw,ifld],'P=',P,'X=',X
#!/usr/bin/env python
#
# linfeedpolhelpers.py
#
# History:
# v1.0 (gmoellen, 2012Oct24) == initial version
#
# This script defines several methods currently needed for
# instrumental polarization calibration for the linear
# feed basis.
# To import these functions, type (at the CASA prompt):
#
# from recipes.linfeedpolhelpers import *
#
#
import os
def qufromgain(gt,badspw=[]):
me.doframe(me.observatory('alma'))
tb.open(gt+'/ANTENNA')
pos=tb.getcol('POSITION')
meanpos=pl.mean(pos,1)
frame=tb.getcolkeyword('POSITION','MEASINFO')['Ref']
units=tb.getcolkeyword('POSITION','QuantumUnits')
mpos=me.position(frame,
str(meanpos[0])+units[0],
str(meanpos[1])+units[1],
str(meanpos[2])+units[2])
me.doframe(mpos)
# _geodetic_ latitude
latr=me.measure(mpos,'WGS84')['m1']['value']
tb.open(gt+'/FIELD')
nfld=tb.nrows()
dirs=tb.getcol('DELAY_DIR')[:,0,:]
tb.close()
print 'Found as many as '+str(nfld)+' fields.'
tb.open(gt+'/SPECTRAL_WINDOW')
nspw=tb.nrows()
tb.close()
print 'Found as many as '+str(nspw)+' spws.'
R=pl.zeros((nspw,nfld))
Q=pl.zeros((nspw,nfld))
U=pl.zeros((nspw,nfld))
mask=pl.ones((nspw,nfld),dtype=bool)
if (len(badspw)>0):
mask[badspw,:]=False
tb.open(gt)
for ifld in range(nfld):
for ispw in range(nspw):
if not mask[ispw,ifld]:
continue
st=tb.query('FIELD_ID=='+str(ifld)+' && SPECTRAL_WINDOW_ID=='+str(ispw))
nrows=st.nrows()
if nrows > 0:
rah=dirs[0,ifld]*12.0/pi