from __future__ import absolute_import
from casatasks.private.casa_transition import *
from casatasks import casalog
from casatools import table as tbtool
from casatools import ms as mstool
from .mstools import write_history
from mstools import write_history
def conjugatevis(vis,spwlist=[],outputvis="",overwrite=False):
Change the sign of the phases in all visibility columns
vis -- Name of input visibility file
default: none; example='3C273XC1.ms'
spwlist -- Select spectral window
default: [] all spws will be conjugated; example: spw=[1,2]
outputvis -- name of output visibility file
default: 'conjugated_'+vis; example= 'conjugated.ms'
overwrite -- Overwrite the outputvis if it exists
default=False; example: overwrite=True
casalog.origin('conjugatevis')
_tb.open(vis+'/SPECTRAL_WINDOW')
if (type(spwlist)==type(1)):
elif(spwlist==None or spwlist==[] or spwlist==""):
casalog.post("Will conjugate visibilities for all spws.", 'INFO')
_tb.open(vis+'/DATA_DESCRIPTION')
raise RuntimeError("Error: max valid spw id is "+str(maxspw))
for j in range(0,_tb.nrows()):
if(_tb.getcell("SPECTRAL_WINDOW_ID",j)==k and not (j in myddlist)):
myddlist = myddlist + [j]
casalog.post('DATA_DESC_IDs to process: '+str(myddlist), 'INFO')
raise RuntimeError('Error reading DATA_DESCRIPTION table: {}'.format(exc))
outname = 'conjugated_'+vis
if((type(outputvis)!=str) or (len(outputvis.split()) < 1)):
raise ValueError('parameter outputvis is invalid')
if not overwrite and os.path.exists(outname):
raise RuntimeError('outputvis '+outname+' exists and you did not permit overwrite')
os.system('rm -rf '+outname)
os.system('cp -R '+vis+' '+outname)
_tb.open(outname, nomodify=False)
for colname in [ 'DATA', 'CORRECTED_DATA', 'FLOAT_DATA' ]:
if colname in _tb.colnames():
casalog.post('Conjugating '+str(colname), 'INFO')
for i in range(0,_tb.nrows()):
a = _tb.getcell(colname, i)
_tb.putcell(colname, i, a)
for colname in [ 'DATA', 'CORRECTED_DATA', 'FLOAT_DATA' ]:
if colname in _tb.colnames():
casalog.post('Conjugating '+str(colname), 'INFO')
for i in range(0,_tb.nrows()):
if(_tb.getcell("DATA_DESC_ID",i) in myddlist):
a = _tb.getcell(colname, i)
_tb.putcell(colname, i, a)