예제 #1
0
def lwpla(uvdata, outfile, inv=None, plv=1,docol=0,plcolors=False):
	HF.delete_file(aips_out+outfile)
	#Must set indata, outfile
  #assert (indata != None, outfile != None)

	lwpla = AIPSTask('lwpla')
	lwpla.indata = uvdata
	lwpla.outfile = aips_out+outfile
	lwpla.lpen = 1.
	lwpla.dparm[6] = 4
	lwpla.dparm[8] = 9
	lwpla.docolor = docol
	if docol==1:
		i=1
		for plc in plcolors:
			lwpla.plcolors[i]=[None]+plc
			i+=1
	lwpla.plver = plv
	if (inv == None or inv == 0):
		inv = uvdata.table_highver('AIPS PL')
	lwpla.inver = inv
	HF.print_inp_to_log(lwpla,'LWPLA')
	try:
		lwpla()
	except:
		sys.stdout.write('LWPLA did encounter an error.\n PL files will remain.\n Change input parameters and try again.')
	else:
		sys.stdout.write('PL files written to plotfile {0}.\n PL files will be deleted now.\n'.format(outfile))
		logger.info('PL files written to plotfile %s.\n PL files will be deleted now.\n',outfile)
		extd(uvdata,ine='PL',inv=-1)
예제 #2
0
def setjy(uvdata):
	setjy = AIPSTask('setjy')
	setjy.inputs()
	setjy.indata = uvdata
	setjy.zerosp[1:] = [1,0]
	HF.print_inp_to_log(setjy,'SETJY')
	setjy()
예제 #3
0
def lgeom(imdata,outn,outd,outseq=0,aparm=[0,0,0,0,0,0,0,0,0],blc=[0],trc=[0]):
	lgeom = AIPSTask('lgeom')
	lgeom.log = open('lgeom.log','w')
	lgeom.indata	= imdata
	lgeom.outname = outn
	lgeom.outclass= lgeom.inclass
	lgeom.outseq	= outseq
	lgeom.outdis	= outd
	lgeom.blc[1:]	= blc
	lgeom.trc[1:] = trc
	lgeom.aparm[1:] = aparm
	HF.print_inp_to_log(lgeom, 'LGEOM')
	lgeom()

	lines=[]
	with open('lgeom.log','r') as f:
		for line in f:
			if line.startswith('LGEOM'):
				lines.append(line)
		for l in lines:
			if l.find('Create')!=-1:
				catnr = l.split()[-1]
	os.remove('lgeom.log')
	print(catnr)
	return int(catnr)
예제 #4
0
def fring_global(uvdata,cals=[],fgv=0,suba=0,refant=0,antennas=[],timer=[0,0,0,1],solint=4,solsub=0,solmin=0,aparm=[1,0,0,0,1,2,4.5,0,1,0],dparm=[1,400,400,0],snv=0,gainu=0,docal=1,search=[],echan=0,bchan=1,bpv=-1,doband=-1,dofit=[0],get2n=False,flux=0):
	fring = AIPSTask('fring')
	fring.indata = uvdata
	fring.flagver = fgv
	fring.calsour[1:] = cals
	fring.timerang[1:] = timer
	fring.solint = solint
	fring.solsub = solsub
	fring.solmin = solmin
	fring.subarray = suba
	fring.antennas[1:] = antennas
	fring.dofit[1:] = dofit
	fring.refant = refant
	fring.gainuse = gainu
	fring.snver = snv
	fring.aparm[1:] = aparm
	fring.dparm[1:] = dparm
	fring.docalib = docal
	fring.doband = doband
	fring.bpver = bpv
	fring.search[1:] = search
	fring.bchan = bchan
	fring.echan = echan
	if get2n:
	#	in2data=getndata(get2n[0],get2n[1])
		fring.in2data=AIPSImage(*get2n)
		fring.flux=flux
	fring.inputs()
	HF.print_inp_to_log(fring,'FRING')
	fring()
예제 #5
0
def uvflg_flagfile(uvdata,intext,outfgv =1,opcode= 'FLAG'):
	uvflg = AIPSTask('uvflg')
	uvflg.indata =uvdata
	uvflg.intext = intext
	uvflg.outfgver = outfgv
	uvflg.opcode= opcode
	HF.print_inp_to_log(uvflg,'UVFLG')
	uvflg()
예제 #6
0
def antab(uvdata,infile,tyv=1,gcv=1):
	antab = AIPSTask('antab')
	antab.indata = uvdata
	antab.calin = infile
	antab.tyver = tyv
	antab.gcver = gcv
	HF.print_inp_to_log(antab,'ANTAB')
	antab()
