Beispiel #1
0
def frf_data(data):  #FRF FULL LENGTH DATA
    aa2 = a.cal.get_aa(opts.cal, freqs)  #All freqs for data instead of subset
    bins = fringe.gen_frbins(inttime)
    frp, bins = fringe.aa_to_fr_profile(aa2, ij, len(freqs) / 2, bins=bins)
    timebins, firs = fringe.frp_to_firs(frp,
                                        bins,
                                        aa2.get_freqs(),
                                        fq0=aa2.get_freqs()[len(freqs) / 2])
    _, blconj, _ = zsa.grid2ij(aa2.ant_layout)
    if blconj[a.miriad.ij2bl(ij[0], ij[1])]:
        fir = {(ij[0], ij[1], POL): n.conj(firs)}
    else:
        fir = {(ij[0], ij[1], POL): firs}
    dij = n.transpose(data)
    wij = n.ones(dij.shape, dtype=bool)  #XXX flags are all true (times,freqs)
    #dij and wij are (times,freqs)
    _d, _w, _, _ = fringe.apply_frf(aa2,
                                    dij,
                                    wij,
                                    ij[0],
                                    ij[1],
                                    pol=POL,
                                    bins=bins,
                                    firs=fir)
    _d = n.transpose(_d)
    return _d
Beispiel #2
0
def frf_data(data): #FRF FULL LENGTH DATA
    aa2 = a.cal.get_aa(opts.cal, freqs) #All freqs for data instead of subset
    bins = fringe.gen_frbins(inttime)
    frp, bins = fringe.aa_to_fr_profile(aa2, ij, len(freqs)/2, bins=bins)
    timebins, firs = fringe.frp_to_firs(frp, bins, aa2.get_freqs(), fq0=aa2.get_freqs()[len(freqs)/2])
    _,blconj,_ = zsa.grid2ij(aa2.ant_layout)
    if blconj[a.miriad.ij2bl(ij[0],ij[1])]: fir = {(ij[0],ij[1],POL):n.conj(firs)}
    else: fir = {(ij[0],ij[1],POL):firs}
    dij = n.transpose(data)
    wij = n.ones(dij.shape,dtype=bool) #XXX flags are all true (times,freqs)
    #dij and wij are (times,freqs)
    _d,_w,_,_ = fringe.apply_frf(aa2,dij,wij,ij[0],ij[1],pol=POL,bins=bins,firs=fir)
    _d = n.transpose(_d)
    return _d
Beispiel #3
0
def getBaselines(freqs, intSeps, exampleDataFile, calFile='psa6622_v003'):
    aa = a.cal.get_aa(calFile, freqs)
    blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout)
    m, _, mdl,_= omni.from_npz(exampleDataFile)
    bls = [(0,i) for i in intSeps]
    for ij in mdl['xx'].keys():
        bl = a.miriad.ij2bl(ij[0],ij[1]) 
        try:
            s = tuple(map(int,bl2sep[bl].split(',')))
        except(KeyError):
            continue
        if s in bls and s[0] == 0:
            bls[s[-1]-1] = ij
    return bls
Beispiel #4
0
def getBaselines(freqs, intSeps, exampleDataFile, calFile='psa6622_v003'):
    aa = a.cal.get_aa(calFile, freqs)
    blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout)
    m, _, mdl, _ = omni.from_npz(exampleDataFile)
    bls = [(0, i) for i in intSeps]
    for ij in mdl['xx'].keys():
        bl = a.miriad.ij2bl(ij[0], ij[1])
        try:
            s = tuple(map(int, bl2sep[bl].split(',')))
        except (KeyError):
            continue
        if s in bls and s[0] == 0:
            bls[s[-1] - 1] = ij
    return bls
Beispiel #5
0
inttime = (t2-t1) * (3600*24)
del(uv)

afreqs = freqs.take(chans)
nchan = chans.size
fq = n.average(afreqs)
z = capo.pspec.f2z(fq)

# aa = a.cal.get_aa(opts.cal, n.array([.150]))
aa = a.cal.get_aa(opts.cal, afreqs)
bls, conj = capo.red.group_redundant_bls(aa.ant_layout)
jy2T = capo.pspec.jy2T(afreqs)
window = a.dsp.gen_window(nchan, WINDOW)
if not WINDOW == 'none':
    window.shape = (nchan, 1)
sep2ij, blconj, bl2sep = zsa.grid2ij(aa.ant_layout)

# B = sdf * afreqs.size / capo.pfb.NOISE_EQUIV_BW[WINDOW]
# this is wrong if we aren't inverting
# the window post delay transform
# (or at least dividing out by the gain of the window)
# For windowed data, the FFT divides out by the full bandwidth, B, which is
# then squared.
# Proper normalization is to multiply by
# B**2 / (B / NoiseEqBand) = B * NoiseEqBand
# XXX NEED TO FIGURE OUT BW NORMALIZATION
B = sdf * afreqs.size * capo.pfb.NOISE_EQUIV_BW[WINDOW]  # proper normalization
etas = n.fft.fftshift(capo.pspec.f2eta(afreqs))
# create etas (fourier dual to frequency)
# etas = capo.pspec.f2eta(afreqs) #create etas (fourier dual to frequency)
kpl = etas * capo.pspec.dk_deta(z)  # 111
Beispiel #6
0
#! /usr/bin/env python -u
import numpy as n
import aipy as a
import optparse, sys
import capo.omni as omni, capo.zsa as zsa, capo.arp as arp
import pylab as p

o = optparse.OptionParser()
a.scripting.add_standard_options(o, cal=True)
opts, args = o.parse_args(sys.argv[1:])

