Пример #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
Пример #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
Пример #3
0
    def test_get_beam_w_fr(self):
        #interps = fringe.get_beam_w_fr(self.aa, (1,4), ref_chan=160)
        #t,firs, frbins, frspace = fringe.get_fringe_rate_kernels(interps, 42.9, 401)
        frp, bins = fringe.aa_to_fr_profile(self.aa, (1,4), 100) 
        print "the bins",len(bins), len(frp)
        timebins, firs = fringe.frp_to_firs(frp, bins, self.aa.get_freqs(), fq0=self.aa.get_freqs()[100])
        print len(timebins), len(firs[100])
        frp_fit = fringe.fir_to_frp(firs[100])
#        print n.ones_like(frspace).sum()
#        print n.sum(frp**2)
        p.subplot(121)
        p.plot(timebins, firs[100])
        p.plot(timebins, n.abs(firs[100]))
        p.subplot(122)
        print len(bins), bins[0], bins[-1]
        p.plot(bins, frp, 'k')
        p.plot(bins, frp_fit, 'b', label='new')
        p.xlim(-.0005,.0020)
        p.ylim(0.0,1.0)
        p.legend()
        p.show()
Пример #4
0
 def test_get_beam_w_fr(self):
     #interps = fringe.get_beam_w_fr(self.aa, (1,4), ref_chan=160)
     #t,firs, frbins, frspace = fringe.get_fringe_rate_kernels(interps, 42.9, 401)
     frp, bins = fringe.aa_to_fr_profile(self.aa, (1, 4), 100)
     print "the bins", len(bins), len(frp)
     timebins, firs = fringe.frp_to_firs(frp,
                                         bins,
                                         self.aa.get_freqs(),
                                         fq0=self.aa.get_freqs()[100])
     print len(timebins), len(firs[100])
     frp_fit = fringe.fir_to_frp(firs[100])
     #        print n.ones_like(frspace).sum()
     #        print n.sum(frp**2)
     p.subplot(121)
     p.plot(timebins, firs[100])
     p.plot(timebins, n.abs(firs[100]))
     p.subplot(122)
     print len(bins), bins[0], bins[-1]
     p.plot(bins, frp, 'k')
     p.plot(bins, frp_fit, 'b', label='new')
     p.xlim(-.0005, .0020)
     p.ylim(0.0, 1.0)
     p.legend()
     p.show()
Пример #5
0
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c += 1
        else: break
    print mychan, ij, opts.bl_scale
    frp, bins = fringe.aa_to_fr_profile(aa,
                                        ij,
                                        mychan,
                                        bins=frbins,
                                        pol=opts.pol,
                                        bl_scale=opts.bl_scale)
    timebins, firs[sep] = fringe.frp_to_firs(
        frp,
        bins,
        aa.get_afreqs(),
        fq0=aa.get_afreqs()[mychan],
        bl_scale=opts.bl_scale,
        fr_width_scale=opts.fr_width_scale,
        alietal=opts.alietal,
        maxfr=opts.maxfr)

    frp = fringe.fir_to_frp(firs[sep])
    if opts.boxcar:
        print 'Making Boxcar',
        print 'Width {0}s ...'.format(opts.teff)
        top_hat = n.zeros_like(firs[sep])
        l_hat = len(top_hat[0])
        if opts.teff: box_time = opts.teff
        else: box_time = 2232.
        start = n.round(l_hat / 2. - box_time / data_inttime / 2.)
        end = n.round(l_hat / 2. + box_time / data_inttime / 2.)
Пример #6
0
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
    
#Get the fir filters for the separation used.
firs = {}
for sep in seps:
    c = 0 
    while c != -1:
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c+=1
        else: break
    frp, bins = fringe.aa_to_fr_profile(aa, ij, 100,frpad=opts.frpad)
    timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[100])
    
baselines = ''.join(sep2ij[sep] for sep in seps)
times, data, flags = arp.get_dict_of_uv_data(args, baselines, pol, verbose=True)
lsts = [ aa.sidereal_time() for k in map(aa.set_jultime(), times) ]