예제 #7
0
def msort(uvdata):
	sys.stdout.write('Sorting data by runing MSORT.')
	msort = AIPSTask('msort')
	msort.outdata = uvdata
	msort.outclass = 'MSORT'
	msort.indata = uvdata
	HF.print_inp_to_log(msort,'MSORT')
	msort()
	return AIPSUVData(uvdata.name,'MSORT',uvdata.disk,uvdata.seq)
예제 #8
0
def pccor(uvdata,refant=0,cals=[''],timer=[]):
	pccor = AIPSTask('pccor')
	pccor.indata = uvdata
	pccor.timer[1:] = timer
	pccor.inver = 1
	pccor.refant = refant
	pccor.calsour[1:] = cals
	HF.print_inp_to_log(pccor,'PCCOR')
	pccor()
예제 #9
0
def tacop(uvdata,ine='SN',inv=0,outv=0):
	tacop = AIPSTask('tacop')
	tacop.indata = uvdata
	tacop.inext = ine
	tacop.invers = inv
	tacop.outvers = outv
	tacop.outdata = uvdata
	HF.print_inp_to_log(tacop,'TACOP')
	tacop()
예제 #10
0
def pang(uvdata,suba=0):
	clcor = AIPSTask('clcor')
	clcor.indata = uvdata
	clcor.opcode = 'PANG'
	clcor.subarray = suba
	clcor.gainv = uvdata.table_highver('CL')
	clcor.gainu = uvdata.table_highver('CL')+1
	clcor.clcorprm[1] = 1
	HF.print_inp_to_log(clcor,'CLCOR PANG')
	clcor()
예제 #11
0
def swpol(uvdata,antennas):
	swpol = AIPSTask('swpol')
	swpol.indata = uvdata
	swpol.antennas[1:] = antennas
	swpol.outname = uvdata.name
	swpol.outclass = 'SWPOL'
	swpol.outseq = uvdata.seq
	swpol.outdisk = uvdata.disk
	HF.print_inp_to_log(swpol,'SWPOL')
	swpol()
	return AIPSUVData(uvdata.name,'SWPOL',uvdata.disk,uvdata.seq)
예제 #12
0
def acscl(uvdata,gainu=0,bpv=1,doband=1):
	acscl = AIPSTask('acscl')
	acscl.indata = uvdata
	#acscl.timer[1:] = [0]
	acscl.solint = 0
	acscl.docalib = 1
	acscl.gainuse =gainu
	acscl.bpver=bpv
	acscl.doband=doband
	HF.print_inp_to_log(acscl,'ACSCL')
	acscl()
예제 #13
0
def slcol(imdata,outfile,inv=1,nfiles=0,pixxy=[0,0],opc='MODL', aparm=[1,1,0]):
	slcol = AIPSTask('slcol')
	slcol.indata		= imdata
	slcol.outtext		= outfile
	slcol.nfiles		= nfiles
	slcol.invers		= inv
	slcol.zinc			= 0
	slcol.pixxy[1:]	= pixxy
	slcol.opcode		= opc
	slcol.aparm[1:]	= aparm
	HF.print_inp_to_log(slcol,'SLCOL')
	slcol()
예제 #14
0
def tabed(uvdata,ine='an',optype='repl',keyvalue=[5,0],aparm=[5,0,0,4,4,14,0],inv=1,outv=1):
	tabed = AIPSTask('tabed')
	tabed.indata = uvdata
	tabed.outdata = uvdata
	tabed.inext = ine
	tabed.invers = inv
	tabed.outvers = outv
	tabed.aparm[1:]=aparm
	tabed.keyvalue[1:]=keyvalue
	tabed.optype = optype
	HF.print_inp_to_log(tabed,'TABED')
	tabed()
