Ejemplo n.º 1
0
o.add_option('--savemask', action='store_true')
o.add_option('--plot', action='store_true')
opts, args = o.parse_args(sys.argv[1:])


### Functions ###
def dB(x):
    return 10 * n.ma.log10(n.ma.abs(x))


### Save Options ###
pol = 'xx'  #XXX shouldn't be hard-coded in the future
rawgains = {}
gaintimes = {}
for filename in args:
    jd = file2jd(filename)
    print filename, jd
    D = n.load(filename)
    for thing in D.files:  #things are gains and xtalks
        try:
            rawgains[thing].append(D[thing])
            gaintimes[thing].append(jd)
        except (KeyError):
            rawgains[thing] = [D[thing]]
            gaintimes[thing] = [jd]
#sort the things by jd
gains = {}
for thing in rawgains:
    jdorder = n.argsort(gaintimes[thing])
    sortedgains = [rawgains[thing][i] for i in jdorder]
    gains[thing] = n.array(n.vstack(sortedgains))
Ejemplo n.º 2
0
o.add_option('--nsigma',type=float,default=100,
    help='flag solutions with log(gain)>std(log(gain))*nsigma [default=100]')
o.add_option('--savemask',action='store_true')
o.add_option('--plot',action='store_true')
opts,args = o.parse_args(sys.argv[1:])

### Functions ###
def dB(x):
    return  10*n.ma.log10(n.ma.abs(x))

### Save Options ###
pol = 'xx' #XXX shouldn't be hard-coded in the future
rawgains = {}
gaintimes = {}
for filename in args:
    jd = file2jd(filename)
    print filename,jd
    D = n.load(filename)
    for thing in D.files: #things are gains and xtalks
        try:
            rawgains[thing].append(D[thing])
            gaintimes[thing].append(jd)
        except(KeyError): 
            rawgains[thing] = [D[thing]]
            gaintimes[thing] = [jd]
#sort the things by jd
gains  ={}
for thing in rawgains:
    jdorder = n.argsort(gaintimes[thing])
    sortedgains = [rawgains[thing][i] for i in jdorder]
    gains[thing] = n.array(n.vstack(sortedgains))
Ejemplo n.º 3
0
import numpy as n
from pylab import *
import sys, os, numpy as n
from capo.dcj import file2jd

chisq = []
nprefix = 3
media = []
means = []
jds = [file2jd(filename) for filename in sys.argv[1:]]
I = n.argsort(jds)
for datafile in [sys.argv[1:][i] for i in I]:
    data = np.fromfile(datafile, dtype='float32')
    nf = int(data[nprefix - 1])
    nt = len(data) / (nf + nprefix)
    if len(data) != nt * (nf + nprefix):
        raise IOError("File %s is not a valid omnichisq file." % datafile)

    data.shape = (nt, (nf + nprefix))
    data = data[:, nprefix:]
    chisq.append(data)
    media.append(n.median(data, axis=0))
    means.append(n.mean(data, axis=0))
    #    print '.',
    print datafile
chisq = n.concatenate(chisq)
media = n.vstack(media)
means = n.vstack(means)
print chisq.shape, media.shape
imshow(n.log(chisq), aspect='auto', vmin=-6, vmax=6)
colorbar()
Ejemplo n.º 4
0
o.set_usage("print_blflagging.py [options]")
o.set_description(__doc__)
a.scripting.add_standard_options(o, ant=True, pol=True)
o.add_option('-v',action='store_true',help='turn on more verbs')
o.add_option('--detail',action='store_true',help='print stats for each bl')
o.add_option('--awesome',action='store_true',help='try to seperate the weights using linear algebra instead of just \
averaging over baselines')
opts,args=o.parse_args(sys.argv[1:])
uv = a.miriad.UV(args[0])
nant=uv['nants']

jds = []
for filename in args:
    F = n.zeros((nant,nant))
    C = n.zeros_like(F)
    jds.append(file2jd(filename))
    t,dat,flg = get_dict_of_uv_data([filename],opts.ant,opts.pol,verbose=opts.v)
    bls = dat.keys()
    for bl in bls:
        (i,j) = a.miriad.bl2ij(bl)
        pols = dat[bl].keys()
        for pol in pols:
            F[i,j] += n.sum(flg[bl][pol])
            F[j,i] += n.sum(flg[bl][pol])
            F[i,i] += n.sum(flg[bl][pol])
            F[j,j] += n.sum(flg[bl][pol])
            Size = flg[bl][pol].size
            C[i,j] +=1
            C[j,i] +=1 
            C[i,i] +=1
            C[j,j] +=1
Ejemplo n.º 5
0
o.add_option('-v', action='store_true', help='turn on more verbs')
o.add_option('--detail', action='store_true', help='print stats for each bl')
o.add_option(
    '--awesome',
    action='store_true',
    help='try to seperate the weights using linear algebra instead of just \
averaging over baselines')
opts, args = o.parse_args(sys.argv[1:])
uv = a.miriad.UV(args[0])
nant = uv['nants']

jds = []
for filename in args:
    F = n.zeros((nant, nant))
    C = n.zeros_like(F)
    jds.append(file2jd(filename))
    t, dat, flg = get_dict_of_uv_data([filename],
                                      opts.ant,
                                      opts.pol,
                                      verbose=opts.v)
    bls = dat.keys()
    for bl in bls:
        (i, j) = a.miriad.bl2ij(bl)
        pols = dat[bl].keys()
        for pol in pols:
            F[i, j] += n.sum(flg[bl][pol])
            F[j, i] += n.sum(flg[bl][pol])
            F[i, i] += n.sum(flg[bl][pol])
            F[j, j] += n.sum(flg[bl][pol])
            Size = flg[bl][pol].size
            C[i, j] += 1
Ejemplo n.º 6
0
import numpy as n
from pylab import *
import sys, os, numpy as n
from capo.dcj import file2jd

chisq = []
nprefix = 3
media = []
means = []
jds = [file2jd(filename) for filename in sys.argv[1:]]
I = n.argsort(jds)
for datafile in [sys.argv[1:][i] for i in I]:
    data = np.fromfile(datafile, dtype="float32")
    nf = int(data[nprefix - 1])
    nt = len(data) / (nf + nprefix)
    if len(data) != nt * (nf + nprefix):
        raise IOError("File %s is not a valid omnichisq file." % datafile)

    data.shape = (nt, (nf + nprefix))
    data = data[:, nprefix:]
    chisq.append(data)
    media.append(n.median(data, axis=0))
    means.append(n.mean(data, axis=0))
    #    print '.',
    print datafile
chisq = n.concatenate(chisq)
media = n.vstack(media)
means = n.vstack(means)
print chisq.shape, media.shape
imshow(n.log(chisq), aspect="auto", vmin=-6, vmax=6)
colorbar()