Beispiel #1
0
def mkfmod():
    '''
	Uses image properties to cutout a single rectangular 
	region from a mask. 
	S.fipe = X,Y,xp,yp,l
	X,Y: Size of the model image (pixels)
	xp,yp: Pixel coords of the source to be peeled
	l: Pixel length of displacement from source
	'''
    # First, the size of the image
    S.fipe = S.fipe.split(',')
    X = int(S.fipe[0])
    Y = int(S.fipe[1])
    xp = int(S.fipe[2])
    yp = int(S.fipe[3])
    l = int(S.fipe[4])
    model = S.fipe[5]
    polygon = 'polygon(1,1,' + str(xp - l) + ',1,' + str(xp -
                                                         l) + ',' + str(yp + l)
    polygon = polygon + ',' + str(xp + l) + ',' + str(yp +
                                                      l) + ',' + str(xp +
                                                                     l) + ',1,'
    polygon = polygon + str(X) + ',1,' + str(X) + ',' + str(Y) + ',1,' + str(
        Y) + ')'
    maths = mirexec.TaskMaths()
    maths.exp = model
    maths.region = polygon
    maths.out = 'fmod'
    tout = maths.snarf()
    acos.taskout(maths, tout, 'maths.txt')
Beispiel #2
0
def selfcal(vis, model):
	selfcal = mirexec.TaskSelfCal();
	selfcal.vis = vis; 
	selfcal.model = model;
	selfcal.options='amplitude'
	tout = selfcal.snarf();
	acos.taskout(selfcal, tout, 'selfcal.txt');
Beispiel #3
0
def fipe_models(model):
	'''
	Uses image properties to cutout a single rectangular 
	region from a mask. 
	S.fipe = X,Y,xp,yp,l
	X,Y: Size of the model image (pixels)
	xp,yp: Pixel coords of the source to be peeled
	l: Pixel length of displacement from source
	'''
	# First, the size of the image
	S.fipe=S.fipe.split(',');
	X = int(S.fipe[0]);
	Y = int(S.fipe[1]);
	xp = int(S.fipe[2]);
	yp = int(S.fipe[3]);
	l = int(S.fipe[4]);
	polygon = 'polygon(0,0,'+str(xp-l)+',0,'+str(xp-l)+','+str(yp+l);
	polygon = polygon+','+str(xp+l)+','+str(yp+l)+','+str(xp+l)+',0,';
	polygon = polygon+str(X)+',0,'+str(X)+','+str(Y)+',0,'+str(Y)+')';
	maths = mirexec.TaskMaths();
	maths.exp = model;
	maths.region = polygon;
	maths.out = 'fmod';
	tout = maths.snarf();
	acos.taskout(maths,tout,'maths.txt');
Beispiel #4
0
def selfcal(vis, model):
    selfcal = mirexec.TaskSelfCal()
    selfcal.vis = vis
    selfcal.model = model
    selfcal.options = 'amplitude'
    tout = selfcal.snarf()
    acos.taskout(selfcal, tout, 'selfcal.txt')
Beispiel #5
0
def mkpeel(a,b,c):
	'''
	Here I use uvmodel to subtract the model b from the uv-data-set a. 
	'''
	print "UVMODEL: "+a+" - "+"uv("+b+") = "+c;
	# Step 1: First we use uvcat to apply the calibration, just to make sure. 
	uvcat = mirexec.TaskUVCat();
	uvcat.vis = a; 
	uvcat.out = 'temp.uv';
	tout = uvcat.snarf();
	acos.taskout(uvcat, tout, 'peel.txt');

	# Step 2: We use the temp.uv file to subtract the model. 
	uvmodel = mirexec.TaskUVModel();
	uvmodel.vis = 'temp.uv'; 
	uvmodel.model = b; 
	uvmodel.out = c; 
	uvmodel.options = 'subtract,mfs';
	tout = uvmodel.snarf();
	acos.taskout(uvmodel, tout, 'peel.txt');
	
	# Step 3: Finally, I'm going to make a settings file just for the peel.uv:
	S = acos.settings(name=c);
	S.save();
	
	# Step 4: Now to clean up the temp.uv files.
	os.system("rm -r temp*.uv");