예제 #15
0
def possm(uvdata, aparm=[0,1,0,0,-200,200,0,0,1,0], solint=-1, sources =[], timer =[0,0,0,0],
      codetype='A&P', nplots=9, stokes='HALF', antennas=[], baseline =[],
      docal=1, gainu=0, doband=0, bpv=0, fgv=0, dotv=-1,bchan=1,echan=0,plotname=None,**kwds):
	
	uvdata.zap_table('PL',-1)	
	sys.stdout.write('Produce possm plots for antennas = {0}'.format(antennas))
	sys.stdout.write('and Sources = {0}'.format(sources))
	possm = AIPSTask('possm')
	possm.indata = uvdata
	possm.solint = solint
	possm.stokes = stokes
	possm.sources[1:] = sources
	possm.timerang[1:] = timer
	possm.antennas[1:] = antennas
	possm.baseline[1:] = baseline
	possm.docalib = docal
	possm.gainuse = gainu
	possm.flagver = fgv
	possm.doband = doband
	possm.bpver = bpv
	possm.bchan = bchan
	possm.echan = echan
	if(aparm==None):
		possm.aparm[9]=1
	else:
		possm.aparm[1:] = aparm[0:]
	possm.codetype = codetype
	possm.nplots = nplots
	possm.dotv = dotv
	HF.print_inp_to_log(possm,'POSSM')
	possm()
	if gainu==0:
		CLtable=uvdata.table_highver('CL')
	else:
		CLtable=gainu
	if sources==[]:
		sourcelist='All'
	elif len(sources) >=1:
		sourcelist='_'.join(set(sources))
		#sourcelist='AC'
	if fgv==-1:
		outfile='{0}_possm_CL{1}_{2}.ps'.format(uvdata.name,CLtable,sourcelist)
	elif fgv>-1:
		if fgv==0:
			fgv=uvdata.table_highver('FG')
		outfile='{0}_possm_CL{1}_FG{3}_{2}.ps'.format(uvdata.name,CLtable,sourcelist,fgv)
	if bpv>0:
		outfile=outfile.split('.')[0]+'BP'+str(bpv)+'.ps'
	if plotname:
		outfile='_'.join(outfile.split('_')[0:4])+'_'+plotname+'.ps'
	lwpla(uvdata, outfile)
예제 #16
0
def uvflg(uvdata,stokes='',timer=[0,0,0,0],antennas=[],bchan=1,outfgv=0,echan=0,bif=1,eif=0,reason='edged'):
	uvflg = AIPSTask('uvflg')
	uvflg.indata = uvdata
	uvflg.antennas[1:] = antennas
	uvflg.timer[1:] = timer
	uvflg.bchan =bchan
	uvflg.echan = echan
	uvflg.stokes = stokes
	uvflg.bif =bif
	uvflg.eif =eif
	uvflg.outfgver=outfgv
	uvflg.opcode = 'FLAG'
	uvflg.reason =reason
	HF.print_inp_to_log(uvflg,'UVFLG')
	uvflg()
예제 #17
0
def slfit(imdata,inv,gmax,gwidth,gpos=0,ngauss=1,savelog=False):
	slfit = AIPSTask('slfit')
	if type(savelog)==str:
		slfit.log = open(savelog,'w')
	slfit.indata	= imdata
	slfit.invers	= inv
	slfit.ngauss	= ngauss
	slfit.gmax[1:]= [gmax]
	slfit.gpos[1:]= [[None,gpos]]
	slfit.gwidth[1:]= [[None,gwidth]]
	slfit.dopos[1:]	= [[None,1]]
	slfit.dowidth[1:]= [[None,1]]
	slfit.domax[1:] = [1]
	HF.print_inp_to_log(slfit,'SLFIT')
	slfit()
예제 #18
0
def snsmo(uvdata,antennas=[],npiece=0,smotype='BOTH',samptype='MWF',bparm=[],cparm=[],doblank=-1,inv=0,outv=0,refant=0,dobtween=0):
	snsmo = AIPSTask('snsmo')
	snsmo.indata		= uvdata
	snsmo.samptype	= samptype
	snsmo.antennas[1:] = antennas
	snsmo.npiece		= npiece
	snsmo.smotype		= smotype
	snsmo.bparm[1:] = bparm
	snsmo.cparm[1:] = cparm
	snsmo.doblank		= doblank #check if 1 or -1 is needed
	snsmo.inver			= inv
	snsmo.outver		= outv
	snsmo.refant		= refant
	snsmo.dobtween	= dobtween
	HF.print_inp_to_log(snsmo,'SNSMO')
	snsmo()
예제 #19
0
def split(uvdata,sources=[],outd=1,aparm=[2,1,1,1,0],antennas=[],fgv=0,bpv=0,doband=-1,gainu=0,bchan=1,echan=0,bif=1,eif=0,stokes='HALF'):
	split = AIPSTask('split')
	split.indata = uvdata
	split.antennas[1:]=antennas
	split.sources[1:] = sources
	split.docalib = 2
	split.aparm[1:] = aparm
	split.outdisk = outd
	split.bpv   = bpv
	split.flagver = fgv
	split.doband= doband
	split.bchan = bchan
	split.echan = echan
	split.bif   = bif
	split.eif   = eif
	split.stokes= stokes
	split.gainuse = gainu
	HF.print_inp_to_log(split,'SPLIT')
	split()
