Exemplo n.º 1
0
def cal2srcs(settings, cal='cal1.uv'):
    '''
	settings: The settings file from your session. This will be used to copy over the solutions.
	cal: the name of the cal file (without full path) which you will use for the gain and
	bandpass calibration. 

	'''
    cal = settings.get('data', 'working') + cal
    srcprefix = settings.get('data', 'srcprefix')
    srcfiles = settings.get('data', 'srcfiles')
    stdout = apercal.shrun('ls -d ' + settings.get('data', 'working') +
                           'src*.uv')
    uvfiles = stdout[0].split('\n')[0:-1]
    o = []
    for s in uvfiles:
        puthd = mirexec.TaskPutHead()
        puthd.in_ = s + '/restfreq'
        puthd.value = 1.420405752
        o.append(puthd.snarf())

        puthd.in_ = s + '/interval'
        puthd.value = 1.0
        puthd.type = 'double'
        o.append(puthd.snarf())

        gpcopy = mirexec.TaskGPCopy()
        gpcopy.vis = cal
        gpcopy.out = s
        o.append(gpcopy.snarf())
        print "Copied Gains from ", cal, " to ", s
    print "DONE cal2srcs"
    return o
Exemplo n.º 2
0
def cal2srcs(settings, cal='cal1.uv'):
	'''
	settings: The settings file from your session. This will be used to copy over the solutions.
	cal: the name of the cal file (without full path) which you will use for the gain and
	bandpass calibration. 

	'''
	cal = settings.get('data', 'working')+cal
	srcprefix = settings.get('data', 'srcprefix')
	srcfiles = settings.get('data', 'srcfiles')
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+'src*.uv')
	uvfiles = stdout[0].split('\n')[0:-1]
	o = []
	for s in uvfiles:
		puthd = mirexec.TaskPutHead();
		puthd.in_ = s+'/restfreq';
		puthd.value = 1.420405752;
		o.append(puthd.snarf())
		
		puthd.in_ = s+'/interval'
		puthd.value = 1.0
		puthd.type = 'double'
		o.append(puthd.snarf())
	
		gpcopy  = mirexec.TaskGPCopy();
		gpcopy.vis = cal;
		gpcopy.out = s;
		o.append(gpcopy.snarf())
		print "Copied Gains from ", cal, " to ",s
	print "DONE cal2srcs"
	return o 
Exemplo n.º 3
0
def sflag(settings, prefix):
	'''
	sflags(settings, prefix) 
	UVFLAG the static flags in the files defined by the given <prefix> - e.g. cal or src.
	This refers to the prefix that you have assigned to the file, and **not** the name of the
	variable. 
	'''
	# NOTE: Need to get the names of the calfiles.
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+prefix+'*')
	uvfiles = stdout[0].split('\n')[0:-1]
	for i in range(0, len(uvfiles)):
		uvfile = settings.get('data', 'working') + prefix + str(i+1) + '.uv'		
		uvflag(uvfile, settings.get('flag', 'sflags'))
		out, err = shrun("qvack vis="+uvfile+" mode=source")
		#print out, err
		print "Flagged and Quacked ", uvfile
Exemplo n.º 4
0
def calcals(settings):
	'''
	Does MFCAL on all the calibrators. 
	'''
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+settings.get('data', 'calprefix')+'*')
	uvfiles = stdout[0].split('\n')[0:-1]

	mfcal = mirexec.TaskMfCal()
	mfcal.refant = settings.get('mfcal', 'refant')
	mfcal.interval = float(settings.get('mfcal', 'interval'))
	mfcal.edge = settings.get('mfcal', 'edge')
	mfcal.select = settings.get('mfcal', 'select')
	o = []
	for v in uvfiles:
		mfcal.vis = v
		o.append( mfcal.snarf())
		print "MFCAL'd ", v 
	return o
Exemplo n.º 5
0
def source_split(settings):
	'''
	Splits sources without doing any smoothing.
	'''
	# Get the file names.
	srcprefix = settings.get('data', 'srcprefix')
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+'src*.uv')
	uvfiles = stdout[0].split('\n')[0:-1]
	source_names = apercal.get_source_names(uvfiles[0])

	uvcat = mirexec.TaskUVCal ()
	uvcat.vis = settings.get('data', 'working')+srcprefix+'*.uv'
	o = []
	for s in source_names:
		print "Splitting ", s
		uvcat.select = "source("+s+")"
		uvcat.out = settings.get('data', 'working')+s+'.uv'
		o.append(uvcat.snarf ())
		print uvcat.vis, "split into", uvcat.out
	return o 
Exemplo n.º 6
0
def sbsplit(settings):
	'''
	Creates subdirectory structure for each source/pointing, and splits the parent UV file into
	spectral windows. This is usually necessary for the selfcal module. 
	'''
	srcprefix = settings.get('data', 'srcprefix')
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+'src*.uv')
	uvfiles = stdout[0].split('\n')[0:-1]
	source_names = apercal.get_source_names(uvfiles[0])

	for s in source_names:
		print "Splitting ", s, " into subbands"
		out, err = shrun("uvsplit vis="+settings.get('data', 'working')+s+".uv")
		#print "Moving subbands into ", s
		shrun("mkdir "+settings.get('data', 'working')+s)
		#print "mkdir "+settings.get('data', 'working')+s
		shrun("mv "+s.lower()+".* "+settings.get('data', 'working')+s+"/")
		#print "mv "+s.lower()+".* "+settings.get('data', 'working')+s+"/"
	print "Subband Split DONE"
	return 1
Exemplo n.º 7
0
def hann_split(settings):
	'''
	Uses UVCAL to smooth and split sources. 
	'''

	# Get the file names.
	srcprefix = settings.get('data', 'srcprefix')
	stdout = apercal.shrun('ls -d '+settings.get('data', 'working')+'src*.uv')
	uvfiles = stdout[0].split('\n')[0:-1]
	source_names = apercal.get_source_names(uvfiles[0])

	uvcal = mirexec.TaskUVCal ()
	uvcal.vis = settings.get('data', 'working')+srcprefix+'*.uv'
	uvcal.options = 'hanning'
	o = []
	for s in source_names:
		print "Splitting ", s
		uvcal.select = "source("+s+")"
		uvcal.out = settings.get('data', 'working')+s+'.uv'
		o.append(uvcal.snarf ())
		print uvcal.vis, "split into", uvcal.out
	return o 
Exemplo n.º 8
0
def sbsplit(settings):
    '''
	Creates subdirectory structure for each source/pointing, and splits the parent UV file into
	spectral windows. This is usually necessary for the selfcal module. 
	'''
    srcprefix = settings.get('data', 'srcprefix')
    stdout = apercal.shrun('ls -d ' + settings.get('data', 'working') +
                           'src*.uv')
    uvfiles = stdout[0].split('\n')[0:-1]
    source_names = apercal.get_source_names(uvfiles[0])

    for s in source_names:
        print "Splitting ", s, " into subbands"
        out, err = shrun("uvsplit vis=" + settings.get('data', 'working') + s +
                         ".uv")
        #print "Moving subbands into ", s
        shrun("mkdir " + settings.get('data', 'working') + s)
        #print "mkdir "+settings.get('data', 'working')+s
        shrun("mv " + s.lower() + ".* " + settings.get('data', 'working') + s +
              "/")
        #print "mv "+s.lower()+".* "+settings.get('data', 'working')+s+"/"
    print "Subband Split DONE"
    return 1