Beispiel #6
0
def mkpeel(a, b, c):
    '''
	Here I use uvmodel to subtract the model b from the uv-data-set a. 
	'''
    print "UVMODEL: " + a + " - " + "uv(" + b + ") = " + c
    # Step 1: First we use uvcat to apply the calibration, just to make sure.
    uvcat = mirexec.TaskUVCat()
    uvcat.vis = a
    uvcat.out = 'temp.uv'
    tout = uvcat.snarf()
    acos.taskout(uvcat, tout, 'peel.txt')

    # Step 2: We use the temp.uv file to subtract the model.
    uvmodel = mirexec.TaskUVModel()
    uvmodel.vis = 'temp.uv'
    uvmodel.model = b
    uvmodel.out = c
    uvmodel.options = 'subtract,mfs'
    tout = uvmodel.snarf()
    acos.taskout(uvmodel, tout, 'peel.txt')

    # Step 3: Finally, I'm going to make a settings file just for the peel.uv:
    S = acos.settings(name=c)
    S.save()

    # Step 4: Now to clean up the temp.uv files.
    os.system("rm -r temp*.uv")
Beispiel #7
0
def flag():
    uvflag = mirexec.TaskUVFlag()
    uvflag.vis = S.vis
    uvflag.flagval = 'flag'
    for f in S.flags.split(','):
        uvflag.select = f
        tout = uvflag.snarf()
        acos.taskout(uvflag, tout, 'uvflag.txt')
Beispiel #8
0
def flag():
	uvflag = mirexec.TaskUVFlag();
	uvflag.vis = S.vis;
	uvflag.flagval = 'flag';
	for f in S.flags.split(','):
		uvflag.select = f;
		tout = uvflag.snarf();
		acos.taskout(uvflag, tout, 'uvflag.txt');
Beispiel #9
0
def exchan(vis, ch):
    uvaver = mirexec.TaskUVAver()
    uvaver.vis = vis
    uvaver.line = 'channel,1,' + str(ch) + ',1,1'
    uvaver.out = vis.replace('.uv', '_ch' + str(ch) + '.uv')
    tout = uvaver.snarf()
    acos.taskout(uvaver, tout, 'uvaver.txt')
    return uvaver.out
Beispiel #10
0
def exchan(vis, ch):
	uvaver = mirexec.TaskUVAver();
	uvaver.vis = vis;
	uvaver.line = 'channel,1,'+str(ch)+',1,1';
	uvaver.out = vis.replace('.uv','_ch'+str(ch)+'.uv');
	tout = uvaver.snarf()
	acos.taskout(uvaver, tout, 'uvaver.txt');
	return uvaver.out;
Beispiel #11
0
def invert(vis, i):
	invert = mirexec.TaskInvert();
	invert.vis = vis;
	invert.map = vis.replace('.uv','.map'+str(i));
	invert.beam = vis.replace('.uv','.beam'+str(i));
	invert.imsize = 2048;
	invert.cell = 2;
	invert.options = 'double';
	tout = invert.snarf();
	acos.taskout(invert, tout, 'invert.txt');
Beispiel #12
0
def invert(vis, i):
    invert = mirexec.TaskInvert()
    invert.vis = vis
    invert.map = vis.replace('.uv', '.map' + str(i))
    invert.beam = vis.replace('.uv', '.beam' + str(i))
    invert.imsize = 2048
    invert.cell = 2
    invert.options = 'double'
    tout = invert.snarf()
    acos.taskout(invert, tout, 'invert.txt')
Beispiel #13
0
def ionly():
	uvfiles = S.uvfiles;
	fits = mirexec.TaskFits();
	for u in uvfiles.split(','):
		infile = u;
		fits.in_ = infile;
		outfile = u.replace(S.tag, S.retag);
		fits.out = outfile; 
		fits.op = 'uvin'; 
		tout = fits.snarf();
		acos.taskout(fits, tout, 'fits.txt');
Beispiel #14
0
def ionly():
    uvfiles = S.uvfiles
    fits = mirexec.TaskFits()
    for u in uvfiles.split(','):
        infile = u
        fits.in_ = infile
        outfile = u.replace(S.tag, S.retag)
        fits.out = outfile
        fits.op = 'uvin'
        tout = fits.snarf()
        acos.taskout(fits, tout, 'fits.txt')
Beispiel #15
0
def restor(vis, i):
	restor = mirexec.TaskRestore();
	restor.model = vis.replace('.uv','.model'+str(i))
	restor.beam = vis.replace('.uv','.beam'+str(i))
	restor.map = vis.replace('.uv','.map'+str(i))
	restor.out = vis.replace('.uv', '.image'+str(i))
	tout = restor.snarf();
	acos.taskout(restor, tout, 'restor.txt');
	restor.mode = 'residual';
	restor.out = vis.replace('.uv','.res'+str(i));
	tout = restor.snarf();
	acos.taskout(restor, tout, 'restor.txt');