_d = {}
_w = {}
for bl in data.keys():
    if not _d.has_key(bl): _d[bl],_w[bl] = {}, {}
    #get filter which is baseline dependent.
    sep = bl2sep[bl]
    fir = firs[sep]
    if blconj[bl]: fir = n.conj(fir)
    print map(int, a.miriad.bl2ij(bl)), sep, blconj[bl]
    for pol in data[bl].keys():
Пример #7
0
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.
firs = {}
for sep in seps:
    c = 0 
    while c != -1:
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c+=1
        else: break
    frp, bins = fringe.aa_to_fr_profile(aa, ij, mychan, bins=frbins,frpad=opts.frpad)
    #frp, bins = fringe.aa_to_fr_profile(aa, ij, mychan) ## for default fr_bins
    #timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[100],mdl=skew,startprms=(.001,.001,-50),frpad=opts.frpad)
    timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[mychan], startprms=(.001*opts.frpad,.0001))
    #timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[mychan],frpad=opts.frpad, alietal=opts.alietal )
    
baselines = ''.join(sep2ij[sep] for sep in seps)
times, data, flags = zsa.get_dict_of_uv_data(args, baselines, pol, verbose=True)
lsts = [ aa.sidereal_time() for k in map(aa.set_jultime(), times) ]

_d = {}
_w = {}
for bl in data.keys():
    if not _d.has_key(bl): _d[bl],_w[bl] = {}, {}
    #get filter which is baseline dependent.
    sep = bl2sep[bl]
    fir = firs[sep]
    if blconj[bl]: fir = n.conj(fir)
    print map(int, a.miriad.bl2ij(bl)), sep, blconj[bl]
Пример #8
0
 if opts.same == None and opts.diff == None:
     print 'Need to specify if noise is the same on all baselines (--same) or different (--diff)'
     sys.exit()
 #Prep FRF Stuff
 ij = bls_master[0]  #ij = (1,4)
 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
 timelen = data_dict[keys[0]].shape[0]
 bins = fringe.gen_frbins(inttime)
 frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs) / 2, bins=bins)
 timebins, firs = fringe.frp_to_firs(frp,
                                     bins,
                                     aa.get_freqs(),
                                     fq0=aa.get_freqs()[len(afreqs) / 2])
 fir = {(ij[0], ij[1], POL): firs}
 if opts.same and opts.frf:
     NOISE = frf((len(chans), timelen))  #same noise on all bls
 if opts.same and opts.frf == None: NOISE = oqe.noise((len(chans), timelen))
 for key in data_dict:
     if opts.same: thing = NOISE.T
     if opts.diff and opts.frf: thing = frf((len(chans), timelen)).T
     if opts.diff and opts.frf == None:
         thing = oqe.noise((len(chans), timelen)).T
     if blconj[a.miriad.ij2bl(key[1][0], key[1][1])]:
         data_dict[key] = n.conj(thing)
     else:
         data_dict[key] = thing
     flg_dict[key] = n.ones_like(data_dict[key])
Пример #9
0
seps = [ bl2sep[b] for b in ants ]
seps = n.unique(seps)
print 'These are the separations that we are going to use:', seps
    
#Get the fir filters for the separation used
bins = fringe.gen_frbins(inttime)
firs = {}
for sep in seps:
    c = 0 #baseline indices
    while True:
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c+=1
        else: break #find when conjugation isn't necessary
    frp, bins = fringe.aa_to_fr_profile(aa, ij, 100, pol=pol, bins=bins) 
    timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[100])


baselines = ''.join(sep2ij[sep] for sep in seps)
times, data, flags = C.miriad.read_files(args, baselines, pol, verbose=True) #new way of get_dict_of_uv_data
#jds = times['times']
#lsts = [ aa.sidereal_time() for k in map(aa.set_jultime(), jds) ]
lsts = times['lsts']
lst_order = n.argsort(lsts) #data is not always read in LST order!
lsts = n.array(lsts)[lst_order]
times['times'] = times['times'][lst_order]
for bl in data: #orders data and flags correctly by LST
    for pol in data[bl]:
        data[bl][pol] = data[bl][pol][lst_order]
        flags[bl][pol] = flags[bl][pol][lst_order]