예제 #20
0
def fittp(imdata,outfile=''):
	uvdata=AIPSUVData(*imdata)
	if outfile=='':
		outfile=uvdata.header['object']
	while os.path.isfile(aips_out+outfile):
		outname=outfile.split('.')[0]
		filetype=outfile.split('.')[-1]
		outname=outname.split('_')
		try:
			outname[-1]= str(int(outname[-1])+1)
		except ValueError:
			outname.append('2')
		outfile='_'.join(outname)+'.'+filetype

	fittp = AIPSTask('fittp')
	fittp.indata = uvdata
	fittp.dataout = aips_out+outfile
	HF.print_inp_to_log(fittp,'FITTP')
	fittp()
예제 #21
0
def snplt(uvdata,ine='CL',antennas=[],nplots=16,inv=0,optype='PHAS',stokes='',sources=[],opcode='ALIF',plotname=False):
	outn = uvdata.name
	if plotname !=False:
		outfile=outn+'_'+plotname+'_snplt_'+ine+str(inv)+'.ps'
	else:
		outfile=outn+'_snplt_'+ine+str(inv)+'.ps'
	snplt = AIPSTask('snplt')
	snplt.indata = uvdata
	snplt.intable = uvdata.table(ine,inv)
	snplt.optype = optype
	snplt.antennas[1:] = antennas
	snplt.stokes = stokes
	snplt.sources = sources
	snplt.dotv = -1
	snplt.do3col = 2
	snplt.opcode = opcode
	snplt.nplots = nplots
	HF.print_inp_to_log(snplt,'SNPLT')
	snplt()
	lwpla(uvdata, outfile)
예제 #22
0
def imlod(outn,outd,datain,outc='CMAP'):
	imlod	= AIPSTask('imlod')
	imlod.log= open('imlod.log','w')
	imlod.outname	=outn
	imlod.outclass= outc
	imlod.outseq	= 0
	imlod.outdisk	= outd
	imlod.datain	= datain
	HF.print_inp_to_log(imlod,'IMLOD')
	imlod()
	
	lines=[]
	with open('imlod.log','r') as f:
		for line in f:
			if line.startswith('IMLOD'):
				lines.append(line)
		for l in lines:
			if l.find('CNO')!=-1:
				catnr = l.split()[-1]
	return int(catnr)
예제 #23
0
def clcal(uvdata,timer=[0,0,0,0],sources=[],cals=[],antennas =[],opcode='CALP',interpol='AMBG',gainv=0,gainu=0,snv=0,refant=0,doblank=0,dobtween=1,smotype='',samptype='',suba = -32000,inv=0):
	clcal = AIPSTask('clcal')
	clcal.indata = uvdata
	clcal.sources[1:] = sources
	clcal.calsour[1:] = cals
	clcal.timer[1:] = timer
	clcal.opcode = opcode
	clcal.subarray = suba
	clcal.interpol = interpol
	clcal.antennas[1:] = antennas
	clcal.snver = snv
	clcal.inver = inv
	clcal.gainver = gainv
	clcal.gainuse = gainu
	clcal.doblank = doblank
	clcal.dobtween = dobtween
	clcal.smotype = smotype
	clcal.samptype = samptype
	clcal.refant = refant
	HF.print_inp_to_log(clcal,'CLCAL')
	clcal()
예제 #24
0
def apcal(uvdata,tyv=0,gcv=0,opcode='',aparm=[],dofit=[],inv=0,trecvr=[],calin='',tau0=[0],savelog=False,solint=0):
	apcal = AIPSTask('apcal')
	if type(savelog)==str:
		apcal.log = open(savelog,'w')
	apcal.indata = uvdata
	apcal.tyver = tyv
	apcal.gcver = gcv
	apcal.dotv = -1
	apcal.solint = solint
	#apcal.timer = []
	apcal.opcode = opcode
	apcal.tau0[1:] = tau0
	apcal.invers = inv
	apcal.calin = calin
	apcal.dofit[1:] = dofit
	apcal.trecvr[1:] = trecvr
	apcal.aparm[1:] = aparm
	HF.print_inp_to_log(apcal,'APCAL')
	apcal()
	if apcal.opcode != '':
		outfile = uvdata.name+'APCAL_opacity_correction.ps'
		lwpla(uvdata, outfile)
