예제 #1
0
def power_model(files_o, files_c, ps=0.12):

    waves = [445, 551, 658, 806]

    fwhm_o = []
    fwhm_c = []
    fwhm_o_err = []
    fwhm_c_err = []
    for i in range(4):
        FWHM_min_o, sig_FWHM_min_o, FWHM_maj_o, sig_FWHM_maj_o = moffat.calc_mof_fwhm(
            files_o[i], filt=False, plate_scale=ps)
        FWHM_min_c, sig_FWHM_min_c, FWHM_maj_c, sig_FWHM_maj_c = moffat.calc_mof_fwhm(
            files_c[i], filt=False, plate_scale=ps)
        fwhm_o.append(np.median(FWHM_min_o) * ps)
        fwhm_o_err.append(np.std(FWHM_min_o) * ps / np.sqrt(len(FWHM_min_o)))
        fwhm_c.append(np.median(FWHM_min_c) * ps)
        fwhm_c_err.append(np.std(FWHM_min_c) * ps / np.sqrt(len(FWHM_min_c)))

    plt.errorbar(waves, fwhm_o, yerr=fwhm_o_err, fmt='bo', label='AO-Off Data')
    plt.errorbar(waves, fwhm_c, yerr=fwhm_c_err, fmt='ro', label='AO-On Data')

    init = models.PowerLaw1D(amplitude=1., x_0=1., alpha=1.)
    fit = fitting.LevMarLSQFitter()
    p_o = fit(init, waves, fwhm_o, weights=1.0 / np.array(fwhm_o_err))
    p_c = fit(init, waves, fwhm_c, weights=1.0 / np.array(fwhm_c_err))

    x = np.linspace(445, 806, 100)
    plt.plot(x, p_o(x), 'b-', label='AO-Off Model')
    plt.plot(x, p_c(x), 'r-', label='AO-On Model')

    χ2_o = np.sum(((p_o(waves) - fwhm_o) / fwhm_o_err)**2)
    χ2_c = np.sum(((p_c(waves) - fwhm_c) / fwhm_c_err)**2)

    α_o = p_o.alpha.value
    α_c = p_c.alpha.value

    #plt.text(450, 0.61, 'χ$^2$='+str(np.round(χ2_o,2)), color='b', fontsize=14)
    #plt.text(450, 0.5, 'χ$^2$='+str(np.round(χ2_c,2)), color='r', fontsize=14)
    #plt.text(450, 0.63, 'α='+str(np.round(α_o,2)), color='b', fontsize=14)
    #plt.text(450, 0.52, 'α='+str(np.round(α_c,2)), color='r', fontsize=14)
    print('χ$^2$=' + str(np.round(χ2_o, 2)))
    print('χ$^2$=' + str(np.round(χ2_c, 2)))
    print('α=' + str(np.round(α_o, 2)))
    print('α=' + str(np.round(α_c, 2)))

    plt.xlabel('Observation Wavelength (nm)', fontsize=16)
    plt.ylabel('Minor FWHM (arcsec)', fontsize=16)
    plt.title('Wavelength Dependence Model', fontsize=18)
    plt.legend()
    plt.xticks(fontsize=14)
    plt.yticks(fontsize=14)

    return
예제 #2
0
def plot_fwhm_beta_4F_frames(redu, c_keys = ["LS_c", "tt_c", "_o"], xlim=[0,1.5], ylim = [1,7]):
    filters = ["B", "V", "R", "I"]
    
    fig, ax = plt.subplots(ncols=2, nrows=1, figsize=(10,4))
    filt_colors = sns.color_palette("Spectral", 5)
    fdict_color = {"B":filt_colors[4], "V":filt_colors[3], "R":filt_colors[1], "I":filt_colors[0]}
    kdict_fmt = {'LS_c':'x', 'docz_c': '+', 'tt_c':'^', '_o':'o'}
    kdict_name = {'_o':'Open (AO Off)', 'docz_c':'Closed LS (AO On)', 'LS_c':'Closed LS (AO On)', 'tt_c':'Closed TT (AO Partial)'}

    # iterate through filters
    for fil_band in filters:
        for key in c_keys:
            stat_f = f'{redu.root_dir}reduce/stats/stats_{key}_{fil_band}_mdp.fits'
            stats = Table.read(stat_f)

            # TODO: outlier rejection

            FWHM_min, sig_FWHM_min, FWHM_maj, sig_FWHM_maj = moffat.calc_mof_fwhm(stat_f, filt=False, plate_scale=stats.meta['SCALE'])
            ax[0].errorbar(np.median(FWHM_min), np.median(stats['Beta']), xerr=np.median(sig_FWHM_min), yerr=np.median(stats['Beta std']), fmt=kdict_fmt[key],  ecolor='lightgray', mec=fdict_color[fil_band], mfc=fdict_color[fil_band])
            ax[1].errorbar(np.median(FWHM_maj), np.median(stats['Beta']), xerr=np.median(sig_FWHM_maj), yerr=np.median(stats['Beta std']), fmt=kdict_fmt[key],  ecolor='lightgray', mec=fdict_color[fil_band], mfc=fdict_color[fil_band])

    ax[0].set_xlabel(r'FWHM Moffat MIN (as)')
    ax[1].set_xlabel(r'FWHM Moffat MAJ (as)')
    ax[0].set_ylabel(r'$\beta$')

    ax[1].set_ylim(ylim[0], ylim[1])    
    ax[0].set_ylim(ylim[0], ylim[1])

    ax[1].set_xlim(xlim[0], xlim[1])    
    ax[0].set_xlim(xlim[0], xlim[1]) 

    ax[0].legend(handles=[mlines.Line2D([0], [0], marker=kdict_fmt[key], label=kdict_name[key], color='grey',  lw=0) for key in c_keys])
    ax[1].legend(handles=[mpatches.Patch(color=value, label=key) for key, value in fdict_color.items()], loc=2)

    plt.suptitle(f"Moffat Summary for {redu.night}, combined filter rotations")
    return