_d = {}
Пример #10
0
    lsts[k] = lsts[k][:j]
    for bl in data[k]:
        data[k][bl], flgs[k][bl] = n.array(data[k][bl][:j]), n.array(flgs[k][bl][:j])
lsts = lsts.values()[0]  # same set of LST values for both even/odd data
daykey = data.keys()[0]
blkey = data[daykey].keys()[0]
ij = a.miriad.bl2ij(blkey)
if blconj[blkey]:
    ij = (ij[1], ij[0])
# ij = (64, 49)

# Prep FRF Stuff
bins = fringe.gen_frbins(inttime)
frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs) / 2, bins=bins)
timebins, firs = fringe.frp_to_firs(
    frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[len(afreqs) / 2]
)  # , maxfr=1.3e-3, frwidth=2.0)
_, blconj, _ = zsa.grid2ij(aa.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}
fir = {(ij[0], ij[1], POL): firs}

# Extract frequency range of data
xi = {}
f = {}
NOISE = frf((len(chans), len(lsts)), loc=0, scale=1)  # same noise on each bl
# embed()
for k in days:
    xi[k] = {}
    f[k] = {}
    for bl in data[k]:
Пример #11
0
if True:  #this one is the exact one
    sep = bl2sep[all_bls[0]]
    ij_array = sep2ij[sep].split(',')
    while True:
        ij = map(int, ij_array.pop().split('_'))
        bl = aipy.miriad.ij2bl(*ij)
        if not blconj[bl]: break
    if False:
        bl = 11072
        ij = aipy.miriad.bl2ij(bl)
    print 'Using Baseline for FRP:', bl
    bins = fringe.gen_frbins(inttime)
    frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs) / 2, bins=bins)

    timebins, firs = fringe.frp_to_firs(
        frp, bins, aa.get_freqs(),
        fq0=aa.get_freqs()[len(afreqs) /
                           2])  #, fr_width_scale=1.3, maxfr=1.3e-3)

    if blconj[aipy.miriad.ij2bl(ij[0], ij[1])]:
        fir = {(ij[0], ij[1], POL): np.conj(firs)}  #conjugate fir if needed
    else:
        fir = {(ij[0], ij[1], POL): firs}

qs_e, qs_v, qs_r, qs_ev = [], [], [], []
ps_e, ps_v, ps_r, ps_ev = [], [], [], []
c_nums = []
bar = ProgressBar(maxval=len(v_scale) * NRUN,
                  widgets=['Performing MC:',
                           Bar(),
                           Percentage(), ' ',
                           ETA()]).start()
Пример #12
0
ijs = sep2ij[SEP].split(',')
all_bls= [ aipy.miriad.ij2bl(*map( int,x.split('_'))) for x in ijs]

if True: #this one is the exact one
    sep = bl2sep[all_bls[0]]
    ij_array =  sep2ij[sep].split(',')
    while True:
        ij = map( int, ij_array.pop().split('_') )
        bl = aipy.miriad.ij2bl(*ij )
        if not blconj[bl]: break
    if False: bl = 11072; ij =  aipy.miriad.bl2ij(bl);
    print 'Using Baseline for FRP:',bl
    bins = fringe.gen_frbins(inttime)
    frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs)/2, bins=bins)

    timebins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[len(afreqs)/2])#, fr_width_scale=1.3, maxfr=1.3e-3)

    if blconj[aipy.miriad.ij2bl(ij[0],ij[1])]: fir = {(ij[0],ij[1],POL):np.conj(firs)} #conjugate fir if needed
    else: fir = {(ij[0],ij[1],POL):firs}

qs_e,qs_v,qs_r,qs_ev = [], [], [], []
ps_e,ps_v,ps_r,ps_ev = [], [], [], []
c_nums = []
bar =ProgressBar(maxval=len(v_scale)*NRUN,widgets=['Performing MC:',Bar(),Percentage(),' ',ETA()]).start()
for cnt,sc in enumerate(v_scale):
    tmp_qs_e,tmp_qs_v,tmp_qs_r,tmp_qs_ev = [], [], [], []
    tmp_ps_e,tmp_ps_v,tmp_ps_r,tmp_ps_ev = [], [], [], []
    tmp_c=[]
    for run in xrange(NRUN):
        e,v,r = {} , {}, {}
        #Gen 1 eor for all bls