Beispiel #16
0
def restor(vis, i):
    restor = mirexec.TaskRestore()
    restor.model = vis.replace('.uv', '.model' + str(i))
    restor.beam = vis.replace('.uv', '.beam' + str(i))
    restor.map = vis.replace('.uv', '.map' + str(i))
    restor.out = vis.replace('.uv', '.image' + str(i))
    tout = restor.snarf()
    acos.taskout(restor, tout, 'restor.txt')
    restor.mode = 'residual'
    restor.out = vis.replace('.uv', '.res' + str(i))
    tout = restor.snarf()
    acos.taskout(restor, tout, 'restor.txt')
Beispiel #17
0
def clean(vis, cutoff, i):
	# Remove the old model
	#cmd = 'rm -r '+vis.replace('.uv', '.model'+str(i))
	#os.system(cmd)
	clean = mirexec.TaskClean();
	clean.vis = vis;
	clean.beam = vis.replace('.uv','.beam'+str(i));
	clean.map = vis.replace('.uv','.map'+str(i));
	clean.out = vis.replace('.uv','.model'+str(i));
	clean.cutoff = cutoff;
	tout = clean.snarf();
	acos.taskout(clean, tout, 'clean.txt');
Beispiel #18
0
def clean(vis, cutoff, i):
    # Remove the old model
    #cmd = 'rm -r '+vis.replace('.uv', '.model'+str(i))
    #os.system(cmd)
    clean = mirexec.TaskClean()
    clean.vis = vis
    clean.beam = vis.replace('.uv', '.beam' + str(i))
    clean.map = vis.replace('.uv', '.map' + str(i))
    clean.out = vis.replace('.uv', '.model' + str(i))
    clean.cutoff = cutoff
    tout = clean.snarf()
    acos.taskout(clean, tout, 'clean.txt')
Beispiel #19
0
def getuvspw():
    uvaver = mirexec.TaskUVAver()
    for f in S.uvfiles.split(','):
        print "Extracting " + str(S.line) + " from " + f
        # Now to extract the spectral range using uvaver
        uvaver.vis = f
        uvaver.line = S.line
        uvaver.out = f.replace(S.tag, S.retag)
        tout = uvaver.snarf()
        acos.taskout(uvaver, tout, 'uvaver')
        # Delete the old file
        cmd = 'rm -r ' + f
        os.system(cmd)
Beispiel #20
0
def pgflag(vis, flagpar):
    if params.log == None:
        params.log = vis + '.pgflag.txt'
    pgflag = mirexec.TaskPGFlag()
    pgflag.vis = vis
    pgflag.stokes = params.stokes
    pgflag.flagpar = flagpar
    pgflag.options = 'nodisp'

    # This specifies the SumThresholding command.
    pgflag.command = '<'
    print pgflag.__dict__
    tout = pgflag.snarf()
    acos.taskout(pgflag, tout, params.log)
Beispiel #21
0
def pgflag(vis, flagpar):
	if params.log==None:
		params.log = vis+'.pgflag.txt' 
	pgflag = mirexec.TaskPGFlag()
	pgflag.vis = vis
	pgflag.stokes = params.stokes
	pgflag.flagpar = flagpar
	pgflag.options = 'nodisp'

	# This specifies the SumThresholding command.
	pgflag.command = '<'
	print pgflag.__dict__
	tout = pgflag.snarf();
	acos.taskout(pgflag, tout, params.log)
Beispiel #22
0
def pgflag(params):
    if params.log == None:
        # This default naming convention is a little clumsy, but at
        # least its clear what's happening here.
        params.log = params.vis + '.pgflaglog.txt'
    pgflag = mirexecb.TaskPGFlag()
    pgflag.vis = params.vis
    pgflag.select = params.select
    pgflag.stokes = params.stokes
    pgflag.flagpar = params.flagpar
    pgflag.options = params.options

    # This specifies the SumThresholding command.
    pgflag.command = '<'
    tout = pgflag.snarf()
    acos.taskout(pgflag, tout, options.log)
