Exemplo n.º 1
0
def mc_plot(result_arr, mc_arr, img_name):

    img = Image_Plot(fig_x=6, fig_y=4, xpad=0.25, ypad=0.2)
    img.subplots(1, 2)

    scale = 1000

    img.axs[0][0].errorbar(result_arr[0],
                           result_arr[1],
                           result_arr[2],
                           marker="s",
                           fmt=" ",
                           label="g1",
                           capsize=img.cap_size)
    img.axs[0][0].errorbar(result_arr[3],
                           result_arr[4],
                           result_arr[5],
                           marker="s",
                           fmt=" ",
                           label="g2",
                           capsize=img.cap_size)
    img.axs[0][1].errorbar(result_arr[0],
                           scale * (result_arr[1] - result_arr[0]),
                           scale * result_arr[2],
                           marker="s",
                           fmt=" ",
                           label="g1",
                           capsize=img.cap_size)
    img.axs[0][1].errorbar(result_arr[3],
                           scale * (result_arr[4] - result_arr[3]),
                           scale * result_arr[5],
                           marker="s",
                           fmt=" ",
                           label="g2",
                           capsize=img.cap_size)

    mc_str = "Mean\n$m_1 = %.5f (%.5f)$\n$c_1 = %.5f (%.5f)$\n$m_2 = %.5f (%.5f)$\n$c_2 = %.5f (%.5f)$" \
             % (mc_arr[0, 0], mc_arr[0, 1], mc_arr[0, 2], mc_arr[0, 3],
                mc_arr[1, 0], mc_arr[1, 1], mc_arr[1, 2], mc_arr[1, 3])
    img.axs_text(0, 0, 0.8, 0.05, mc_str, text_fontsize=img.legend_size)

    img.set_label(0, 0, 0, "EST g")
    img.set_label(0, 1, 1, "$10^3 (\hat{g} - g_{true})$")
    img.axs[0][0].plot([-0.1, 0.1], [-0.1, 0.1],
                       ls="dashed",
                       c="grey",
                       alpha=0.5)
    img.axs[0][0].set_ylim(-0.05, 0.05)
    img.axs[0][1].set_ylim(-0.1, 0.1)
    for i in range(2):
        img.set_label(0, i, 1, "TRUE g")
        img.axs[0][i].legend(fontsize=img.legend_size, loc="lower right")
        img.axs[0][i].set_xlim(-0.05, 0.05)
    img.save_img(img_name)
    img.close_img()
Exemplo n.º 2
0
def plot_gf_pix(x, y, ichip, gf1, gf2, gf, gf1_scale, gf2_scale,gf_scale,dot_size=1,pic_path=None):

    chip_row, chip_col = numpy.divmod(ichip, 9)

    x = x + chip_col * 2112
    y = y + chip_row * 4644

    img = Image_Plot(xpad=0.2,ypad=0.1)
    img.subplots(1, 3)
    color_cm = 'bwr'

    norm = plt.Normalize(vmin=numpy.min(gf1_scale[0]), vmax=numpy.max(gf1_scale[1]))
    cmap = plt.get_cmap(color_cm)
    cl = cmap(norm(gf1))
    fig = img.axs[0][0].scatter(x, y, color=cl, s=dot_size)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][0])

    norm = plt.Normalize(vmin=numpy.min(gf2_scale[0]), vmax=numpy.max(gf2_scale[1]))
    cmap = plt.get_cmap(color_cm)
    cl = cmap(norm(gf2))
    fig = img.axs[0][1].scatter(x, y, color=cl, s=dot_size)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][1])

    norm = plt.Normalize(vmin=numpy.min(gf_scale[0]), vmax=numpy.max(gf_scale[1]))
    cmap = plt.get_cmap(color_cm)
    cl = cmap(norm(gf))
    fig = img.axs[0][2].scatter(x, y, color=cl, s=dot_size)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][2])

    for i in range(3):
        img.axis_sci_ticklabel(0,i,0)
        img.axis_sci_ticklabel(0,i,1)
        img.set_label(0,i,0,"y")
        img.set_label(0,i,1,"x")
    if pic_path:
        img.save_img(pic_path)
    # img.show_img()
    img.close_img()
Exemplo n.º 3
0
def plot_label(x, y, cent_xy, cent_label, title, show=None, pic_path=None):
    ncent = cent_label.shape[0]
    img = Image_Plot()
    img.subplots(1, 1)
    for i in range(ncent):
        img.axs[0][0].scatter(cent_xy[0][i],
                              cent_xy[1][i],
                              color="C%d" % i,
                              marker="*",
                              s=80)
        idx = cent_label[i] == 1
        img.axs[0][0].scatter(x[idx],
                              y[idx],
                              edgecolors="C%d" % i,
                              color="none",
                              label="%d, %d" % (i, idx.sum()),
                              s=5)
    img.axs[0][0].set_title(title)
    img.axs[0][0].legend()
    if pic_path:
        img.save_img(pic_path)
    if show:
        img.show_img()
    img.close_img()
