uvsub.in2data = imagedatacl uvsub.inver = 1 uvsub.outdisk = indisk uvsub.ncomp[1] = -1000000 uvsub.opcode = "DIV" uvsub.go() uvdata = AIPSUVData(uvname[i], "UVSUB", indisk, 1) # wtmod = AIPSTask('WTMOD') #change weight relative to amplitude adjustments # wtmod.indata = uvdata # wtmod.aparm[1] = (maxamplitude(uvname[i])**2)*(10**10) # wtmod.outdisk = indisk # wtmod.go() # uvdata = AIPSUVData(uvname[i],'WTMOD',2,1) uvdata2 = WizAIPSUVData(uvname[i], "UVSUB", indisk, 1) uvdata2.header["crval"][4] = pointcenRA uvdata2.header.update() uvdata2.header["crval"][5] = pointcenDEC uvdata2.header.update() uvdata.rename(name="COMBO", klass="UV", seq=0) if len(uvname) > 1: dbapp = AIPSTask("DBAPP") uvdata = AIPSUVData("COMBO", "UV", indisk, 1) dbapp.inname = "COMBO" dbapp.inclass = "UV" dbapp.indisk = indisk dbapp.inseq = 2 dbapp.in2seq = len(uvname) dbapp.outdata = uvdata dbapp.outdisk = indisk
uvsub.in2data = imagedatacl uvsub.inver = 1 uvsub.outdisk = 2 uvsub.ncomp[1] = -1000000 uvsub.opcode = 'DIV' uvsub.go() uvdata = AIPSUVData(uvname[i],'UVSUB',2,1) wtmod = AIPSTask('WTMOD') #change weight relative to amplitude adjustments wtmod.indata = uvdata wtmod.aparm[1] = (maxamplitude(uvname[i])**2)*(10**10) wtmod.outdisk = 2 wtmod.go() uvdata = AIPSUVData(uvname[i],'WTMOD',2,1) uvdata2 = WizAIPSUVData(uvname[i], 'WTMOD',2,1) uvdata2.header['crval'][4] = pointcenRA uvdata2.header.update() uvdata2.header['crval'][5] = pointcenDEC uvdata2.header.update() uvdata.rename(name='COMBO',klass='UV', seq=0) if len(uvname) > 1: dbapp = AIPSTask('DBAPP') uvdata = AIPSUVData('COMBO','UV',2,1) dbapp.inname = 'COMBO' dbapp.inclass = 'UV' dbapp.indisk = 2 dbapp.inseq = 2 dbapp.in2seq = len(uvname) dbapp.outdata = uvdata dbapp.outdisk = 2
def dfluxpy(freq,uvdata): "Function to calculate 3C286 values, modified from Danielle's dfluxpy.py." "Updated 20140506 to include new coefficients and a calculation for projected" "baseline length from inspecting the u's and v's." data=WizAIPSUVData(uvdata.name, uvdata.klass, uvdata.disk, uvdata.seq) antab = data.table('AN',1) numLO = 10 numM2 = 10 for row in antab: # Ignore the Lovell baselines if 'Lo' in row.anname: numLO = row.nosta if 'Mk2' in row.anname: numM2 = row.nosta u=[] v=[] proj=[] basel = [] baseline = 10000000 for visibility in data: if ( visibility.baseline != [numLO, numM2] ) and ( visibility.baseline != [numM2, numLO] ): u.append(visibility.uvw[0]) v.append(visibility.uvw[1]) newbasel = (299792458.0/data.header.crval[2]) * math.sqrt((visibility.uvw[0] ** 2) + (visibility.uvw[1] ** 2)) proj.append( newbasel ) if newbasel < baseline: baseline = newbasel basel = visibility.baseline antab = data.table('AN',1) for row in antab: if row.nosta == basel[0]: ant1=row.anname for row in antab: if row.nosta == basel[1]: ant2=row.anname print "For projected baseline", baseline/1000, "km, between", ant1, "and", ant2 ###################################### # Perley & Butler 2012 values A = 1.2515 B = -0.4605 C = -0.1715 D = 0.0336 log10f = (math.log(freq)/2.3025851) - 3.0; # Why the -3? Because freq has to be GHz for the formula to work. log_flux = A + B*log10f + C*log10f*log10f + D*log10f*log10f*log10f vlaflux = math.pow(10.0,log_flux) ref_bl_length = 11236.79 # MK-TA separation in metres. ref_freq = 5000.0 ref_rho = 0.04 # thisbl = "this baseline (Mk-Ta)" bl_length = baseline frac = (freq / ref_freq) * (bl_length / ref_bl_length) rho = frac * frac * ref_rho merlinflux = vlaflux / (1.0 + rho) print "\tfor IF with freq =", freq, ", e-MERLIN flux =", merlinflux return merlinflux
uvflg() uvflg.stokes = 'RL' uvflg() print uvdata.tables fqtable = uvdata.table('FQ', 0) print fqtable[0] fgtable = uvdata.table('FG', 0) for row in fgtable: print row continue assert (fgtable[0].pflags == [0, 0, 1, 1]) assert (fgtable[1]['pflags'] == [0, 0, 1, 0]) uvdata2 = WAIPSUVData(uvdata.name, uvdata.klass, uvdata.disk, uvdata.seq) fgtable = uvdata2.table('FG', 0) row = fgtable[1] row.ants = [2, 0] fgtable.append(row) fgtable.close() fgtable = uvdata.table('FG', 0) for row in fgtable: print row continue assert (fgtable[2].ants == [2, 0]) finally: uvdata.zap()
uvsub.inver = 1 uvsub.outdisk = 2 uvsub.ncomp[1] = -1000000 uvsub.opcode = 'DIV' uvsub.go() uvdata = AIPSUVData(uvname[i], 'UVSUB', 2, 1) wtmod = AIPSTask( 'WTMOD') #change weight relative to amplitude adjustments wtmod.indata = uvdata wtmod.aparm[1] = (maxamplitude(uvname[i])**2) * (10**10) wtmod.outdisk = 2 wtmod.go() uvdata = AIPSUVData(uvname[i], 'WTMOD', 2, 1) uvdata2 = WizAIPSUVData(uvname[i], 'WTMOD', 2, 1) uvdata2.header['crval'][4] = pointcenRA uvdata2.header.update() uvdata2.header['crval'][5] = pointcenDEC uvdata2.header.update() uvdata.rename(name='COMBO', klass='UV', seq=0) if len(uvname) > 1: dbapp = AIPSTask('DBAPP') uvdata = AIPSUVData('COMBO', 'UV', 2, 1) dbapp.inname = 'COMBO' dbapp.inclass = 'UV' dbapp.indisk = 2 dbapp.inseq = 2 dbapp.in2seq = len(uvname) dbapp.outdata = uvdata dbapp.outdisk = 2
delay_directory = "./" except KeyError: delay_directory = "./" delays = {} for s in cfg['stations']: filename = delay_directory + '/' + cfg['exper_name'] + '_' + s + '.del' print 'open delay for station ', s, ' : file = ', filename file = open(filename, 'r+') hsize = struct.unpack('i', file.read(4))[0] header = file.read(hsize) delays[s.upper()] = file a = cfg['aips'] AIPS.userno = a['user_nr'] uvdata = AIPSUVData(a['name'].encode('ascii'), a['class'].encode('ascii'), a['disk'], a['seq']) return delays, uvdata def get_cl(uvdata): cl = uvdata.table('CL', 0) nstation = len(uvdata.antennas) #scan = [[[]]*2]*nstation scan = [[[] for j in range(4)] for i in range(nstation)] #pdb.set_trace() cal = [] start_obs = [int(t) for t in uvdata.header.date_obs.split('-')] t0 = datetime.datetime(start_obs[0], start_obs[1], start_obs[2]) time = [cl[0].time] source_old = cl[0].source_id previous_antenna = -1
assert([3, 'AIPS CL'] in uvdata.tables) uvdata.zap_table('CL', 1) assert([3, 'AIPS CL'] in uvdata.tables) assert([1, 'AIPS CL'] not in uvdata.tables) tacop = AIPSTask('tacop') tacop.indata = uvdata tacop.outdata = uvdata tacop.inext = 'CL' tacop.invers = 3 tacop.outvers = 5 tacop() uvdata2 = WAIPSUVData(uvdata.name, uvdata.klass, uvdata.disk, uvdata.seq) assert([5, 'AIPS CL'] in uvdata2.tables) uvdata2.zap_table('CL', 0) assert([5, 'AIPS CL'] not in uvdata2.tables) assert([3, 'AIPS CL'] in uvdata2.tables) assert([1, 'AIPS CL'] not in uvdata2.tables) count = 0 for cl in uvdata2.table('CL', 3): count += 1 continue assert(count > 0)
from AIPS import AIPS from AIPSData import AIPSUVData from Wizardry.AIPSData import AIPSUVData as WAIPSUVData AIPS.userno = 100 if __name__ == '__main__': data = WAIPSUVData('MULTI', 'MSORT ', 1, 1) sntable = data.table('SN', 1) n = 0 with open('delay.txt', 'w') as f: f.write('# pulse antenna delay(s) weight\n') for item in sntable: if item['antenna_no'] == 1: # next pulse n += 1 if item['antenna_no'] in [1, 3, 4, 7]: delay = item['delay_1'][0] weight = item['weight_1'][0] if not (delay > 1 or delay == 0.): f.write( str(n) + ' ' + ' ' + str(item['antenna_no']) + ' ' + str(delay) + ' ' + str(weight) + '\n')