예제 #3
0
def plot_stack_stats_4F_time(date, suffixes=['open', 'ttf', 'closed'], root_dir='/Users/jlu/work/imaka/pleiades/', reduce_dir='fli/reduce/'):
    """
        Make a suite of standard plots for the stats on a given night.
        Parameters
        ----------
        date : str
        The date string for which to plot up the stats (i.e. '20170113').
        Optional Parameters
        -------------------
        suffix : str
        stats files have the name stats_open<suffix>.fits, stats_ttf<suffix>.fits, and
        stats_closed<suffix>.fits.
        root_dir : str
        The root directory for the <date> observing run directories. The
        stats files will be searched for in:
        <root_dir>/<date>/fli/reduce/stats/
        """
    stats_dir = root_dir + date + '/' + reduce_dir + 'stats/'
    plots_dir = root_dir + date + '/' + reduce_dir + 'plots/'
    
    labels = ['B', 'V', 'R', 'I']
    dict_filt = {"B":"b", "V":"c", "R":"r", "I":"m"}
    f_fmt = {'LS_c':'x', 'docz2_c':'+', 'tt_c':'^', "_o":'o'}
    f_name = {"_o":'Open', 'LS_c':'Closed (LS)', 'docz2_c':'Closed (DOC)', 'tt_c':'Closed (tt)'}
        
    util.mkdir(plots_dir)
    
    suff_filt = []
    stats = []
    for suffix in suffixes:
        for f in labels:
            stats_file = f'{stats_dir}stats_{suffix}_{f}.fits'
            table_tmp = Table.read(stats_file)
            scale_tmp = table_tmp[0].meta['SCALE']
            
            FWHM_min, sig_FWHM_min, FWHM_maj, sig_FWHM_maj = moffat.calc_mof_fwhm(stats_file, filt=False, plate_scale=scale_tmp)
            
            N_frames = len(table_tmp)
            table_tmp.add_column(Column(FWHM_maj, name='FWHM_maj'))
            table_tmp.add_column(Column(FWHM_min, name='FWHM_min'))
            table_tmp.add_column(Column(np.repeat(f, N_frames), name='filter'))

            stats.append(table_tmp)
            suff_filt.append(f"{suffix}_{f}")

    scale = stats[0].meta['SCALE']
    colors = get_color_list()
    
    #
    # Plots for ratio of improvements. First we need to find a matching
    # closed loop image to go with each open (and TTF) image.
    #
    tree_indices = []
    tree_so = scipy.spatial.KDTree(np.array([stats[0]['Index']]).T)
    for ss in range(len(stats)):
        dist_ss, idx_ss = tree_so.query(np.array([stats[ss]['Index']]).T, 1)
        tree_indices.append(idx_ss)