Exemplo n.º 4
0
def plot_gf(ra, dec, gf1, gf2, pic_path, gf1_bin_num = 15, gf2_bin_num = 18,gf_bin_num = 18):
    gf = numpy.sqrt(gf1**2 + gf2**2)

    label_1 = numpy.zeros_like(gf1)
    label_2 = numpy.zeros_like(gf2)
    label_3 = numpy.zeros_like(gf)

    gf1_bin = numpy.linspace(gf1.min(), gf1.max(), gf1_bin_num+1)
    gf2_bin = numpy.linspace(gf2.min(), gf2.max(), gf2_bin_num+1)
    gf_bin = numpy.linspace(gf.min(), gf.max(), gf_bin_num+1)

    for i in range(gf1_bin_num):
        idx1 = gf1 >= gf1_bin[i]
        idx2 = gf1 < gf1_bin[i+1]
        idx = idx1 & idx2
        label_1[idx] = (gf1_bin[i]+ gf1_bin[i+1])/2

    for i in range(gf2_bin_num):
        idx1 = gf2 >= gf2_bin[i]
        idx2 = gf2 < gf2_bin[i+1]
        idx = idx1 & idx2
        label_2[idx] = (gf2_bin[i]+ gf2_bin[i+1])/2

    for i in range(gf_bin_num):
        idx1 = gf >= gf_bin[i]
        idx2 = gf < gf_bin[i+1]
        idx = idx1 & idx2
        label_3[idx] = (gf_bin[i]+ gf_bin[i+1])/2


    img = Image_Plot()
    img.subplots(1,3)

    norm = plt.Normalize(vmin=numpy.min(label_1), vmax=numpy.max(label_1))
    cmap = plt.get_cmap('YlOrRd',gf1_bin_num)
    cl = cmap(norm(label_1))
    fig = img.axs[0][0].scatter(ra, dec, color=cl, s=3)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][0])


    norm = plt.Normalize(vmin=numpy.min(label_2), vmax=numpy.max(label_2))
    cmap = plt.get_cmap('YlOrRd',gf2_bin_num)
    cl = cmap(norm(label_2))
    fig = img.axs[0][1].scatter(ra, dec, color=cl, s=3)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][1])


    norm = plt.Normalize(vmin=numpy.min(label_3), vmax=numpy.max(label_3))
    cmap = plt.get_cmap('YlOrRd',gf_bin_num)
    cl = cmap(norm(label_3))
    fig = img.axs[0][2].scatter(ra, dec, color=cl, s=3)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm._A = []
    img.figure.colorbar(sm, ax=img.axs[0][2])

    img.save_img(pic_path)
    # img.show_img()
    img.close_img()
Exemplo n.º 5
0
    t2 = time.time()

    chisq_min_c = coeffc[0] - coeffc[1]**2 / 4 / coeffc[2]
    result_min[2, tag] = chisq_min_c
    result_min[3, tag] = asymc

    for m in range(2):
        img.axis_sci_ticklabel(0, m, 1)
    print(
        "%.5f(%.5f). asym: %.3e. %d source + %d contaminations + %d corrections. %.2f sec"
        % (ghc, ghc_sig, asymc, num_s, num_non, num_corr, t2 - t1))

    img.save_img(data_path + "/result/%d/%s_%.2f_dilute_%d_mg_bins.png" %
                 (mg_bin_num, data_type, dilute_case[tag], mg_bin_num))
    # img.show_img()
    img.close_img()

comm.Barrier()
if rank == 0:
    numpy.savez(
        data_path + "/result/%d/%s_min_change_%d.npz" %
        (mg_bin_num, data_type, mg_bin_num), result_min)
    img = Image_Plot(xpad=0.25)
    img.subplots(1, 2)
    img.axs[0][0].plot(dilute_case,
                       result_min[0],
                       label="$\chi^2_{min}$",
                       marker="s")
    img.axs[0][0].plot(dilute_case,
                       result_min[2],
                       label="$\chi^2_{min}$_corr",
Exemplo n.º 6
0
                                              left=left,
                                              right=right,
                                              fit_num=20,
                                              chi_gap=30,
                                              fig_ax=img_check.axs[0][0])[:2]
        g2_sym, g2_sig_sym = fq.find_shear_bk(mg2,
                                              mnu2,
                                              mg_bin_num,
                                              left=left,
                                              right=right,
                                              fit_num=20,
                                              chi_gap=30,
                                              fig_ax=img_check.axs[0][1])[:2]

        img_check.save_img(img_check_name % ig)
        img_check.close_img()

        mean_result_array[1, ig] = g1_mean
        mean_result_array[2, ig] = g1_sig_mean
        mean_result_array[4, ig] = g2_mean
        mean_result_array[5, ig] = g2_sig_mean

        sym_result_array[1, ig] = g1_sym
        sym_result_array[2, ig] = g1_sig_sym
        sym_result_array[4, ig] = g2_sym
        sym_result_array[5, ig] = g2_sig_sym

    comm.Barrier()

    if rank == 0: