from SSINS import SS
from SSINS import Catalog_Plot as cp
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('obs')
parser.add_argument('inpath')
parser.add_argument('outpath')
args = parser.parse_args()

read_kwargs = {'ant_str': 'cross', 'file_type': 'uvfits'}

MF_kwargs = {
    'sig_thresh': 5,
    'shape_dict': {
        'TV6': [1.74e8, 1.81e8],
        'TV7': [1.81e8, 1.88e8],
        'TV8': [1.88e8, 1.95e8]
    },
    'N_thresh': 20
}

ss = SS(obs=args.obs,
        inpath=args.inpath,
        outpath=args.outpath,
        read_kwargs=read_kwargs,
        bad_time_indices=[0, -1, -2, -3])
ss.MF_prepare(**MF_kwargs)
cp.MF_plot(ss.MF)
Beispiel #2
0
    read_paths = {
        'data':
        arr,
        'Nbls':
        '%s/arrs/%s_%s_INS_Nbls.npym' % (args.inpath, obs, args.flag_choice),
        'freq_array':
        '%s/metadata/%s_freq_array.npy' % (args.inpath, obs),
        'pols':
        '%s/metadata/%s_pols.npy' % (args.inpath, obs),
        'vis_units':
        '%s/metadata/%s_vis_units.npy' % (args.inpath, obs)
    }
    ins = INS(obs=obs,
              outpath=args.outpath,
              flag_choice=args.flag_choice,
              read_paths=read_paths)
    # ins.data[:, :, :82] = np.ma.masked
    # ins.data[:, :, -21:] = np.ma.masked
    ins.data_ms = ins.mean_subtract()
    ins.counts, ins.bins, ins.sig_thresh = ins.hist_make()
    cp.INS_plot(ins, **ms_plot_kwargs)
    mf = MF(ins,
            shape_dict=shape_dict,
            point=args.point,
            streak=args.streak,
            **mf_kwargs)
    for test in args.tests:
        getattr(mf, 'apply_%s_test' % test)(args.order)
    ins.save()
    cp.MF_plot(mf, **ms_plot_kwargs)
            vmin=0,
            vmax=0.03,
            aspect=ss.UV.Nfreqs / ss.UV.Ntimes)

ss.INS.data[:, 0, :82] = np.ma.masked
ss.INS.data[:, 0, -21:] = np.ma.masked
ss.INS.data_ms = ss.INS.mean_subtract(order=1)
ss.MF_prepare(sig_thresh=5, N_thresh=20, shape_dict=shape_dict)
ss.MF.apply_match_test(apply_N_thresh=True, order=1)
ss.INS.data[ss.INS.data > 0.03] = np.ma.masked
ss.INS.data_ms = ss.INS.mean_subtract(order=0)
ss.INS.save()

cp.MF_plot(ss.MF,
           ms_vmin=-5,
           ms_vmax=5,
           vmin=0,
           vmax=0.03,
           aspect=ss.UV.Nfreqs / ss.UV.Ntimes)

ss.apply_flags(choice='INS', INS=ss.INS)
ss.UV.data_array.mask[:, auto_bls] = True

ss.write('%s/%s.HH.uvfits' % (args.outdir, args.obs),
         'uvfits',
         UV=UV1 + UV2,
         write_kwargs={
             'force_phase': True,
             'spoof_nonessential': True
         })
outpath = '%s/test_combines' % basedir
insarray = []
for x in obs:
    read_paths = util.read_paths_construct(basedir, 'None', x, 'INS')
    insarray.append(
        INS(obs=x,
            outpath=outpath,
            read_paths=read_paths,
            flag_choice='orginal'))
inscombined = INS_helpers.INS_concat(insarray, axis=0)
inscombined.obs = 'LWA_50to60'
inscombined.outpath = outpath
inscombined.vis_units = insarray[0].vis_units
inscombined.pols = insarray[0].pols
inscombined.save()

cp.INS_plot(inscombined, vmax=.05, ms_vmax=5, ms_vmin=-5)

shape_dict = {'44MHZ': [44e6, 45e6], '40.6MHZ': [40.4e6, 40.7e6]}
sig_thresh = 4.35

mf = MF(inscombined,
        shape_dict=shape_dict,
        sig_thresh=sig_thresh,
        point=False,
        streak=False)

mf.apply_match_test()

cp.MF_plot(mf, ms_vmin=-mf.sig_thresh, ms_vmax=mf.sig_thresh)
from SSINS import SS
from SSINS import Catalog_Plot as cp

inpath = '/Users/mike_e_dubs/MWA/Data/1061313128_noflag.uvfits'
outpath = '/Users/mike_e_dubs/MWA/1061313128_noflag'
obs = '1061313128'

ss = SS(inpath=inpath,
        outpath=outpath,
        obs=obs,
        bad_time_indices=[0, -1, -2, -3, -4],
        read_kwargs={
            'ant_str': 'cross',
            'file_type': 'uvfits'
        })
ss.MF_prepare(sig_thresh=5,
              shape_dict={
                  'TV6': [1.74e8, 1.81e8],
                  'TV7': [1.81e8, 1.88e8],
                  'TV8': [1.88e8, 1.95e8],
                  'TV7_Broad': [1.79e8, 1.9e8]
              })
cp.INS_plot(ss.INS, ms_vmin=-5, ms_vmax=5)
ss.MF.apply_match_test()
cp.MF_plot(ss.MF, ms_vmin=-5, ms_vmax=5)
Beispiel #6
0
    shape_dict = {label: [min, max] for (label, min, max) in zip(args.labels, args.mins, args.maxs)}
else:
    shape_dict = {}

obslist = util.make_obslist(args.obsfile)
edges = [0 + 16 * i for i in range(24)] + [15 + 16 * i for i in range(24)]
freqs = np.load('/Users/mike_e_dubs/python_stuff/MJW-MWA/Useful_Information/MWA_Highband_Freq_Array.npy')

for i, obs in enumerate(obslist):
    read_paths = util.read_paths_INS(args.basedir, args.flag_choice, obs)
    ins = INS(read_paths=read_paths, flag_choice=args.flag_choice, obs=obs,
              outpath=args.outdir, order=args.order)
    cp.INS_plot(ins)
    mf = MF(ins, sig_thresh=5, shape_dict=shape_dict)
    mf.apply_match_test(order=args.order)
    cp.MF_plot(mf)
    if not i:
        occ_num = np.ma.masked_array(mf.INS.data.mask)
        occ_den = np.ma.masked_array(np.ones(occ_num.shape))
        occ_num[:, 0, edges] = np.ma.masked
        occ_den[:, 0, edges] = np.ma.masked
    else:
        occ_num = occ_num + mf.INS.data.mask
        occ_den = occ_den + np.ones(occ_num.shape)

occ_freq = occ_num.sum(axis=(0, 1, 3)) / occ_den.sum(axis=(0, 1, 3)) * 100
occ_total = occ_num.sum() / occ_den.sum() * 100
fig, ax = plt.subplots(figsize=(14, 8))
plot_lib.error_plot(fig, ax, freqs * 10**(-6), occ_freq,
                    title='Golden Set RFI Frequency Post COTTER',
                    xlabel='Frequency (Mhz)', ylabel='RFI Occupancy %%',