Пример #13
0
_, 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(),
                                    fq0=aa.get_freqs()[mychan])
firs = firs[int(opts.chan.split('_')[0]):int(opts.chan.split('_')[1])+1,:] # chop firs to frequency range of interest
fir = {(ij[0], ij[1], POL): firs}
fir_conj = {} # fir for conjugated baselines
for key in fir:
    fir_conj[key] = n.conj(fir[key])
aa = a.cal.get_aa(opts.cal, afreqs) # aa is now subset of freqs, for use in apply_frf later

# Acquire data
data_dict_v = {}
data_dict_n = {}
flg_dict = {}
conj_dict = {}
stats, lsts, data, flgs = {}, {}, {}, {}
for k in days:
    stats[k], data[k], flgs[k] = capo.miriad.read_files(dsets[k],
Пример #14
0
    for sep in seps:
        c = 0
        while c != -1:
            ij = map(int, sep2ij[sep].split(',')[c].split('_'))
            bl = a.miriad.ij2bl(*ij)
            if blconj[bl]: c += 1
            else: break
        frp, bins = fringe.aa_to_fr_profile(aa,
                                            ij,
                                            mychan,
                                            bins=frbins,
                                            frpad=pad)

        timebins, firs[sep] = fringe.frp_to_firs(frp,
                                                 bins,
                                                 aa.get_afreqs(),
                                                 fq0=aa.get_afreqs()[mychan],
                                                 limit_xtalk=True)

        if False and pad == 1:
            delta = prms0[-1] / n.sqrt(1 + prms0[-1]**2)
            print 'model fit parameters: ', prms0
            print 'norm is: ', n.sum(frp)
            print 'mean is: ', n.sum(bins * frp) / n.sum(frp)
            mn = n.sum(bins * frp) / n.sum(frp)
            sq = n.sqrt(n.sum((bins - mn)**2 * frp) / n.sum(frp))
            sk = n.sum(((bins - mn) / sq)**3 * frp) / n.sum(frp)
            ftsk = (4 - n.pi) / 2. * (delta * n.sqrt(2 / n.pi))**3 / (
                1 - 2 * delta**2 / n.pi)**(1.5)
            print 'actual skew is: ', sk
            print 'fitted skew is: ', ftsk
Пример #15
0
#Get the fir filters for the separation used.
fig_firs,ax_firs=p.subplots(1)
fig_frp,ax_frp=p.subplots(1)
for cnt,pad in enumerate(frpads):
    firs = {}
    frps = {}
    for sep in seps:
        c = 0 
        while c != -1:
            ij = map(int, sep2ij[sep].split(',')[c].split('_'))
            bl = a.miriad.ij2bl(*ij)
            if blconj[bl]: c+=1
            else: break
        frp, bins = fringe.aa_to_fr_profile(aa, ij, mychan,bins=frbins,frpad=pad)

        timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[mychan], limit_xtalk=True)
        
            
        
        if False and pad ==1:
            delta=prms0[-1]/n.sqrt(1+prms0[-1]**2)
            print 'model fit parameters: ',prms0
            print 'norm is: ', n.sum(frp)
            print 'mean is: ', n.sum(bins*frp)/n.sum(frp)
            mn= n.sum(bins*frp)/n.sum(frp)
            sq= n.sqrt(n.sum((bins-mn)**2*frp)/n.sum(frp))
            sk= n.sum(((bins-mn)/sq)**3*frp)/n.sum(frp)
            ftsk= (4-n.pi)/2.* (delta*n.sqrt(2/n.pi))**3/(1-2*delta**2/n.pi)**(1.5)
            print 'actual skew is: ', sk
            print 'fitted skew is: ', ftsk
