def antsortsn(inname='UVSIM', inclass='FITS', indi=1, inseq=1, invers=1): w = WizAIPSUVData(inname, inclass, indisk, inseq) sn = w.table('SN', invers) anno = 8 ### starting no of international station print 'i[refant]', i['refant_1'] for i in sn: #print 'i[refant]', i['refant_1']; #print 'i[antenna_no]', i['antenna_no']; #print 'anno: ', anno i['refant_1'] = 16 i['refant_2'] = 16 i['antenna_no'] = anno if anno == 16: anno = 8 else: anno = anno + 1 i.update()
from Wizardry.AIPSData import AIPSUVData import numpy as np import sys import matplotlib.pyplot as plt AIPS.userno = 666 uvdata = AIPSUVData('VO0051', 'UVDATA', 1, 1) # Get number of IFs nif=uvdata.header['naxis'][uvdata.header['ctype'].index('IF')] # Get lower-edge frequencies for these IFS freq0=uvdata.header['crval'][uvdata.header['ctype'].index('FREQ')] FQ=uvdata.table('FQ', 1) freqs = (np.array(FQ[0]['if_freq']) + freq0 )/1e6 # Mhz #print freqs # Calculate the channels with pcal signal (need to be removed) pcalch0 = 5- (freqs % 5) - 1 #print pcalch0 pcalch0 = np.round(pcalch0).astype(np.int) #print pcalch0 print "START" ts = [] for row in uvdata: adata = [] if not (row.baseline[0]==row.baseline[1]): # Ignore autocorrs for j in range(nif): # loop through IFs
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()
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 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
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
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) finally: uvdata.zap()
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()
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) finally: uvdata.zap()
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')