Beispiel #1
0
def iofits(I, O):
    '''
	Reads in the uvfits file I and exports it to the miriad-uv file O,
	using the carma-miriad task wsrtfits.
	'''
    cmd = 'wsrtfits in=' + I + ' out=' + O + ' op=uvin velocity=optbary'
    print "Import " + I + " -> " + O
    os.system(cmd)
    print "Tsys Calibration on " + O
    cmd = 'attsys vis=' + O + ' out=_tmp_vis'
    os.system(cmd)
    cmd = 'rm -r ' + O
    os.system(cmd)
    cmd = 'mv _tmp_vis ' + O
    os.system(cmd)
    flags = ['auto', 'shadow(25)', 'an(6)']
    for f in flags:
        uvflag = mirexec.TaskUVFlag()
        uvflag.vis = O
        uvflag.select = f
        #'auto,or,shadow(27),or,ant(6)';
        uvflag.flagval = 'flag'
        tout = uvflag.snarf()
        acos.taskout(uvflag, tout, 'uvflag.txt')
    print "Done."
Beispiel #2
0
def imstat(image, fname):
	'''
	Performs imstat on settings.image
	'''
	imstat = mirexec.TaskImStat();
	imstat.in_ = image;
	tout = imstat.snarf();
	acos.taskout(imstat, tout, fname);
Beispiel #3
0
def imstat(image, fname):
    '''
	Performs imstat on settings.image
	'''
    imstat = mirexec.TaskImStat()
    imstat.in_ = image
    tout = imstat.snarf()
    acos.taskout(imstat, tout, fname)
Beispiel #4
0
def calcals(cals):
	mfcal = mirexec.TaskMfCal();
	for c in cals:
		mfcal.vis = c;
		mfcal.interval = 1000000.;
		tout = mfcal.snarf();
		acos.taskout(mfcal, tout, 'mfcal.txt');
		print "MFCAL Done on "+c;
Beispiel #5
0
def calcals(cals):
    mfcal = mirexec.TaskMfCal()
    for c in cals:
        mfcal.vis = c
        mfcal.interval = 1000000.
        tout = mfcal.snarf()
        acos.taskout(mfcal, tout, 'mfcal.txt')
        print "MFCAL Done on " + c
Beispiel #6
0
def selfcal(settings, fname):
    selfcal = mirexec.TaskSelfCal()
    selfcal.vis = settings.vis
    selfcal.options = settings.selfcal_options
    selfcal.model = settings.m4s
    selfcal.interval = settings.selfcal_interval
    selfcal.select = settings.selfcal_select
    tout = selfcal.snarf()
    acos.taskout(selfcal, tout, fname)
Beispiel #7
0
def maths(settings, fname):
    settings.gt = round(settings.gt, 10)
    maths = mirexec.TaskMaths()
    maths.exp = settings.image
    maths.mask = settings.image + '.gt.' + str(settings.gt)
    maths.out = settings.mask
    #maths.region=settings.clean_region;
    tout = maths.snarf()
    acos.taskout(maths, tout, fname)
Beispiel #8
0
def restores(settings, fname, mode='residual'):
	restor = mirexec.TaskRestore();
	restor.model = settings.model;
	restor.map = settings.map;
	restor.beam = settings.beam;
	restor.out = settings.res;
	restor.mode = mode;
	tout = restor.snarf();
	acos.taskout(restor, tout, fname);
Beispiel #9
0
def restorim(settings, fname, mode='clean'):
	restor = mirexec.TaskRestore();
	restor.model = settings.model;
	restor.map = settings.map;
	restor.beam = settings.beam;
	restor.out = settings.image;
	restor.mode = mode;
	tout = restor.snarf();
	acos.taskout(restor, tout, fname);
Beispiel #10
0
def selfcal(settings, fname):
	selfcal = mirexec.TaskSelfCal()
	selfcal.vis = settings.vis;
	selfcal.options = settings.selfcal_options;
	selfcal.model = settings.m4s;
	selfcal.interval = settings.selfcal_interval;
	selfcal.select = settings.selfcal_select;
	tout = selfcal.snarf();
	acos.taskout(selfcal, tout, fname);
Beispiel #11
0
def restorim(settings, fname, mode='clean'):
    restor = mirexec.TaskRestore()
    restor.model = settings.model
    restor.map = settings.map
    restor.beam = settings.beam
    restor.out = settings.image
    restor.mode = mode
    tout = restor.snarf()
    acos.taskout(restor, tout, fname)
Beispiel #12
0
def maths(settings, fname):
	settings.gt = round(settings.gt,10);
	maths = mirexec.TaskMaths();
	maths.exp = settings.image;
	maths.mask = settings.image+'.gt.'+str(settings.gt);
	maths.out = settings.mask;
	#maths.region=settings.clean_region;
	tout = maths.snarf();
	acos.taskout(maths, tout, fname);
Beispiel #13
0
def restores(settings, fname, mode='residual'):
    restor = mirexec.TaskRestore()
    restor.model = settings.model
    restor.map = settings.map
    restor.beam = settings.beam
    restor.out = settings.res
    restor.mode = mode
    tout = restor.snarf()
    acos.taskout(restor, tout, fname)
Beispiel #14
0
def clean(settings, fname):
	clean = mirexec.TaskClean()
	clean.map = settings.map;
	#clean.region = settings.clean_region;
	clean.beam = settings.beam;
	clean.out = settings.model;
	clean.cutoff = round(settings.cutoff, 10);
	clean.niters = settings.niters;
	tout = clean.snarf()
	acos.taskout(clean, tout, fname);
Beispiel #15
0
def clean(settings, fname):
    clean = mirexec.TaskClean()
    clean.map = settings.map
    #clean.region = settings.clean_region;
    clean.beam = settings.beam
    clean.out = settings.model
    clean.cutoff = round(settings.cutoff, 10)
    clean.niters = settings.niters
    tout = clean.snarf()
    acos.taskout(clean, tout, fname)
Beispiel #16
0
def exfits(I, O):
	'''
	Reads in the 
	'''
	print "Exporting "+I+" to "+O;
	fits = mirexec.TaskFits();
	fits.in_ = I;
	fits.out = O;
	fits.op = 'uvout';
	tout = fits.snarf();
	acos.taskout(fits, tout, 'fits.txt');
Beispiel #17
0
def exfits(I, O):
    '''
	Reads in the 
	'''
    print "Exporting " + I + " to " + O
    fits = mirexec.TaskFits()
    fits.in_ = I
    fits.out = O
    fits.op = 'uvout'
    tout = fits.snarf()
    acos.taskout(fits, tout, 'fits.txt')
Beispiel #18
0
def specr(f, S):
	'''
	Uses uvaver to cut-out a spectral range. 
	'''
	uvaver = mirexec.TaskUVAver();
	uvaver.vis = f; 
	uvaver.line = S.line;
	uvaver.out = '_tmp_specr'
	tout = uvaver.snarf();
	os.system('rm -r '+f);
	os.system('mv _tmp_specr '+f)
	acos.taskout(uvaver, tout, 'uvaver.txt');
Beispiel #19
0
def specr(f, S):
    '''
	Uses uvaver to cut-out a spectral range. 
	'''
    uvaver = mirexec.TaskUVAver()
    uvaver.vis = f
    uvaver.line = S.line
    uvaver.out = '_tmp_specr'
    tout = uvaver.snarf()
    os.system('rm -r ' + f)
    os.system('mv _tmp_specr ' + f)
    acos.taskout(uvaver, tout, 'uvaver.txt')
Beispiel #20
0
def invert(settings, fname):
	invert = mirexec.TaskInvert()
	invert.vis = settings.name
	invert.map = settings.map
	invert.beam = settings.beam
	invert.imsize = settings.imsize;
	invert.cell = settings.cell;
	invert.options=settings.invert_options;
	invert.robust = settings.robust;
	invert.select = settings.invert_select;
	invert.slop=0.5;
	tout = invert.snarf()
	acos.taskout(invert, tout, fname);
Beispiel #21
0
def clean_deeper(settings, fname, df=3):
    '''
	Runs clean using the mask. The settings.cutoff is divided by df. 
	'''
    clean = mirexec.TaskClean()
    clean.map = settings.map
    clean.beam = settings.beam
    clean.region = 'mask(' + settings.mask + ')'
    clean.out = settings.m4s
    clean.cutoff = settings.cutoff
    clean.niters = settings.niters
    tout = clean.snarf()
    acos.taskout(clean, tout, fname)
Beispiel #22
0
def clean_deeper(settings, fname, df=3):
	'''
	Runs clean using the mask. The settings.cutoff is divided by df. 
	'''
	clean = mirexec.TaskClean()
	clean.map = settings.map;
	clean.beam = settings.beam;
	clean.region = 'mask('+settings.mask+')';
	clean.out = settings.m4s;
	clean.cutoff = settings.cutoff;
	clean.niters = settings.niters;
	tout = clean.snarf()
	acos.taskout(clean, tout, fname);