pol = 'xx'
freqs = n.arange(.1, .2, .1 / 203)
aa = a.cal.get_aa('psa6622_v003', freqs)
blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout)
_, _, mdl, _, jds, lsts, freqs = omni.from_npz(args[0])
seps = n.arange(1, 16)  #* 15m  = baseline lengths
bls = [(0, i) for i in seps]
sep2ij = {}
for ij in mdl['xx'].keys():
    bl = a.miriad.ij2bl(ij[0], ij[1])
    try:
        s = tuple(map(int, bl2sep[bl].split(',')))
    except (KeyError):
        continue
    if s in bls and s[0] == 0:
        bls[s[-1] - 1] = ij

print bls
conjugate = [(0, 101), (0, 62), (0, 100), (0, 97), (12, 43), (57, 64)]
Beispiel #7
0
    scalar = 1
if not DELAY:
    # XXX this is a hack
    if WINDOW == 'hamming':
        scalar /= 3.67
    elif WINDOW == 'blackman-harris':
        scalar /= 5.72
print 'Freq:', fq
print 'z:', z
print 'B:', B
print 'scalar:', scalar
sys.stdout.flush()

# Prep FRF Stuff
antstr = 'cross'
_, blconj, _ = zsa.grid2ij(aa.ant_layout)
days = dsets.keys()
s,d,f = capo.miriad.read_files([dsets[days[0]][0]], antstr=antstr, polstr=POL) # read first file
ij = d.keys()[0] # use first baseline
if blconj[a.miriad.ij2bl(ij[0], ij[1])]:
    # makes sure FRP will be the same whether bl is a conjugated one or not
    if ij[0] < ij[1]:
        temp = (ij[1], ij[0])
        ij = temp
sep_type = bl2sep[a.miriad.ij2bl(ij[0], ij[1])]
# convert uvw in light-nanoseconds to m, (cosmo_units.c in m/s)
uvw = aa.get_baseline(ij[0], ij[1], src='z') * cosmo_units.c * 1e-9
bins = fringe.gen_frbins(inttime)
mychan = 101 # XXX use this to match frf_filter.py
frp, bins = fringe.aa_to_fr_profile(aa, ij, mychan, bins=bins)
timebins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(),
Beispiel #8
0
(uvw, t2, (i, j)), d = uv.read()
while t1 == t2:
    (uvw, t2, (i, j)), d = uv.read()
data_inttime = (t2 - t1) * (3600 * 24)
#manually calculate the inttime so frf time bins match data
if opts.inttime: inttime = opts.inttime
else: inttime = float(data_inttime)
del (uv)
#inttime=50.

#set channel to make frf
if opts.chan: mychan = int(opts.chan)
else: mychan = 101

#Get only the antennas of interest
sep2ij, blconj, bl2sep = zsa.grid2ij(aa.ant_layout)
print "Using normalization for old FRF: ", opts.alietal

print "Looking for baselines matching ", opts.ant
ants = [b[0] for b in a.scripting.parse_ants(opts.ant, nants)]
seps = [bl2sep[b] for b in ants]
seps = n.unique(seps)
print 'These are the spearations that we are going to use ', seps
print 'This is the channel we are using to build the frf: ', mychan
print 'Current inttime use for gen_frbins: ', inttime
#Get the fir filters for the separation used.

baselines = ''.join(sep2ij[sep] for sep in seps)
times, data, flags = zsa.get_dict_of_uv_data(args,
                                             baselines,
                                             pol,
Beispiel #9
0
if not DELAY:
    # XXX this is a hack
    if WINDOW == 'hamming': scalar /= 3.67
    elif WINDOW == 'blackman-harris': scalar /= 5.72
print 'Freq:', fq
print 'z:', z
print 'B:', B
print 'scalar:', scalar
sys.stdout.flush()

#Acquire data
data_dict = {}
flg_dict = {}
conj_dict = {}
antstr = 'cross'
_, blconj, _ = zsa.grid2ij(aa.ant_layout)
days = dsets.keys()
lsts, data, flgs = {}, {}, {}
for k in days:
    lsts[k], data[k], flgs[k] = capo.miriad.read_files(dsets[k],
                                                       antstr=antstr,
                                                       polstr=POL,
                                                       verbose=True)
    lsts[k] = n.array(lsts[k]['lsts'])
    for bl in data[k]:
        d = n.array(data[k][bl][POL])[:,
                                      chans] * jy2T  #extract frequency range
        flg = n.array(flgs[k][bl][POL])[:, chans]
        key = (k, bl, POL)
        data_dict[key] = d
        flg_dict[key] = n.logical_not(flg)
Beispiel #10
0
#! /usr/bin/env python
import numpy as n
import aipy as a
import optparse,sys
import capo.omni as omni, capo.zsa as zsa, capo.arp as arp
import pylab as p, os

o = optparse.OptionParser()
a.scripting.add_standard_options(o, cal=True)
opts,args = o.parse_args(sys.argv[1:])


pol='xx'
freqs = n.arange(.1,.2,.1/203)
aa = a.cal.get_aa('psa6622_v003', freqs)
blstr, _, bl2sep = zsa.grid2ij(aa.ant_layout)
m, _, mdl,_= omni.from_npz(args[0])
seps = n.arange(1,16) #* 15m  = baseline lengths
bls = [(0,i) for i in seps]
sep2ij = {}
for ij in mdl['xx'].keys():
    bl = a.miriad.ij2bl(ij[0],ij[1]) 
    try:
        s = tuple(map(int,bl2sep[bl].split(',')))
    except(KeyError):
        continue
    if s in bls and s[0] == 0:
        bls[s[-1]-1] = ij

#print bls
conjugate = [(0,101), (0,62), (0,100), (0,97), (12,43), (57,64)]