예제 #25
0
def bpass (uvdata,bpv=-1,cals=[],antennas=[],gainu=0,solint=0,refant=0,bpassprm=[0],ichansel=[],timer=[],fgv=1):
	bpass = AIPSTask('bpass')
	bpass.indata = uvdata
	bpass.calsour[1:] = cals
	bpass.antennas[1:] = antennas
	bpass.gainuse = gainu
	bpass.bpver	= bpv
	bpass.flagver = fgv
	bpass.solint = solint
	bpass.refant = refant
	bpass.docalib = 1
	bpass.timer[1:] = timer
	bpass.cmethod = 'GRID'
	for i in range(len(ichansel)):
		n=i+1
		bpass.ichansel[n][1:] = ichansel[i]
# form of 'ichansel': [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
	bpass.bpassprm[1:] = bpassprm
	#for row in inputs:
	# print row
	#raw_input("Press Enter to continue...")
	HF.print_inp_to_log(bpass,'BPASS')
	bpass()
예제 #26
0
def fring_instr(uvdata,fgv=0,suba=0,cals=[],refant=0,antennas=[],timer =[0,0,0,0],solint=-1,aparm=[2,0,0,0,0,2,0,0,0],dparm=[1,400,400,0,0,0,0,1,1],snv=0,gainu=0,docal=1,search=[],echan=0,bchan=1,bpv=-1,doband=-1):
	fring = AIPSTask('fring')
	fring.indata = uvdata
	fring.calsour[1:] = cals
	fring.timerang[1:] = timer
	fring.flagver = fgv
	fring.solint = solint
	fring.subarray = suba
	fring.antennas[1:] = antennas
	fring.refant = refant
	fring.gainuse = gainu
	fring.snver = snv
	fring.aparm[1:] = aparm
	fring.dparm[1:] = dparm
	fring.docalib = docal
	fring.doband = doband
	fring.bpver = bpv
	fring.search[1:] = search
	fring.bchan = bchan
	fring.echan = echan
	fring.inputs()
	HF.print_inp_to_log(fring,'FRING')
	fring()
예제 #27
0
def eops(uvdata):
	if(os.path.isfile('./usno_finals.erp')):
		eops_file='./usno_finals.erp'
	else:
		valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False}
		# According to http://www.aips.nrao.edu/index.shtml the goddad webserver is down. On the webside a copy can be downoaded. The path to the copy is set below.
		#eops_file = HF.download_file('https://gemini.gsfc.nasa.gov/solve_save/usno_finals.erp','./usno_finals.erp')
		eops_file = HF.download_file('ftp://ftp.lbo.us/pub/staff/wbrisken/EOP/usno_finals.erp','./usno_finals.erp')
		if eops_file == False:
			msg = "Run EOP with presonal 'usno_finals.erp'?" 
			choice = None
			while True:
				sys.stdout.write('EOP file download failed. Either provide EOP file yourself or skip clcor(eop)\n')
				choice = raw_input('{0} [yes/no]\n'.format(msg)).lower()
				if choice in valid:
					if valid[choice] is True:
						isfile=False
						while isfile is False:
							msg2='Please provied path to file:'
							eops_file = raw_input('{0}\n'.format(msg2))
							if(os.path.isfile(filename)):
								isfile ==True
							else:
								sys.stdout.write('Path  not found. Try again.')
					elif valid[choice] is False:
						logger.info('Skip EOP and procede with calibration./n')
						return
				else:
					sys.stdout.write("Please say 'yes' or 'no'")
	clcor = AIPSTask('clcor')
	clcor.indata = uvdata
	clcor.gainv = uvdata.table_highver('CL')
	clcor.gainu = uvdata.table_highver('CL')+1
	clcor.opcode = 'EOPS'
	clcor.infile = './usno_finals.erp'
	HF.print_inp_to_log(clcor,'CLCOR EPOS')
	clcor()
예제 #28
0
def accor(uvdata,solint=-10):
	accor = AIPSTask('accor')
	accor.indata = uvdata
	accor.solint = solint #scan-average
	HF.print_inp_to_log(accor,'ACCOR')
	accor()
예제 #29
0
def usuba(uvdata,opcode='SCAN'):
	usuba = AIPSTask('usuba')
	usuba.indata = uvdata
	usuba.opcode = opcode
	HF.print_inp_to_log(usuba,'USUBA')
	usuba()
예제 #30
0
def indxr(uvdata,clint=0.1):
	indxr = AIPSTask('indxr')
	indxr.indata = uvdata
	indxr.cparm[3] = clint
	HF.print_inp_to_log(indxr,'INDXR')
	indxr()