flags = {}
    for pol in ['xx', 'yy']:
        flags[pol] = np.concatenate([np.fromfile(fname, dtype = 'bool').reshape((nTimes[i], nFrequencies[i])) for i, fname in enumerate(sorted(glob.glob("/home/omniscope/data/X5/2015calibration/*_%s_*%s.omniflag"%(Q, pol))))], axis=0)
    flag = flags['xx']|flags['yy']


    for p, pol in enumerate(['xx', 'xy', 'yx', 'yy']):
        omnifits[pol] = np.concatenate([fit[..., 6::2] + 1.j*fit[..., 7::2] for fit in omnifits[pol]], axis=0).transpose((0,2,1))
        omnifits[pol][flag] = np.nan
    info = omni.read_redundantinfo(glob.glob("/home/omniscope/data/X5/2015calibration/*_%s_*xx.binfo"%Q)[0])
    redundancy_sort = np.argsort(info['ublcount'])

    raw_vars = {}
    for pol in ['xx', 'xy', 'yx', 'yy']:
        omnichisq = np.concatenate([omni.load_omnichisq(fname)[:,3:] for fname in sorted(glob.glob("/home/omniscope/data/X5/2015calibration/*_%s_*%s.omnichisq"%(Q,pol)))], axis=0)
        if pol[0] == pol[1]:
            raw_vars[pol] = omnichisq / (info['nBaseline'] - info['nAntenna'] - info['nUBL'] + 2)
        else:
            raw_vars[pol] = omnichisq / info['nBaseline']
        raw_vars[pol] = np.outer(raw_vars[pol], 1./info['ublcount']).reshape(list(raw_vars[pol].shape) + [info['nUBL']])

    ####process the pi jump in xy and yx
    per_file_avg = {}
    pi_flip = {}
    flip_use_ubls = redundancy_sort[-10:]
    for pol in ['xy', 'yx']:
        tmp_t = 0
        per_file_avg[pol] = np.zeros((len(nTimes), omnifits[pol].shape[1], len(flip_use_ubls)), dtype='complex64')
        for nfile in range(len(nTimes)):
            per_file_avg[pol][nfile] = np.nanmean(omnifits[pol][tmp_t:tmp_t+nTimes[nfile]], axis=0)[..., flip_use_ubls]
Exemple #2
0
        dataano = dataano + os.path.basename(uvf)



have_model_noises = False
if opts.model_noise is not None:
    if not need_new_flag:
        raise IOError("--noise_model supplied without --flag. Noise model is only useful when doing new flagging.")
    if len(opts.model_noise.split(',')) != len(opts.pol.split(',')):
        raise ValueError("--model_noise got argument %s that does not have the same number of polarizations as -p argument %s."%(opts.model_noise, opts.pol))
    model_noises = {}
    for p, pol in enumerate(opts.pol.split(',')):
        model_noise_file = os.path.expanduser(opts.model_noise.split(',')[p])
        if not os.path.isfile(model_noise_file):
            raise IOError("model noise file %s does not exist"%model_noise_file)
        model_noises[pol] = omni.load_omnichisq(model_noise_file)
        if np.max(omni.get_omnitime(model_noises[pol])) >= TPI or np.min(omni.get_omnitime(model_noises[pol])) < 0:
            raise ValueError("Times stored in noise model %s is outside the range [0, 2pi)."%model_noise_file)
    have_model_noises = True
    chisq_leniency = opts.chisq_leniency

have_model_treasure = False
if opts.model_treasure is not None:
    if os.path.isdir(os.path.expanduser(opts.model_treasure)):
        model_treasure = omni.Treasure(os.path.expanduser(opts.model_treasure))
        for pol in opts.pol.split(','):
            if pol not in model_treasure.ubls.keys():
                raise ValueError("Polarization %s not found in the model treasure file %s."%(pol, os.path.expanduser(opts.model_treasure)))
    else:
        raise IOError("Model treasure folder not found: %s."%os.path.expanduser(opts.model_treasure))
    have_model_treasure = True
Exemple #3
0
if opts.model_noise is not None:
    if not need_new_flag:
        raise IOError(
            "--noise_model supplied without --flag. Noise model is only useful when doing new flagging."
        )
    if len(opts.model_noise.split(',')) != len(opts.pol.split(',')):
        raise ValueError(
            "--model_noise got argument %s that does not have the same number of polarizations as -p argument %s."
            % (opts.model_noise, opts.pol))
    model_noises = {}
    for p, pol in enumerate(opts.pol.split(',')):
        model_noise_file = os.path.expanduser(opts.model_noise.split(',')[p])
        if not os.path.isfile(model_noise_file):
            raise IOError("model noise file %s does not exist" %
                          model_noise_file)
        model_noises[pol] = omni.load_omnichisq(model_noise_file)
        if np.max(omni.get_omnitime(model_noises[pol])) >= TPI or np.min(
                omni.get_omnitime(model_noises[pol])) < 0:
            raise ValueError(
                "Times stored in noise model %s is outside the range [0, 2pi)."
                % model_noise_file)
    have_model_noises = True
    chisq_leniency = opts.chisq_leniency

have_model_treasure = False
if opts.model_treasure is not None:
    if os.path.isdir(os.path.expanduser(opts.model_treasure)):
        model_treasure = omni.Treasure(os.path.expanduser(opts.model_treasure))
        for pol in opts.pol.split(','):
            if pol not in model_treasure.ubls.keys():
                raise ValueError(