##########
# All plots vs. time.
##########

    utcs = []
    for ss in range(len(suff_filt)):
        utc_dt = [datetime.strptime(stats[ss]['TIME_UTC'][ii], '%H:%M:%S') for ii in range(len(stats[ss]))]
        utcs.append(utc_dt)

    time_fmt = mp_dates.DateFormatter('%H:%M')
    
    
    #####
    # FWHM
    #####
    plt.figure(8, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['FWHM']*scale, marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Gaussian-Fit FWHM (")')
    plt.legend(numpoints=1)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['FWHM'] / stats[ss%4]['FWHM'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of Gaussian-Fit FWHM')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'fwhm_vs_time' + suffix + '.png')

#####
# Empirical FWHM
#####
    plt.figure(9, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['emp_fwhm']*scale, marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Empirical FWHM (")')
    plt.legend(numpoints=1)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['emp_fwhm'] / stats[ss%4]['emp_fwhm'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of Empircal FWHM')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'efwhm_vs_time' + suffix + '.png')
    
    #####
    # EE 50
    #####
    plt.figure(10, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['EE50'], marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Radius of 50% Encircled Energy (")')
    plt.legend(numpoints=1)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['EE50'] / stats[ss%4]['EE50'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of 50% EE Radius')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'ee50_vs_time' + suffix + '.png')

#####
# EE 80
#####
    plt.figure(11, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['EE80'], marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Radius of 80% Encircled Energy (")')
    plt.legend(numpoints=1)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['EE80'] / stats[ss%4]['EE80'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of 80% EE Radius')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'ee80_vs_time' + suffix + '.png')

#####
# NEA
#####
    plt.figure(12, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['NEA']*scale**2, marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('NEA (Sq. Arcsec)')
    plt.legend(numpoints=1)
    plt.ylim(0, 5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['NEA'] / stats[ss%4]['NEA'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of NEA')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.5)
    plt.savefig(plots_dir + 'nea_vs_time' + suffix + '.png')

#####
# NEA2
#####
    plt.figure(13, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(utcs[ss], stats[ss]['NEA2']*scale**2, marker='o', linestyle='none', label=suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('NEA2 (Sq. Arcsec)')
    plt.legend(numpoints=1)
    plt.ylim(0, 5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['NEA2'] / stats[ss%4]['NEA2'][idx], marker='o', linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of NEA2')
    plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.5)
    plt.savefig(plots_dir + 'nea2_vs_time' + suffix + '.png')
    
    #####
    # FWHM for each direction
    #####
    plt.figure(14, figsize=(12, 6))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        c = np.take(colors, ss, mode='wrap')
        plt.plot(utcs[ss], stats[ss]['xFWHM']*scale, marker='o', color=c, linestyle='none', label='X ' + suff_filt[ss])
        plt.plot(utcs[ss], stats[ss]['yFWHM']*scale, marker='^', color=c, linestyle='none', label='Y ' + suff_filt[ss])
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Gaussian-Fit FWHM (")')
    plt.legend(numpoints=1, fontsize=10)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        c = np.take(colors, ss, mode='wrap')
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        utc = [utcs[0][ii] for ii in idx]
        plt.plot(utc, stats[ss]['xFWHM'] / stats[ss%4]['xFWHM'][idx], marker='o', color=c, linestyle='none', label=label)
        plt.plot(utc, stats[ss]['yFWHM'] / stats[ss%4]['yFWHM'][idx], marker='^', color=c, linestyle='none', label=label)
    plt.gca().xaxis.set_major_formatter(time_fmt)
    plt.xticks(rotation=35)
    plt.xlabel('UTC Time (hr)')
    plt.ylabel('Ratio of Gaussian-Fit FWHM')
    plt.legend(numpoints=1, fontsize=10)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'xyfwhm_vs_time' + suffix + '.png')
    
    return
예제 #4
0
def plot_stack_stats_4F_frame(date, suffixes=['open', 'ttf', 'closed'], root_dir='/Users/jlu/work/imaka/pleiades/', reduce_dir='fli/reduce/'):
    """
        Make a suite of standard plots for the stats on a given night.
        Parameters
        ----------
        date : str
        The date string for which to plot up the stats (i.e. '20170113').
        Optional Parameters
        -------------------
        suffix : str
        stats files have the name stats_open<suffix>.fits, stats_ttf<suffix>.fits, and
        stats_closed<suffix>.fits.
        root_dir : str
        The root directory for the <date> observing run directories. The
        stats files will be searched for in:
        <root_dir>/<date>/fli/reduce/stats/
        """
    stats_dir = root_dir + date + '/' + reduce_dir + 'stats/'
    plots_dir = root_dir + date + '/' + reduce_dir + 'plots/'
    
    labels = ['B', 'V', 'R', 'I']
    filt_colors = sns.color_palette("Spectral", 5)
    dict_filt = {"B":filt_colors[4], "V":filt_colors[3], "R":filt_colors[1], "I":filt_colors[0]}
    #dict_filt = {"B":"b", "V":"c", "R":"r", "I":"m"}
    f_fmt = {'LS_c':'x', 'docz2_c':'+', 'tt_c':'^', "_o":'o'}
    f_name = {"_o":'Open', 'LS_c':'Closed (LS)', 'docz2_c':'Closed (DOC)', 'tt_c':'Closed (tt)'}
        
    util.mkdir(plots_dir)
    
    suff_filt = []
    stats = []
    for suffix in suffixes:
        for f in labels:
            stats_file = f'{stats_dir}stats_{suffix}_{f}.fits'
            table_tmp = Table.read(stats_file)
            scale_tmp = table_tmp[0].meta['SCALE']
            
            FWHM_min, sig_FWHM_min, FWHM_maj, sig_FWHM_maj = moffat.calc_mof_fwhm(stats_file, filt=False, plate_scale=scale_tmp)
            
            N_frames = len(table_tmp)
            table_tmp.add_column(Column(FWHM_maj, name='FWHM_maj'))
            table_tmp.add_column(Column(FWHM_min, name='FWHM_min'))
            table_tmp.add_column(Column(np.repeat(f, N_frames), name='filter'))

            stats.append(table_tmp)
            suff_filt.append(f"{suffix}_{f}")

    scale = stats[0].meta['SCALE']
    colors = get_color_list()
    
    #
    # Plots for ratio of improvements. First we need to find a matching
    # closed loop image to go with each open (and TTF) image.
    #
    tree_indices = []
    tree_so = scipy.spatial.KDTree(np.array([stats[0]['Index']]).T)
    for ss in range(len(stats)):
        dist_ss, idx_ss = tree_so.query(np.array([stats[ss]['Index']]).T, 1)
        tree_indices.append(idx_ss)
    
    #####
    # MOFFAT FWHM vs. Frame
    #####
    
    plt.figure(1, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):   
        plt.plot(stats[ss]['Index'], stats[ss]['FWHM_min'], marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Moffat-Fit FWHM_min (")')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) for key, value in f_fmt.items()])
    plt.ylim(0, 1.5)
    plt.title(date)

    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['FWHM_min'] / stats[ss%4]['FWHM_min'][idx],  linestyle='none', marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.legend(handles=[mpatches.Patch(color=value, label=key) for key, value in dict_filt.items()], loc=2)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of Moffat-Fit FWHM_min')
    #plt.legend(numpoints=1)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'fwhm_vs_frame' + suffix + '.png')
    
    #####
    # Empirical FWHM
    #####
    plt.figure(2, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(stats[ss]['Index'], stats[ss]['emp_fwhm']*scale, marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Empirical FWHM (")')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) for key, value in f_fmt.items()])
    plt.ylim(0, 1.5)

    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['emp_fwhm'] / stats[ss%4]['emp_fwhm'][idx], linestyle='none', 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of Empircal FWHM')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()][:ss//4])
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'efwhm_vs_frame' + suffix + '.png')
    
    
    #####
    # EE 50
    #####
    plt.figure(3, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(stats[ss]['Index'], stats[ss]['EE50'], marker=f_fmt[suffixes[ss//4]], 
                 color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Radius of 50% Encircled Energy (")')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) 
                        for key, value in f_fmt.items()])
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['EE50'] / stats[ss%4]['EE50'][idx], linestyle='none', 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of 50% EE Radius')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()][:ss//4])
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'ee50_vs_frame' + suffix + '.png')

#####
# EE 80
#####
    plt.figure(4, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(stats[ss]['Index'], stats[ss]['EE80'], marker=f_fmt[suffixes[ss//4]], 
                 color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Radius of 80% Encircled Energy (")')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) 
                        for key, value in f_fmt.items()])
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['EE80'] / stats[ss%4]['EE80'][idx], linestyle='none', 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of 80% EE Radius')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()][:ss//4])
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'ee80_vs_frame' + suffix + '.png')
    
    #####
    # NEA
    #####
    plt.figure(5, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(stats[ss]['Index'], stats[ss]['NEA'] * scale**2, marker=f_fmt[suffixes[ss//4]], 
                 color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('NEA (Sq. Arcsec)')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) 
                        for key, value in f_fmt.items()])
    plt.ylim(0, 5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['NEA'] / stats[ss%4]['NEA'][idx], linestyle='none', 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of NEA')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()][:ss//4])
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.5)
    plt.savefig(plots_dir + 'nea_vs_frame' + suffix + '.png')
    
    #####
    # NEA2
    #####
    plt.figure(6, figsize=(12, 4))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        plt.plot(stats[ss]['Index'], stats[ss]['NEA2']*scale**2, marker=f_fmt[suffixes[ss//4]], 
                 color=dict_filt[labels[ss%4]], linestyle='none', label=suff_filt[ss], alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('NEA2 (Sq. Arcsec)')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key], color='grey',  lw=0) 
                        for key, value in f_fmt.items()])
    plt.ylim(0, 5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['NEA2'] / stats[ss%4]['NEA2'][idx], linestyle='none', 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], label=label, alpha=0.7)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of NEA2')
    #plt.legend(numpoints=1)
    plt.legend(handles=[mlines.Line2D([0], [0], marker=value, label=f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()][:ss//4])
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.5)
    plt.savefig(plots_dir + 'nea2_vs_frame' + suffix + '.png')

#####
# FWHM for each direction
#####
    plt.figure(7, figsize=(12, 8))
    plt.subplots_adjust(left=0.1, bottom=0.15)
    plt.clf()
    plt.subplot(121)
    for ss in range(len(suff_filt)):
        c = np.take(colors, ss, mode='wrap')
        plt.plot(stats[ss]['Index'], stats[ss]['xFWHM']*scale, marker=f_fmt[suffixes[ss//4]],   
                 color=dict_filt[labels[ss%4]], linestyle='none', label='X ' + suff_filt[ss])
        plt.plot(stats[ss]['Index'], stats[ss]['yFWHM']*scale, marker=f_fmt[suffixes[ss//4]], 
                 color=dict_filt[labels[ss%4]], linestyle='none', label='Y ' + suff_filt[ss], alpha = 0.5)
    plt.xlabel('Frame Number')
    plt.ylabel('Gaussian-Fit FWHM (")')
    #plt.legend(numpoints=1, fontsize=10)
    handles_xy = [mlines.Line2D([0], [0], marker=value, label="x "+f_name[key], color='grey',  lw=0) for key, value in f_fmt.items()] + [mlines.Line2D([0], [0], marker=value, label="y "+f_name[key], color='grey',  lw=0, alpha=0.3) for key, value in f_fmt.items()]
    plt.legend(handles=handles_xy)
    plt.ylim(0, 1.5)
    plt.title(date)
    
    plt.subplot(122)
    for ss in range(4, len(suff_filt)):
        idx = tree_indices[ss]
        label = suff_filt[ss] + " / " + suff_filt[ss%4]
        plt.plot(stats[0]['Index'][idx], stats[ss]['xFWHM'] / stats[ss%4]['xFWHM'][idx], 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]], linestyle='none', label=label)
        plt.plot(stats[0]['Index'][idx], stats[ss]['yFWHM'] / stats[ss%4]['yFWHM'][idx], 
                 marker=f_fmt[suffixes[ss//4]], color=dict_filt[labels[ss%4]],linestyle='none', label=label, alpha = 0.5)
    plt.xlabel('Frame Number')
    plt.ylabel('Ratio of Gaussian-Fit FWHM')
    #plt.legend(numpoints=1, fontsize=10)
    handles_xy = [mlines.Line2D([0], [0], marker=value, label="x "+f_name[key]+" / Open", color='grey',  lw=0) for key, value in f_fmt.items()] + [mlines.Line2D([0], [0], marker=value, label="y "+f_name[key]+" / Open", color='grey',  lw=0, alpha=0.5) for key, value in f_fmt.items()]
    plt.legend(handles=handles_xy)
    plt.axhline(1.0, color='k', linestyle='--', linewidth=2)
    plt.ylim(0, 1.3)
    plt.savefig(plots_dir + 'xyfwhm_vs_frame' + suffix + '.png')
    
    return
예제 #5
0
def plot_stability(files_o, files_c):

    labels = ['B', 'V', 'R', 'I']

    plt.figure(figsize=(8, 10))
    for i in range(4):

        # Make divisions by focus
        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        ind3 = np.where(dat['Focus'] == str(-3.5))
        if i == 0:
            ind = ind3
        else:
            ind = ind2

    list_o = []
    list_c = []

    for i in range(4):

        # Make divisions by focus
        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        ind3 = np.where(dat['Focus'] == str(-3.5))
        if i == 0:
            ind = ind3
        else:
            ind = ind2

        FWHM_min_o, sig_FWHM_min, FWHM_maj, sig_FWHM_maj = moffat.calc_mof_fwhm(
            files_o[i], filt=False)
        FWHM_min_c, sig_FWHM_min, FWHM_maj, sig_FWHM_maj = moffat.calc_mof_fwhm(
            files_c[i], filt=False)
        list_o.append(FWHM_min_o[ind] * 0.12)
        list_c.append(FWHM_min_c[ind] * 0.12)

    fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(7, 5))

    # rectangular box plot
    bplot1 = axes.boxplot(list_o, sym='', vert=True,
                          patch_artist=True)  # fill with color
    for patch in bplot1['boxes']:
        patch.set_alpha(0.3)
    for element in ['boxes', 'whiskers', 'fliers', 'means', 'medians', 'caps']:
        plt.setp(bplot1[element], color='blue')

    bplot2 = axes.boxplot(list_c, sym='', vert=True, patch_artist=True)
    for patch in bplot2['boxes']:
        patch.set_alpha(0.3)
    for element in ['boxes', 'whiskers', 'fliers', 'means', 'medians', 'caps']:
        plt.setp(bplot2[element], color='red')

    # Formatting Axes and Labels
    axes.yaxis.grid(True)
    axes.set_xticks([y + 1 for y in range(4)], )
    axes.set_xlabel('Observation Band', fontsize=18)
    axes.set_ylabel('Minor FWHM (arcsec)', fontsize=18)

    plt.setp(axes, xticks=[y + 1 for y in range(4)], xticklabels=labels)
    axes.tick_params(axis='both', which='major', labelsize=16)
    plt.tight_layout()

    axes.text(3.9, 0.93, 'AO-Off', color='k', fontsize=16)
    axes.text(3.2, 0.93, 'AO-On', color='k', fontsize=16)
    axes.add_patch(
        patches.Rectangle((3.85, 0.92), 0.6, 0.05, color='blue', alpha=0.3))
    axes.add_patch(
        patches.Rectangle((3.13, 0.92), 0.6, 0.05, color='red', alpha=0.3))

    plt.savefig('Four_Filter_Stability.png')
    plt.show()

    return
예제 #6
0
def plot_gain(files_o, files_c, ps=0.12):

    plt.figure(1, figsize=(14, 6))
    waves = [445, 551, 658, 806]

    for i in range(4):
        plt.subplot(121)
        FWHM_min_o, sig_FWHM_min_o, FWHM_maj_o, sig_FWHM_maj_o = moffat.calc_mof_fwhm(
            files_o[i], filt=False)
        FWHM_min_c, sig_FWHM_min_c, FWHM_maj_c, sig_FWHM_maj_c = moffat.calc_mof_fwhm(
            files_c[i], filt=False)
        if i == 0:
            plt.errorbar(waves[i],
                         np.median(FWHM_min_o) * ps,
                         yerr=np.std(FWHM_min_o) * ps /
                         np.sqrt(len(FWHM_min_o)),
                         fmt='bo',
                         label='AO Off, Min')
            plt.errorbar(waves[i],
                         np.median(FWHM_min_c) * ps,
                         yerr=np.std(FWHM_min_c) * ps /
                         np.sqrt(len(FWHM_min_c)),
                         fmt='ro',
                         label='AO On, Min')
            plt.errorbar(waves[i],
                         np.median(FWHM_maj_o) * ps,
                         yerr=np.std(FWHM_maj_o) * ps /
                         np.sqrt(len(FWHM_maj_o)),
                         fmt='bs',
                         label='AO Off, Maj')
            plt.errorbar(waves[i],
                         np.median(FWHM_maj_c) * ps,
                         yerr=np.std(FWHM_maj_c) * ps /
                         np.sqrt(len(FWHM_maj_c)),
                         fmt='rs',
                         label='AO On, Maj')

        else:
            plt.errorbar(waves[i],
                         np.median(FWHM_min_o) * ps,
                         yerr=np.std(FWHM_min_o) * ps /
                         np.sqrt(len(FWHM_min_o)),
                         fmt='bo')
            plt.errorbar(waves[i],
                         np.median(FWHM_min_c) * ps,
                         yerr=np.std(FWHM_min_c) * ps /
                         np.sqrt(len(FWHM_min_c)),
                         fmt='ro')
            plt.errorbar(waves[i],
                         np.median(FWHM_maj_o) * ps,
                         yerr=np.std(FWHM_maj_o) * ps /
                         np.sqrt(len(FWHM_maj_o)),
                         fmt='bs')
            plt.errorbar(waves[i],
                         np.median(FWHM_maj_c) * ps,
                         yerr=np.std(FWHM_maj_c) * ps /
                         np.sqrt(len(FWHM_maj_c)),
                         fmt='rs')

        plt.subplot(122)
        gain_min = np.median(FWHM_min_o) / np.median(FWHM_min_c)
        gain_maj = np.median(FWHM_maj_o) / np.median(FWHM_maj_c)
        if i == 0:
            plt.plot(waves[i], gain_min, 'ko', label='Minor')
            plt.plot(waves[i], gain_maj, 'ks', label='Major')
        else:
            plt.plot(waves[i], gain_min, 'ko')
            plt.plot(waves[i], gain_maj, 'ks')

    plt.subplot(121)
    plt.xlabel('Observation Wavelength (nm)', fontsize=16)
    plt.ylabel('Minor FWHM (arcsec)', fontsize=16)
    plt.legend(fontsize=14, loc='best')
    plt.xticks(fontsize=14)
    plt.yticks(fontsize=14)
    plt.legend(fontsize=14)

    plt.subplot(122)
    plt.xlabel('Observation Wavelength (nm)', fontsize=16)
    plt.ylabel('Correction Factor', fontsize=16)
    plt.xticks(fontsize=14)
    plt.yticks(fontsize=14)
    plt.legend(fontsize=14)

    plt.savefig('colors_arcsec.png')
    plt.tight_layout()

    return
예제 #7
0
def minmaj_FWHM(files_o, files_c):

    labels = ['B', 'V', 'R', 'I']
    ps = 0.12
    plt.figure(figsize=(9, 8))
    for i in range(4):

        # Make divisions by focus
        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        ind3 = np.where(dat['Focus'] == str(-3.5))
        if i == 0:
            ind = ind3
        else:
            ind = ind2

        # Read in Moffat fit data
        FWHM_min_o, sig_FWHM_min_o, FWHM_maj_o, sig_FWHM_maj_o = moffat.calc_mof_fwhm(
            files_o[i], filt=False)
        FWHM_min_c, sig_FWHM_min_c, FWHM_maj_c, sig_FWHM_maj_c = moffat.calc_mof_fwhm(
            files_c[i], filt=False)

        # Plot FWHM distributions
        plt.subplot(4, 2, (i * 2) + 1)
        bins = np.arange(2 * ps, 10 * ps, 0.001 * ps)

        plt.hist(FWHM_min_o[ind] * ps,
                 bins=bins,
                 histtype='step',
                 cumulative=True,
                 normed=True,
                 color='b',
                 label='AO Off, min')
        plt.hist(FWHM_maj_o[ind] * ps,
                 bins=bins,
                 histtype='step',
                 cumulative=True,
                 normed=True,
                 color='b',
                 linestyle='--',
                 label='AO Off, Maj')
        plt.hist(FWHM_min_c[ind] * ps,
                 bins=bins,
                 histtype='step',
                 cumulative=True,
                 normed=True,
                 color='r',
                 label='AO On, min')
        plt.hist(FWHM_maj_c[ind] * ps,
                 bins=bins,
                 histtype='step',
                 cumulative=True,
                 normed=True,
                 color='r',
                 linestyle='--',
                 label='AO On, maj')
        plt.axvline(np.median(FWHM_min_o[ind]) * ps, color='b', alpha=0.5)
        plt.axvline(np.median(FWHM_maj_o[ind]) * ps,
                    color='b',
                    alpha=0.5,
                    linestyle='--')
        plt.axvline(np.median(FWHM_min_c[ind]) * ps, color='r', alpha=0.5)
        plt.axvline(np.median(FWHM_maj_c[ind]) * ps,
                    color='r',
                    alpha=0.5,
                    linestyle='--')

        plt.yticks(fontsize=14)
        plt.ylabel(labels[i], fontsize=16)
        plt.xlim(2.9 * ps, 9.5 * ps)
        plt.yticks([0, 0.2, 0.4, 0.6, 0.8])
        if i == 0:
            plt.title('Minor and Major FWHM', fontsize=18)
        if i == 3:
            plt.xlabel('FWHM (arcsec)', fontsize=16)
            plt.xticks(fontsize=14)
            plt.legend(fontsize=9, loc=4)
        else:
            plt.xticks([], [])

        plt.subplot(4, 2, (i * 2) + 2)
        bins = np.arange(1, 2, 0.05)
        elon_o = FWHM_maj_o / FWHM_min_o
        elon_c = FWHM_maj_c / FWHM_min_c
        plt.hist(elon_o[ind],
                 bins=bins,
                 color='b',
                 alpha=0.5,
                 normed=True,
                 label='AO-Off')
        plt.hist(elon_c[ind],
                 bins=bins,
                 color='r',
                 alpha=0.5,
                 normed=True,
                 label='AO-On')

        plt.xlim(1, 1.8)
        plt.yticks(fontsize=14)
        plt.axvline(np.median(elon_o), color='Navy')
        plt.axvline(np.median(elon_c), color='Firebrick')
        if i == 0:
            plt.title('Elongation', fontsize=18)
            plt.legend(fontsize=14)
        if i == 3:
            plt.xlabel('Elongation Factor', fontsize=16)
            plt.xticks(fontsize=14)
        else:
            plt.xticks([], [])

    plt.subplots_adjust(hspace=0)
    plt.savefig('4filt_fwhm.png')
    return
예제 #8
0
def focus_comp(files_o, files_c):

    plt.figure(figsize=(15, 6))
    colors = ['b', 'g', 'r', 'purple']
    waves = [445, 551, 658, 806]
    ps = 0.12

    ax0 = plt.subplot2grid((2, 7), (0, 0), colspan=3, rowspan=2)
    ax1 = plt.subplot2grid((2, 7), (0, 3), colspan=2)
    ax2 = plt.subplot2grid((2, 7), (0, 5), colspan=2)
    ax3 = plt.subplot2grid((2, 7), (1, 3), colspan=2)
    ax4 = plt.subplot2grid((2, 7), (1, 5), colspan=2)

    for i in range(4):

        FWHM_min_o, sig_FWHM_min_o, FWHM_maj_o, sig_FWHM_maj_o = moffat.calc_mof_fwhm(
            files_o[i], filt=False)
        FWHM_min_c, sig_FWHM_min_c, FWHM_maj_c, sig_FWHM_maj_c = moffat.calc_mof_fwhm(
            files_c[i], filt=False)

        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        ind3 = np.where(dat['Focus'] == str(-3.5))
        FWHM_2 = np.mean(FWHM_min_o[ind2]) * 0.12
        FWHM_3 = np.mean(FWHM_min_o[ind3]) * 0.12
        FWHM_0 = np.mean(FWHM_min_o) * 0.12
        err_2 = (np.std(FWHM_min_o[ind2]) /
                 np.sqrt(len(FWHM_min_o[ind2]))) * 0.12
        err_3 = (np.std(FWHM_min_o[ind3]) /
                 np.sqrt(len(FWHM_min_o[ind3]))) * 0.12
        err_0 = (np.std(FWHM_min_o) / np.sqrt(len(FWHM_min_o))) * 0.12
        ax0.errorbar(waves[i] + 10,
                     FWHM_2,
                     yerr=err_2,
                     fmt='x',
                     color=colors[i])
        ax0.errorbar(waves[i] - 10,
                     FWHM_3,
                     yerr=err_3,
                     fmt='+',
                     color=colors[i])
        ax0.errorbar(waves[i], FWHM_0, yerr=err_0, fmt='*', color=colors[i])

        dat = Table.read(files_c[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        ind3 = np.where(dat['Focus'] == str(-3.5))
        FWHM_2 = np.mean(FWHM_min_c[ind2]) * 0.12
        FWHM_3 = np.mean(FWHM_min_c[ind3]) * 0.12
        FWHM_0 = np.mean(FWHM_min_c) * 0.12
        err_2 = (np.std(FWHM_min_c[ind2]) /
                 np.sqrt(len(FWHM_min_c[ind2]))) * 0.12
        err_3 = (np.std(FWHM_min_c[ind3]) /
                 np.sqrt(len(FWHM_min_c[ind3]))) * 0.12
        err_0 = (np.std(FWHM_min_c) / np.sqrt(len(FWHM_min_c))) * 0.12
        ax0.errorbar(waves[i] + 10,
                     FWHM_2,
                     yerr=err_2,
                     fmt='x',
                     color=colors[i])
        ax0.errorbar(waves[i] - 10,
                     FWHM_3,
                     yerr=err_3,
                     fmt='+',
                     color=colors[i])
        ax0.errorbar(waves[i], FWHM_0, yerr=err_0, fmt='*', color=colors[i])

    ax0.plot(0, 0, 'kx', label='Focus=-2.0')
    ax0.plot(0, 0, 'k+', label='Focus=-3.5')
    ax0.plot(0, 0, 'k*', label='Combined')
    ax0.axhline(0.578, color='k', linestyle='--')
    ax0.legend(loc=3, fontsize=14)
    ax0.axis([410, 840, 0.45, 0.7])
    ax0.text(600, 0.583, 'AO-Off', fontsize=14)
    ax0.text(600, 0.565, 'AO-On', fontsize=14)

    ax0.xaxis.set_tick_params(labelsize=14)
    ax0.yaxis.set_tick_params(labelsize=14)
    ax0.set_xlabel('Observation Wavelength (nm)', fontsize=16)
    ax0.set_ylabel('Minor FWHM (arcsec)', fontsize=16)

    #####

    bins = np.arange(3 * ps, 10 * ps, 0.001)

    for i in range(4):
        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        FWHM_2 = dat['emp_fwhm'][ind2] * ps
        ax1.hist(FWHM_2,
                 bins=bins,
                 color=colors[i],
                 histtype='step',
                 normed=True,
                 cumulative=True)
        ax1.axvline(np.median(FWHM_2), color=colors[i], alpha=0.5)
    ax1.set_ylabel('Focus=-2.0', fontsize=16)
    ax1.set_title('AO-Off', fontsize=18)
    ax1.set_xlim(4 * ps, 9 * ps)

    for i in range(4):
        dat = Table.read(files_o[i])
        ind2 = np.where(dat['Focus'] == str(-3.5))
        FWHM_2 = dat['emp_fwhm'][ind2] * ps
        ax3.hist(FWHM_2,
                 bins=bins,
                 color=colors[i],
                 histtype='step',
                 normed=True,
                 cumulative=True)
        ax3.axvline(np.median(FWHM_2), color=colors[i], alpha=0.5)
    ax3.set_ylabel('Focus=-3.5', fontsize=16)
    ax3.set_xlabel('Minor FWHM (arcsec)', fontsize=16)
    ax3.set_xlim(4 * ps, 9 * ps)

    for i in range(4):
        dat = Table.read(files_c[i])
        ind2 = np.where(dat['Focus'] == str(-2))
        FWHM_2 = dat['emp_fwhm'][ind2] * ps
        ax2.hist(FWHM_2,
                 bins=bins,
                 color=colors[i],
                 histtype='step',
                 normed=True,
                 cumulative=True)
        ax2.axvline(np.median(FWHM_2), color=colors[i], alpha=0.5)
    ax2.set_title('AO-On', fontsize=18)
    ax2.set_xlim(3 * ps, 6.5 * ps)
    ax2.set_ylabel('Focus=-3.5', fontsize=16)

    for i in range(4):
        dat = Table.read(files_c[i])
        ind2 = np.where(dat['Focus'] == str(-3.5))
        FWHM_2 = dat['emp_fwhm'][ind2] * ps
        ax4.hist(FWHM_2,
                 bins=bins,
                 color=colors[i],
                 histtype='step',
                 normed=True,
                 cumulative=True)
        ax4.axvline(np.median(FWHM_2), color=colors[i], alpha=0.5)
    ax4.set_xlabel('Minor FWHM (arcsec)', fontsize=16)
    ax4.set_xlim(3 * ps, 6.5 * ps)
    ax4.set_ylabel('Focus=-2.0', fontsize=16)

    plt.subplots_adjust(hspace=0, wspace=1)
    plt.savefig('filt_comp.png')

    return