Beispiel #23
0
def pgflag(params):
	if params.log==None:
		# This default naming convention is a little clumsy, but at
		# least its clear what's happening here. 
		params.log = params.vis+'.pgflaglog.txt';
	pgflag = mirexecb.TaskPGFlag();
	pgflag.vis = params.vis;
	pgflag.select = params.select;
	pgflag.stokes = params.stokes; 
	pgflag.flagpar = params.flagpar;
	pgflag.options = params.options;
	
	# This specifies the SumThresholding command.
	pgflag.command = '<';
	tout = pgflag.snarf();
	acos.taskout(pgflag, tout, options.log)
Beispiel #24
0
def fp_models(ppoly,fpoly,model):
	'''
	Uses the vertices defined in pgon to  
	'''
	maths = mirexec.TaskMaths();
	maths.exp = model;
	maths.mask = model;
	maths.region=ppoly;
	maths.out=model.replace("src","src_p");
	tout = restor.snarf();
	acos.taskout(maths,tout,'maths.txt');
	
	maths = mirexec.TaskMaths();
	maths.exp = model;
	maths.mask = model;
	maths.region=fpoly;
	maths.out=model.replace("src","src_f");
	tout = restor.snarf();
	acos.taskout(maths,tout,'maths.txt');
Beispiel #25
0
def fp_models(ppoly, fpoly, model):
    '''
	Uses the vertices defined in pgon to  
	'''
    maths = mirexec.TaskMaths()
    maths.exp = model
    maths.mask = model
    maths.region = ppoly
    maths.out = model.replace("src", "src_p")
    tout = restor.snarf()
    acos.taskout(maths, tout, 'maths.txt')

    maths = mirexec.TaskMaths()
    maths.exp = model
    maths.mask = model
    maths.region = fpoly
    maths.out = model.replace("src", "src_f")
    tout = restor.snarf()
    acos.taskout(maths, tout, 'maths.txt')
Beispiel #26
0
def mkpuv():
    '''
	For a chan0, applies the gains and then subtracts all the sources
	to provide a uv file with the source to be peeled. 	
	'''
    # First, apply the current gains.
    uvcat = mirexec.TaskUVCat()
    uvcat.vis = S.vis
    uvcat.out = S.vis + '_sc'
    tout = uvcat.snarf()
    acos.taskout(uvcat, tout, 'uvcat.txt')

    # Second, subtract the model from the new uv-file
    uvmodel = mirexec.TaskUVModel()
    uvmodel.vis = S.vis + '_sc'
    #TODO: Need to include pmod in the settings file.
    uvmodel.model = 'fmod'
    uvmodel.options = 'subtract'
    uvmodel.out = 'puv'
    tout = uvmodel.snarf()
    acos.taskout(uvmodel, tout, 'uvmodel.txt')
Beispiel #27
0
def mkpuv():
	'''
	For a chan0, applies the gains and then subtracts all the sources
	to provide a uv file with the source to be peeled. 	
	'''
	# First, apply the current gains. 
	uvcat = mirexec.TaskUVCat();
	uvcat.vis=S.vis;
	uvcat.out = S.vis+'_sc';
	tout = uvcat.snarf();
	acos.taskout(uvcat, tout, 'uvcat.txt');
	
	# Second, subtract the model from the new uv-file
	uvmodel = mirexec.TaskUVModel();
	uvmodel.vis = S.vis+'_sc';
	#TODO: Need to include pmod in the settings file. 
	uvmodel.model = 'fmod'; 
	uvmodel.options='subtract';
	uvmodel.out = 'puv';
	tout = uvmodel.snarf();
	acos.taskout(uvmodel, tout, 'uvmodel.txt');
