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")
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')
def cal2srcs(config): ''' ''' # puthd on src cal = config.get('mfiles', 'cal1') src = config.get('mfiles', 'src') puthd = mirexec.TaskPutHead() puthd.in_ = src + '/restfreq' puthd.value = 1.420405752 puthd.snarf() puthd.in_ = src + '/interval' puthd.value = 1.0 puthd.type = 'double' puthd.snarf() # gpcopy cal1 -> src gpcopy = mirexec.TaskGPCopy() gpcopy.vis = cal gpcopy.out = src gpcopy.snarf()
def selfcalcopy(): gpcopy = mirexec.TaskGPCopy() gpcopy.vis = S.chan0 gpcopy.out = S.vis tout = gpcopy.snarf() acos.taskout(gpcopy, tout, 'gpcopy')