Пример #16
0
                ij = a.miriad.bl2ij(opts.baseline)
                bl = opts.baseline
            else:
                ij_array = sep2ij[sep].split(',')
                while True:
                    ij = map(int, ij_array.pop().split('_'))
                    bl = a.miriad.ij2bl(*ij)
                    if not blconj[bl]: break
            print "bl_scale = ", scale, "fr_width:", frw_scale, "sep: ", sep, 'bl:', bl, 'ant:', ij
            frp[scale][frw_scale][sep], bins = fringe.aa_to_fr_profile(
                aa, ij, mychan, bins=frbins, pol=opts.pol, bl_scale=scale)
            timebins, firs[sep] = fringe.frp_to_firs(
                frp[scale][frw_scale][sep],
                bins,
                aa.get_afreqs(),
                fq0=aa.get_afreqs()[mychan],
                limit_xtalk=True,
                bl_scale=scale,
                fr_width_scale=frw_scale,
                maxfr=opts.maxfr)
            timebins *= opts.data_inttime / opts.inttime

            if False and scale == 1:
                delta = prms0[-1] / n.sqrt(1 + prms0[-1]**2)
                print 'model fit parameters: ', prms0
                print 'norm is: ', n.sum(frp)
                print 'mean is: ', n.sum(bins * frp) / n.sum(frp)
                mn = n.sum(bins * frp) / n.sum(frp)
                sq = n.sqrt(n.sum((bins - mn)**2 * frp) / n.sum(frp))
                sk = n.sum(((bins - mn) / sq)**3 * frp) / n.sum(frp)
                ftsk = (4 - n.pi) / 2. * (delta * n.sqrt(2 / n.pi))**3 / (
Пример #17
0
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
    
#Get the fir filters for the separation used.
firs = {}
for sep in seps:
    c = 0 
    while c != -1:
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c+=1
        else: break
    frp, bins = fringe.aa_to_fr_profile(aa, ij, 100,frpad=1.0)
    timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[100],mdl=skew,startprms=(.001,.001,-50),frpad=opts.frpad)
    
baselines = ''.join(sep2ij[sep] for sep in seps)
times, data, flags = arp.get_dict_of_uv_data(args, baselines, pol, verbose=True)
lsts = [ aa.sidereal_time() for k in map(aa.set_jultime(), times) ]

_d = {}
_w = {}
for bl in data.keys():
    if not _d.has_key(bl): _d[bl],_w[bl] = {}, {}
    #get filter which is baseline dependent.
    sep = bl2sep[bl]
    fir = firs[sep]
    if blconj[bl]: fir = n.conj(fir)
    print map(int, a.miriad.bl2ij(bl)), sep, blconj[bl]
    for pol in data[bl].keys():
Пример #18
0
aa = a.cal.get_aa('psa6240_v003', n.array([.151]))

h = a.healpix.HealpixMap(nside=64) #healpix map for the beam
xyz = h.px2crd(n.arange( h.npix() ), ncrd=3)
tx,ty,tz = n.dot(aa._eq2zen, xyz) #rotate the coordinated system to be centered on the array. This is equatorial centered at the array.
_bmx = aa[0].bm_response((tx,ty,tz),pol='x')[0]
_bmy = aa[0].bm_response((tx,ty,tz),pol='y')[0]
bmI = 0.5 * (_bmx**2 + _bmy**2)
bmI = n.where(tz > 0, bmI, 0) # only use beam values above the horizon.

bl = aa.get_baseline(0,26,'r') * .151 #baseline length in frequency.
fng = C.frf_conv.mk_fng(bl, xyz)

#get the fringe rate filter in frf_conv. aa only has one channel in it.
frp, bins = fringe.aa_to_fr_profile(aa, (0,26), 0)
tbins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[0])
frp = fringe.fir_to_frp(firs)
#frf,bins,wgt,(cen,wid) = C.frf_conv.get_optimal_kernel_at_ref(aa, 0, (0,26)) 
#bwfrs = C.frf_conv.get_beam_w_fr(aa, (0,26), ref_chan=0) 
#tbins,firs,frbins,frfs = C.frf_conv.get_fringe_rate_kernels(bwfrs,42.9,403)