Beispiel #28
0
def mkfield(a, b, c, g):
	'''
	Here I use uvmodel to subtract the model b from the uv-data-set a. 
	This also copies the gain over, subtracts the source and then undoes the gain. 
	'''
	# Step 0: We need to ensure that any previous selfcal calibration gets applied
	# to the uv-data-set a. 
	uvcat = mirexec.TaskUVCat();
	uvcat.vis = a; 
	uvcat.out = 'temp2.uv';
	tout = uvcat.snarf();
	acos.taskout(uvcat, tout, 'peel.txt');

	# Step 1: First we copy the calibration from g to the uv-data-set a:
	
	gpcopy = mirexec.TaskGPCopy();
	gpcopy.vis = g; 
	gpcopy.out = 'temp2.uv';
	tout = gpcopy.snarf();
	acos.taskout(gpcopy, tout, 'peel.txt');
	
	# Step 2: Use uvcat to apply the gains, creating a temporary uv-file. 
	uvcat = mirexec.TaskUVCat();
	uvcat.vis = 'temp2.uv';
	uvcat.out = 'temp3.uv';
	tout = uvcat.snarf();
	acos.taskout(uvcat, tout, 'peel.txt');

	# Step 3: Subtract the model pmod from the temporary uv-file. 
	uvmodel = mirexec.TaskUVModel();
	uvmodel.vis = 'temp3.uv';
	uvmodel.out = 'temp4.uv';
	uvmodel.model = b;
	uvmodel.options = 'subtract,mfs';
	tout = uvmodel.snarf();
	acos.taskout(uvmodel, tout, 'peel.txt');
	
 	# Step 4: This is a hack: We use atnf-gpedit (agpedit) to copy and invert the gains from g. 
	gpcopy.vis = g;
	gpcopy.out = 'temp4.uv';
	tout = gpcopy.snarf();
	acos.taskout(gpcopy, tout, 'peel.txt');

	cmd = './agpedit vis=temp4.uv options=invert';
	os.system(cmd);

	# Step 5: We use uvcat to make the desired uv-data-set. 
	uvcat.vis = 'temp4.uv';
	uvcat.out = c;
	tout = uvcat.snarf();
	acos.taskout(uvcat, tout, 'peel.txt');
	
	# Step 6: Finally, I make a settings file for c:
	S = acos.settings(name=c);
	S.save();
	print "DONE"

	# Step 7: Cleanup temp.uv and temp3.uv temp4.uv
	os.system("rm -r temp*.uv");
Beispiel #29
0
def selfcalcopy():
	gpcopy = mirexec.TaskGPCopy();
	gpcopy.vis = S.chan0;
	gpcopy.out = S.vis;
	tout = gpcopy.snarf();
	acos.taskout(gpcopy, tout, 'gpcopy');
Beispiel #30
0
def selfcalcopy():
    gpcopy = mirexec.TaskGPCopy()
    gpcopy.vis = S.chan0
    gpcopy.out = S.vis
    tout = gpcopy.snarf()
    acos.taskout(gpcopy, tout, 'gpcopy')
Beispiel #31
0
def mkfield(a, b, c, g):
    '''
	Here I use uvmodel to subtract the model b from the uv-data-set a. 
	This also copies the gain over, subtracts the source and then undoes the gain. 
	'''
    # Step 0: We need to ensure that any previous selfcal calibration gets applied
    # to the uv-data-set a.
    uvcat = mirexec.TaskUVCat()
    uvcat.vis = a
    uvcat.out = 'temp2.uv'
    tout = uvcat.snarf()
    acos.taskout(uvcat, tout, 'peel.txt')

    # Step 1: First we copy the calibration from g to the uv-data-set a:

    gpcopy = mirexec.TaskGPCopy()
    gpcopy.vis = g
    gpcopy.out = 'temp2.uv'
    tout = gpcopy.snarf()
    acos.taskout(gpcopy, tout, 'peel.txt')

    # Step 2: Use uvcat to apply the gains, creating a temporary uv-file.
    uvcat = mirexec.TaskUVCat()
    uvcat.vis = 'temp2.uv'
    uvcat.out = 'temp3.uv'
    tout = uvcat.snarf()
    acos.taskout(uvcat, tout, 'peel.txt')

    # Step 3: Subtract the model pmod from the temporary uv-file.
    uvmodel = mirexec.TaskUVModel()
    uvmodel.vis = 'temp3.uv'
    uvmodel.out = 'temp4.uv'
    uvmodel.model = b
    uvmodel.options = 'subtract,mfs'
    tout = uvmodel.snarf()
    acos.taskout(uvmodel, tout, 'peel.txt')

    # Step 4: This is a hack: We use atnf-gpedit (agpedit) to copy and invert the gains from g.
    gpcopy.vis = g
    gpcopy.out = 'temp4.uv'
    tout = gpcopy.snarf()
    acos.taskout(gpcopy, tout, 'peel.txt')

    cmd = './agpedit vis=temp4.uv options=invert'
    os.system(cmd)

    # Step 5: We use uvcat to make the desired uv-data-set.
    uvcat.vis = 'temp4.uv'
    uvcat.out = c
    tout = uvcat.snarf()
    acos.taskout(uvcat, tout, 'peel.txt')

    # Step 6: Finally, I make a settings file for c:
    S = acos.settings(name=c)
    S.save()
    print "DONE"

    # Step 7: Cleanup temp.uv and temp3.uv temp4.uv
    os.system("rm -r temp*.uv")