Beispiel #23
0
def invert(settings, fname):
    invert = mirexec.TaskInvert()
    invert.vis = settings.name
    invert.map = settings.map
    invert.beam = settings.beam
    invert.imsize = settings.imsize
    invert.cell = settings.cell
    invert.options = settings.invert_options
    invert.robust = settings.robust
    invert.select = settings.invert_select
    invert.slop = 0.5
    tout = invert.snarf()
    acos.taskout(invert, tout, fname)
Beispiel #24
0
def iofits(I, O):
	'''
	Reads in the uvfits file I and exports it to the miriad-uv file O,
	using the carma-miriad task wsrtfits.
	'''
	cmd = 'wsrtfits in='+I+' out='+O+' op=uvin velocity=optbary';
	print "Import "+I+" -> "+O;
	os.system(cmd);
	print "Tsys Calibration on "+O;
	cmd = 'attsys vis='+O+' out=_tmp_vis';
	os.system(cmd);
	cmd = 'rm -r '+O;
	os.system(cmd);
	cmd = 'mv _tmp_vis '+O;
	os.system(cmd);
	flags = ['auto', 'shadow(25)', 'an(6)'];
	for f in flags:
		uvflag = mirexec.TaskUVFlag();
		uvflag.vis = O;
		uvflag.select = f; #'auto,or,shadow(27),or,ant(6)';
		uvflag.flagval = 'flag';
		tout = uvflag.snarf();
		acos.taskout(uvflag, tout, 'uvflag.txt')
	print "Done."
Beispiel #25
0
def cal2srcs(cals, srcs):
	'''
	Cals = 'cal1,cal2'
	Srcs = 'src1,src2'
	'''
	#cals = cals.split(',');
	#srcs = srcs.split(',');
	# uvcat on src files
	if os.path.exists(srcs[2])==False:
	#try:
	#	with open(srcs[2]):
	#		isthere=True;
	#except IOError:
	#	isthere=False;
	#
	#if isthere==False:
		uvcat = mirexec.TaskUVCat();
		uvcat.vis = srcs[0]+','+srcs[1];
		uvcat.out = srcs[2];
		uvcat.options='unflagged';
		tout = uvcat.snarf();
		acos.taskout(uvcat, tout, 'cal2srcs.txt');
	

	# puthd on src
	puthd = mirexec.TaskPutHead();
	puthd.in_ = srcs[2]+'/restfreq';
	puthd.value = 1.420405752;
	tout = puthd.snarf();
	acos.taskout(puthd, tout, 'cal2srcs.txt');
	
	puthd.in_ = srcs[2]+'/interval'
	puthd.value = 1.0
	puthd.type = 'double'
	tout = puthd.snarf();
	acos.taskout(puthd, tout, 'cal2srcs.txt');

	# gpcopy cal1 -> src
	gpcopy  = mirexec.TaskGPCopy();
	gpcopy.vis = cals[0];
	gpcopy.out = srcs[2];
	tout = gpcopy.snarf();
	acos.taskout(gpcopy, tout, 'cal2srcs.txt');
Beispiel #26
0
def cal2srcs(cals, srcs):
    '''
	Cals = 'cal1,cal2'
	Srcs = 'src1,src2'
	'''
    #cals = cals.split(',');
    #srcs = srcs.split(',');
    # uvcat on src files
    if os.path.exists(srcs[2]) == False:
        #try:
        #	with open(srcs[2]):
        #		isthere=True;
        #except IOError:
        #	isthere=False;
        #
        #if isthere==False:
        uvcat = mirexec.TaskUVCat()
        uvcat.vis = srcs[0] + ',' + srcs[1]
        uvcat.out = srcs[2]
        uvcat.options = 'unflagged'
        tout = uvcat.snarf()
        acos.taskout(uvcat, tout, 'cal2srcs.txt')

    # puthd on src
    puthd = mirexec.TaskPutHead()
    puthd.in_ = srcs[2] + '/restfreq'
    puthd.value = 1.420405752
    tout = puthd.snarf()
    acos.taskout(puthd, tout, 'cal2srcs.txt')

    puthd.in_ = srcs[2] + '/interval'
    puthd.value = 1.0
    puthd.type = 'double'
    tout = puthd.snarf()
    acos.taskout(puthd, tout, 'cal2srcs.txt')

    # gpcopy cal1 -> src
    gpcopy = mirexec.TaskGPCopy()
    gpcopy.vis = cals[0]
    gpcopy.out = srcs[2]
    tout = gpcopy.snarf()
    acos.taskout(gpcopy, tout, 'cal2srcs.txt')