コード例 #1
0
#import argparse

#parser = argparse.ArgumentParser(description = 'Script to generate correlation v/s duration plots of x triggers\n.
#The duration plotted against is of the x triggers')

#parser.add_argument('channelName', type=str, help='Name of the correlation statistic file which contains data such as correlation, duration, significance etc.')

#args = parser.parse_args()
#fileDir = args.channelName
if (len(sys.argv) < 2):
    print 'Provide atleast one file name'

fileDir = sys.argv[1:]

channelName = fileDir[0].split('results/')[1].split('/')[0].split(
    '+')[0].split('H1-')[1]
correlation = np.asarray([])
duration = np.asraay([])

for iFile in fileDir:
    corrData = np.loadtxt(fileDir[iFile]).reshape(-1, 15)
    correlation = np.append(correlation, corrData[:, 1])
    duration = np.append(duration, corrData[:, 9])

plt.figure()
plt.plot(duration, correlation, '.')
plt.title('Correlation vs trigger durations of %s channel' % (channelName))
plt.ylabel('correlation statistic $r$')
plt.xlabel('trigger durations')
plt.savefig('./corr_vs_duration_%s.png' % (channelName))
plt.close()
コード例 #2
0
import matplotlib.pyplt as plt
#import argparse

#parser = argparse.ArgumentParser(description = 'Script to generate correlation v/s duration plots of x triggers\n.
				 #The duration plotted against is of the x triggers')

#parser.add_argument('channelName', type=str, help='Name of the correlation statistic file which contains data such as correlation, duration, significance etc.')

#args = parser.parse_args()
#fileDir = args.channelName
if(len(sys.argv)<2):
  print 'Provide atleast one file name'

fileDir = sys.argv[1:]

channelName = fileDir[0].split('results/')[1].split('/')[0].split('+')[0].split('H1-')[1]
correlation = np.asarray([])
duration = np.asraay([])

for iFile in fileDir:
  corrData = np.loadtxt(fileDir[iFile]).reshape(-1, 15)
  correlation = np.append(correlation, corrData[:, 1])
  duration = np.append(duration, corrData[:, 9])
  
plt.figure()
plt.plot(duration, correlation, '.')
plt.title('Correlation vs trigger durations of %s channel' %(channelName))
plt.ylabel('correlation statistic $r$')
plt.xlabel('trigger durations')
plt.savefig('./corr_vs_duration_%s.png'%(channelName))
plt.close()
コード例 #3
0
ファイル: stats.py プロジェクト: philrosenfield/TPAGB-calib
def chi2plot(model_dict, outfile_loc=None):
    targets = list(np.unique([k.split("_")[0] for k in model_dict.keys()]))
    agb_mods = list(np.unique(["_".join(k.split("_")[1:4]) for k in model_dict.keys()]))

    cols = ["darkgreen", "navy", "darkred"]

    fig, axs = plt.subplots(ncols=2, nrows=2, sharex=True, sharey=False, figsize=(10, 10))
    offsets = np.linspace(0, 1, len(targets))
    for key, val in model_dict.items():
        if "std" in key:
            continue
        target = key.split("_")[0]
        errval = model_dict[key.replace("mean", "std")]
        ioff = targets.index(target)
        agb_mod = "_".join(key.split("_")[1:4])
        col = cols[agb_mods.index(agb_mod)]
        sym = "o"
        if not agb_mod.endswith("nov13"):
            mfc = "white"
        else:
            mfc = col
        if not "nov13" in agb_mod:
            sym = "*"
        ax_row = 0
        ax_col = 0
        if not "_agb" in key:
            ax_row = 1
        if "ir" in key:
            ax_col = 1
        ax = axs[ax_row][ax_col]

        ax.errorbar(
            offsets[ioff],
            val,
            yerr=errval,
            marker=sym,
            color=col,
            ms=12,
            mfc=mfc,
            ecolor="black",
            mew=1.5,
            elinewidth=2,
        )
        ax.set_ylabel("$\chi^2$", fontsize=20)

        ax.xaxis.set_ticks(offsets)
        ax.set_xticklabels(["$%s$" % t.replace("-deep", "").replace("-", "\!-\!").upper() for t in targets])
        [t.set_rotation(30) for t in ax.get_xticklabels()]

        # ymaxs[ax_num] = np.max([val, ymaxs[ax_num]])
    axs[0][0].set_title(r"$\rm{Optical}$", fontsize=20)
    axs[0][1].set_title(r"$\rm{NIR}$", fontsize=20)
    [ax.set_ylim(0, 25) for ax in axs[:, 0]]
    [ax.set_ylim(0, 10) for ax in axs[:, 1]]
    fig.subplots_adjust(hspace=0.1)
    xlims = ax.get_xlim()
    off = np.diff(offsets)[0]
    ax.set_xlim(xlims[0] - off / 2, xlims[1] + off / 2)
    sym = ["o", "o", "*"]
    mfc = [cols[0], "None", "None"]
    [
        axs[0, 0].plot(
            -99,
            99,
            sym[j],
            mfc=mfc[j],
            ms=12,
            mew=1.5,
            color=cols[j],
            label="$%s$" % model_plots.translate_model_name(agb_mods[j].split("_")[-1]),
        )
        for j in range(len(agb_mods))
    ]
    axs[0, 0].legend(loc=0, numpoints=1)
    [ax.annotate(r"$\rm{TP\!-\!AGB\ Only}$", (0.02, 0.02), fontsize=16, xycoords="axes fraction") for ax in axs[0, :]]
    if outfile_loc is None:
        outfile_loc = os.getcwd()
    outfile = os.path.join(outfile_loc, "chi2_plot.png")
    plt.tick_params(labelsize=16)
    plt.savefig(outfile, dpi=150)

    return axs