#need to renormalize to get the proper scaling. firs are properly normalized.
#firs = firs[0]
#frfs = n.fft.fftshift(n.fft.fft(n.fft.ifftshift(firs), axis=-1))
#get weights.
wgts = scipy.interpolate.interp1d(bins, frp, kind='linear')
fng_wgt = wgts(fng) #gets weightings at fringes on the sky.
fng_bm = bmI * fng_wgt
#flat weighting determined by the maximum possible fringe rate for a baseline 
#and 0.
skypass = n.where(n.abs(bins) < n.max(n.abs(fng)), 1., 0)
Пример #19
0
h = a.healpix.HealpixMap(nside=64)  # healpix map for the beam
xyz = h.px2crd(n.arange(h.npix()), ncrd=3)
tx, ty, tz = n.dot(
    aa._eq2zen, xyz
)  # rotate the coordinated system to be centered on the array. This is equatorial centered at the array.
_bmx = aa[0].bm_response((tx, ty, tz), pol="x")[0]
_bmy = aa[0].bm_response((tx, ty, tz), pol="y")[0]
bmI = 0.5 * (_bmx ** 2 + _bmy ** 2)
bmI = n.where(tz > 0, bmI, 0)  # only use beam values above the horizon.

bl = aa.get_baseline(0, 26, "r") * 0.151  # baseline length in frequency.
fng = C.frf_conv.mk_fng(bl, xyz)

# get the fringe rate filter in frf_conv. aa only has one channel in it.
frp, bins = fringe.aa_to_fr_profile(aa, (0, 26), 0)
tbins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[0])
frp = fringe.fir_to_frp(firs)
# frf,bins,wgt,(cen,wid) = C.frf_conv.get_optimal_kernel_at_ref(aa, 0, (0,26))
# bwfrs = C.frf_conv.get_beam_w_fr(aa, (0,26), ref_chan=0)
# tbins,firs,frbins,frfs = C.frf_conv.get_fringe_rate_kernels(bwfrs,42.9,403)

# need to renormalize to get the proper scaling. firs are properly normalized.
# firs = firs[0]
# frfs = n.fft.fftshift(n.fft.fft(n.fft.ifftshift(firs), axis=-1))
# get weights.
wgts = scipy.interpolate.interp1d(bins, frp, kind="linear")
fng_wgt = wgts(fng)  # gets weightings at fringes on the sky.
fng_bm = bmI * fng_wgt
# flat weighting determined by the maximum possible fringe rate for a baseline
# and 0.
skypass = n.where(n.abs(bins) < n.max(n.abs(fng)), 1.0, 0)
Пример #20
0
    firs = {}
    frps = {}
    frp[scale] = {}
    for cn1,frw_scale in enumerate(fr_width_scales):
        frp[scale][frw_scale] ={}
        for sep in seps:
            if opts.baseline:  ij =  a.miriad.bl2ij(opts.baseline); bl =opts.baseline
            else:
                ij_array =  sep2ij[sep].split(',')
                while True:
                    ij = map( int, ij_array.pop().split('_') )
                    bl = a.miriad.ij2bl(*ij )
                    if not blconj[bl]: break
            print "bl_scale = ", scale,"fr_width:", frw_scale, "sep: ",sep,'bl:',bl, 'ant:', ij
            frp[scale][frw_scale][sep], bins = fringe.aa_to_fr_profile(aa, ij, mychan,bins=frbins, pol=opts.pol, bl_scale=scale)
            timebins, firs[sep] = fringe.frp_to_firs(frp[scale][frw_scale][sep], bins, aa.get_afreqs(), fq0=aa.get_afreqs()[mychan], limit_xtalk=True, bl_scale = scale, fr_width_scale = frw_scale, maxfr=opts.maxfr)
            timebins*= opts.data_inttime/opts.inttime

            if False and scale ==1:
                delta=prms0[-1]/n.sqrt(1+prms0[-1]**2)
                print 'model fit parameters: ',prms0
                print 'norm is: ', n.sum(frp)
                print 'mean is: ', n.sum(bins*frp)/n.sum(frp)
                mn= n.sum(bins*frp)/n.sum(frp)
                sq= n.sqrt(n.sum((bins-mn)**2*frp)/n.sum(frp))
                sk= n.sum(((bins-mn)/sq)**3*frp)/n.sum(frp)
                ftsk= (4-n.pi)/2.* (delta*n.sqrt(2/n.pi))**3/(1-2*delta**2/n.pi)**(1.5)
                print 'actual skew is: ', sk
                print 'fitted skew is: ', ftsk

            frps[sep], frp_freqs = fringe.fir_to_frp(firs[sep],tbins=timebins)
