示例#1
0
def INS_read_plot(inpath, outpath, obs, repo_dir):

    if not os.path.exists(outpath):
        os.makedirs(outpath)

    fig_titles = {'All': 'All Baselines', 'Unflagged': 'Post-Flagging'}
    for flag in fig_titles:
        if flag in inpath:
            fig_title = fig_titles[flag]
            flag_slice = flag

    INS = np.load(inpath)
    INS_frac_diff = INS / INS.mean(axis=1) - 1

    fig, ax, pols, xticks, xminors, yminors, xticklabels = \
        plot_lib.four_panel_tf_setup(np.load('%sUseful_Information/MWA_Highband_Freq_Array.npy' %
                                             (repo_dir)))
    fig.suptitle('%s Mean-Subtracted Incoherent Noise Spectrum, %s' %
                 (obs, fig_title))

    for m, pol in enumerate(pols):
        plot_lib.image_plot(fig,
                            ax[m / 2][m % 2],
                            INS_frac_diff[:, 0, :, m],
                            cmap=cm.coolwarm,
                            title=pol,
                            cbar_label='Fraction of Mean',
                            xticks=xticks,
                            xminors=xminors,
                            yminors=yminors,
                            xticklabels=xticklabels,
                            zero_mask=False,
                            mask_color='black')

    fig.savefig('%s%s_INS_frac_diff_%s.png' % (outpath, obs, flag_slice))
    np.save('%s%s_INS_frac_diff_%s.npy' % (outpath, obs, flag_slice),
            INS_frac_diff)

    return (INS, INS_frac_diff)
示例#2
0
for m, arr in enumerate(arr_list):
    INS = np.load(arr)
    INS_total[m] = INS.mean(axis=0)
    frac_diff = INS / INS_total[m] - 1
    frac_diff_total[m] = frac_diff.mean(axis=0)
    if m == 0:
        INS_stack = INS
        FD_stack = frac_diff
    else:
        INS_stack = np.vstack((INS_stack, INS))
        FD_stack = np.vstack((FD_stack, frac_diff))

INS_m = INS_total.mean(axis=0)
frac_diff_m = frac_diff_total.mean(axis=0)

fig_INS, ax_INS, pols, xticks, xminors, yminors, xticklabels = pl.four_panel_tf_setup(freq_array)
fig_fd, ax_fd = plt.subplots(figsize=(14, 8), nrows=2, ncols=2)
fig_INS_s, ax_INS_s = plt.subplots(figsize=(14, 8), nrows=2, ncols=2)
fig_FD_s, ax_FD_s = plt.subplots(figsize=(14, 8), nrows=2, ncols=2)
fig_m, ax_m = plt.subplots(figsize=(14, 8), nrows=2)
fig_mp, ax_mp = plt.subplots(figsize=(14, 8), nrows=2)

avg_title = ['Golden Set INS Averaged Across Obs', 'Golden Set Frac Diff Averaged Across Obs']
ylabels = ['Amplitude (UNCALIB)', 'Fraction']

for m in range(4):
    pl.image_plot(fig_INS, ax_INS[m / 2][m % 2], INS_total[:, 0, :, m],
                  title=pols[m], ylabel='Obs', cbar_label='Amplitude (UNCALIB)',
                  xticks=xticks, xminors=xminors, yminors=yminors,
                  xticklabels=xticklabels, zero_mask=False)
    pl.image_plot(fig_fd, ax_fd[m / 2][m % 2], frac_diff_total[:, 0, :, m],
示例#3
0
        INS = np.ma.masked_array(np.load(arr))
        # INS = rfiutil.narrowband_filter(INS, ch_ignore)
        MS = INS / INS.mean(axis=0) - 1
        if sig_thresh == 4:
            Nbls = 8001 * np.ones(INS.shape)

        INS, MS, _, _, _, _ = rfiutil.match_filter(INS, MS, Nbls, freq_array,
                                                   sig_thresh, shape_dict)
        occ_num[sig_thresh - 4] += np.count_nonzero(INS.mask)
        occ_den[sig_thresh - 4] += np.prod(INS.shape)
        if np.count_nonzero(INS.mask) > 0:
            occ_freq_num[sig_thresh - 4, :] += np.count_nonzero(INS.mask,
                                                                axis=(0, 1, 3))
        occ_freq_den[sig_thresh - 4] += INS.shape[0] * INS.shape[3]

        fig, ax, pols, xticks, xminors, yminors, xticklabels = pl.four_panel_tf_setup(
            freq_array[0, :])
        for m in range(4):
            pl.image_plot(fig,
                          ax[m / 2][m % 2],
                          MS[:, 0, :, m],
                          cmap=cm.coolwarm,
                          title=pols[m],
                          xlabel='Frequency (Mhz)',
                          ylabel='Time Pair',
                          cbar_label='Fraction of Mean',
                          xticks=xticks,
                          xminors=xminors,
                          yminors=yminors,
                          xticklabels=xticklabels,
                          zero_mask=False,
                          mask_color='black')
示例#4
0
with open('/Users/mike_e_dubs/MWA/Obs_Lists/P2_Streak.txt') as f:
    obslist = f.read().split("\n")

arr_path = '/Users/mike_e_dubs/MWA/Catalogs/Wenyang_Phase2/data_eva/arrs/arrs/'
outpath = '/Users/mike_e_dubs/MWA/Test_Plots/streak_test/'
freq_arr = np.load(
    '/Users/mike_e_dubs/python_stuff/MJW-MWA/Useful_Information/MWA_Highband_Freq_Array.npy'
)

for obs in obslist:
    frac_diff = np.load('%s%s_Unflagged_Amp_INS_frac_diff.npym' %
                        (arr_path, obs))

    fig, ax = plt.subplots(figsize=(14, 8))
    fig_im, ax_im, pols, xticks, xminors, yminors, xticklabels = plot_lib.four_panel_tf_setup(
        freq_arr)
    fig_im.suptitle('%s Streak Flagging Test' % (obs))

    frac_diff = rfiu.streak_detect(frac_diff)

    # plot_lib.line_plot(fig, ax, [edge[:, 0, m] for m in range(edge.shape[2])],
    # title='%s Streak Detection' % (obs), xlabel='Time', ylabel='Gradient',
    # labels=['XX', 'YY', 'XY', 'YX'])
    for m in range(frac_diff.shape[3]):
        plot_lib.image_plot(fig_im,
                            ax_im[m / 2][m % 2],
                            frac_diff[:, 0, :, m],
                            cmap=cm.coolwarm,
                            xlabel='Frequency (Mhz)',
                            ylabel='Time Pair',
                            cbar_label='Amplitude (UNCALIB)',