Пример #21
0
print 'scalar:', scalar
sys.stdout.flush()


if True: #this one is the exact one
    sep = bl2sep[all_bls[0]]
    ij_array =  sep2ij[sep].split(',')
    while True:
        ij = map( int, ij_array.pop().split('_') )
        bl = a.miriad.ij2bl(*ij )
        if not blconj[bl]: break
    print 'Using Baseline for FRP:',bl
    bins = fringe.gen_frbins(inttime)
    frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs)/2, bins=bins, bl_scale = opts.bl_scale)

    timebins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[len(afreqs)/2], bl_scale=opts.bl_scale, fr_width_scale= opt.fr_width_scale)

    if blconj[a.miriad.ij2bl(ij[0],ij[1])]: fir = {(ij[0],ij[1],POL):n.conj(firs)} #conjugate fir if needed
    else: fir = {(ij[0],ij[1],POL):firs}

#Extract frequency range of data for each boot
for boot in xrange(opts.nboot):
    print '%d / %d' % (boot+1,opts.nboot)
    x = {}
    f = {}
    for k in days:
        x[k] = {}
        f[k] = {}
        for bl in all_bls:
            d = noise((nchan,ntimes)).T * NOISE * jy2T
            flg = n.zeros_like(d)
Пример #22
0
sep = bl2sep[blkey]
c = 0
while c != -1:
    ij = map(int, sep2ij[sep].split(',')[c].split('_'))
    blkey = a.miriad.ij2bl(*ij)
    if blconj[blkey]:
        c += 1
    else:
        break
# ij = (64, 49)

# ep FRF Stuff
bins = fringe.gen_frbins(inttime)
frp, bins = fringe.aa_to_fr_profile(aa, ij, len(afreqs)/2, bins=bins)
# , alietal=True)
timebins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(),
                                    fq0=aa.get_freqs()[len(afreqs)/2])
#                                   , alietal=True)#, maxfr=1.3e-3,
#                                   frwidth=2.0)

_, blconj, _ = zsa.grid2ij(aa.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}
fir = {(ij[0], ij[1], POL): firs}

# Extract frequency range of data
xi = {}
f = {}
NOISE = frf((len(chans), len(lsts)), loc=0, scale=1)
# same noise on each bl
Пример #23
0
##use calculated inttime to generate correct frf bins
frbins = fringe.gen_frbins(inttime,fringe_res=1./(inttime*len(times)))
#frbins = n.arange( -.5/inttime+5e-5/2, .5/inttime,5e-5)
#DEFAULT_FRBINS = n.arange(-.01+5e-5/2,.01,5e-5) # Hz

firs = {}
for sep in seps:
    c = 0
    while c != -1:
        ij = map(int, sep2ij[sep].split(',')[c].split('_'))
        bl = a.miriad.ij2bl(*ij)
        if blconj[bl]: c+=1
        else: break
    print mychan,ij,opts.bl_scale
    frp, bins = fringe.aa_to_fr_profile(aa, ij, mychan, bins=frbins,pol=opts.pol,bl_scale=opts.bl_scale)
    timebins, firs[sep] = fringe.frp_to_firs(frp, bins, aa.get_afreqs(), fq0=aa.get_afreqs()[mychan],
         bl_scale=opts.bl_scale, fr_width_scale = opts.fr_width_scale, alietal = opts.alietal,maxfr=opts.maxfr)

    frp = fringe.fir_to_frp(firs[sep])
    if opts.boxcar:
        print 'Making Boxcar',
        print 'Width {0}s ...'.format(opts.teff)
        top_hat = n.zeros_like(firs[sep])
        l_hat =len(top_hat[0])
        if opts.teff: box_time = opts.teff
        else: box_time = 2232.
        start = n.round(l_hat/2. - box_time/data_inttime/2.)
        end = n.round(l_hat/2. + box_time/data_inttime/2.)
        diff = n.round(box_time/data_inttime - ( end - start))
        if diff != 0: end += diff
        if  (end-start) % 2 == 0: end +=1
        top_hat[:,start:end] += 1.
Пример #24
0
h = a.healpix.HealpixMap(nside=64) #healpix map for the beam
xyz = h.px2crd(n.arange( h.npix() ), ncrd=3)
tx,ty,tz = n.dot(aa._eq2zen, xyz) #rotate the coordinated system to be centered on the array. This is equatorial centered at the array.
_bmx = aa[0].bm_response((tx,ty,tz),pol='x')[0]
_bmy = aa[0].bm_response((tx,ty,tz),pol='y')[0]
bmI = 0.5 * (_bmx**2 + _bmy**2)
bmI = n.where(tz > 0, bmI, 0) # only use beam values above the horizon.

bl = aa.get_baseline(0,26,'r') * .151 #baseline length in frequency.
print aa.get_baseline(0,26,'r')
fng = C.frf_conv.mk_fng(bl, xyz)

#get the fringe rate filter in frf_conv. aa only has one channel in it.
frp, bins = fringe.aa_to_fr_profile(aa, (1,4), 0) #XXX hard-coded
tbins, firs = fringe.frp_to_firs(frp, bins, aa.get_freqs(), fq0=aa.get_freqs()[0],alietal=True)
frp = fringe.fir_to_frp(firs)
#frf,bins,wgt,(cen,wid) = C.frf_conv.get_optimal_kernel_at_ref(aa, 0, (0,26)) 
#bwfrs = C.frf_conv.get_beam_w_fr(aa, (0,26), ref_chan=0) 
#tbins,firs,frbins,frfs = C.frf_conv.get_fringe_rate_kernels(bwfrs,42.9,403)

#need to renormalize to get the proper scaling. firs are properly normalized.
#firs = firs[0]
#frfs = n.fft.fftshift(n.fft.fft(n.fft.ifftshift(firs), axis=-1))
#get weights.
wgts = scipy.interpolate.interp1d(bins, frp, kind='linear')
fng_wgt = wgts(fng) #gets weightings at fringes on the sky.
fng_bm = bmI * fng_wgt
#flat weighting determined by the maximum possible fringe rate for a baseline 
#and 0.
skypass = n.where(n.abs(bins) < n.max(n.abs(fng)), 1., 0)
Пример #25
0
)  #rotate the coordinated system to be centered on the array. This is equatorial centered at the array.
_bmx = aa[0].bm_response((tx, ty, tz), pol='x')[0]
_bmy = aa[0].bm_response((tx, ty, tz), pol='y')[0]
bmI = 0.5 * (_bmx**2 + _bmy**2)
bmI = n.where(tz > 0, bmI, 0)  # only use beam values above the horizon.

bl = aa.get_baseline(0, 26,
                     'r') * .151  #XXX hard-coded baseline length in frequency.
print aa.get_baseline(0, 26, 'r')
fng = fringe.mk_fng(bl, xyz)

#get the fringe rate filter in frf_conv. aa only has one channel in it.
frp, bins = fringe.aa_to_fr_profile(aa, (1, 4), 0)  #XXX hard-coded
tbins, firs = fringe.frp_to_firs(frp,
                                 bins,
                                 aa.get_freqs(),
                                 fq0=aa.get_freqs()[0],
                                 alietal=False)
#frp = fringe.fir_to_frp(firs)

## Old way of calculating FRP,FIRS,etc. ##
#frf,bins,wgt,(cen,wid) = C.frf_conv.get_optimal_kernel_at_ref(aa, 0, (0,26))
#bwfrs = C.frf_conv.get_beam_w_fr(aa, (0,26), ref_chan=0)
#tbins,firs,frbins,frfs = C.frf_conv.get_fringe_rate_kernels(bwfrs,42.9,403)

#need to renormalize to get the proper scaling. firs are properly normalized.
#firs = firs[0]
#frfs = n.fft.fftshift(n.fft.fft(n.fft.ifftshift(firs), axis=-1))
#get weights.
wgts = scipy.interpolate.interp1d(bins, frp, kind='linear')
fng_wgt = wgts(fng)  #gets weightings at fringes on the sky.