예제 #1
0
            marker = marker_long
        all_marker.append(marker)
        data[eos][usim]["marker"] = marker
data["allx"] = np.array(all_x)
data["ally"] = np.array(all_y)
data["allcol"] = np.array(all_col)
data["allmarker"] = all_marker

# for fits
for eos in simlist.keys():
    for usim in simlist[eos].keys():
        if not data[eos][usim]["isprompt"]:
            total_x.append(data[eos][usim]["x"])
            total_y.append(data[eos][usim]["y"])
#
Printcolor.green("Data is collected")
Printcolor.blue("Plotting Data")


#
def make_plot_name(v_n_x, v_n_y, v_n_col, do_plot_old_table):
    figname = ''
    figname = figname + v_n_x + '_'
    figname = figname + v_n_y + '_'
    figname = figname + v_n_col + '_'
    if do_plot_old_table:
        figname = figname + '_InclOldTbl2'
    figname = figname + '.png'
    return figname

예제 #2
0
def plot_disk_2d():

    # tmp = d3class.get_data(688128, 3, "xy", "ang_mom_flux")
    # print(tmp.min(), tmp.max())
    # print(tmp)
    # exit(1) # dens_unb_geo
    """ --- --- --- """
    '''sly4 '''
    simlist = [
        "SLy4_M13641364_M0_SR", "SLy4_M13641364_M0_SR", "SLy4_M13641364_M0_SR",
        "SLy4_M13641364_M0_SR"
    ]
    # itlist = [434176, 475136, 516096, 565248]
    # itlist = [606208, 647168, 696320, 737280]
    # itlist = [434176, 516096, 647168, 737280]
    ''' ls220 '''
    simlist = [
        "LS220_M14691268_M0_LK_SR", "LS220_M14691268_M0_LK_SR",
        "LS220_M14691268_M0_LK_SR"
    ]  #, "LS220_M14691268_M0_LK_SR"]
    itlist = [1515520, 1728512, 1949696]  #, 2162688]
    ''' dd2 '''
    simlist = [
        "DD2_M13641364_M0_LK_SR_R04", "DD2_M13641364_M0_LK_SR_R04",
        "DD2_M13641364_M0_LK_SR_R04"
    ]  #, "DD2_M13641364_M0_LK_SR_R04"]
    itlist = [1111116, 1741554, 2213326]  #,2611022]
    #
    simlist = [
        "DD2_M13641364_M0_LK_SR_R04", "BLh_M13641364_M0_LK_SR",
        "LS220_M14691268_M0_LK_SR", "SLy4_M13641364_M0_SR"
    ]
    itlist = [2611022, 1974272, 1949696, 737280]
    #

    #

    simlist = ["BLh_M13641364_M0_LK_SR"]
    itlist = [737280]
    v_ns = ["rho", "Ye"]
    rl = 3
    plane = "xy"

    data_dic = {}
    Printcolor.blue("Collecting data...")
    for sim, it in zip(simlist, itlist):
        simit = str(sim) + str(it)
        data_dic[simit] = {}
        print("sim:{} it:{}".format(sim, it))
        d3class = LOAD_PROFILE_XYXZ(sim)
        # d1class = ADD_METHODS_ALL_PAR(sim)
        x_arr = d3class.get_data(it, rl, plane, "x")
        y_arr = d3class.get_data(it, rl, plane, "y")
        data_dic[simit]["x_arr"] = x_arr
        data_dic[simit]["y_arr"] = y_arr
        for v_n in v_ns:
            data_arr = d3class.get_data(it, rl, plane, v_n)
            data_dic[simit][v_n] = data_arr
    Printcolor.green("Data is collected")
    #

    o_plot = PLOT_MANY_TASKS()
    o_plot.gen_set["figdir"] = __outplotdir__
    o_plot.gen_set["type"] = "cartesian"
    o_plot.gen_set["figsize"] = (
        4.2, 3.6
    )  #(4 * len(simlist), 6.0)  # <->, |] # to match hists with (8.5, 2.7)
    o_plot.gen_set[
        "figname"] = "disk_densmodes.png"  # "DD2_1512_slices.png" # LS_1412_slices
    o_plot.gen_set["sharex"] = False
    o_plot.gen_set["sharey"] = True
    o_plot.gen_set["dpi"] = 128
    o_plot.gen_set["subplots_adjust_h"] = -0.35
    o_plot.gen_set["subplots_adjust_w"] = 0.05
    o_plot.set_plot_dics = []

    plot_x_i = 1
    for sim, it in zip(simlist, itlist):
        simit = str(sim) + str(it)
        #
        mask = "x>0"
        v_n = "rho"
        cmap = 'Greys'
        xmin, xmax, ymin, ymax, zmin, zmax = UTILS.get_xmin_xmax_ymin_ymax_zmin_zmax(
            rl)
        rho_dic_xy = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': data_dic[simit]["x_arr"],
            "yarr": data_dic[simit]["y_arr"],
            "zarr": data_dic[simit][v_n],
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': ymin,
            'ymax': ymax,
            'vmin': 1e-9,
            'vmax': 1e-5,
            'fill_vmin': False,  # fills the x < vmin with vmin
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': cmap,
            'norm': "log",
            'fancyticks': True,
            'minorticks': True,
            'title': {},
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        rho_dic_xy['cbar'] = {
            'location': 'left -0.6 .00',
            'label': r'$\rho$ [GEO]',  # 'fmt': '%.1e',
            'labelsize': 14,
            'fontsize': 14
        }
        o_plot.set_plot_dics.append(rho_dic_xy)
        #
        contour_dic_xy = {
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'task': 'contour',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': data_dic[simit]["x_arr"],
            "yarr": data_dic[simit]["y_arr"],
            "zarr": data_dic[simit][v_n],
            'levels': [1.e13 / 6.176e+17],
            'colors': ['white'],
            'lss': ["-"],
            'lws': [1.],
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': 'rho',
            'xscale': None,
            'yscale': None,
            'fancyticks': True,
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        o_plot.set_plot_dics.append(contour_dic_xy)

        # ---

        mask = "x<0"
        v_n = "Ye"
        cmap = "bwr_r"
        ye_dic_xy = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': data_dic[simit]["x_arr"],
            "yarr": data_dic[simit]["y_arr"],
            "zarr": data_dic[simit][v_n],
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'fill_vmin': False,  # fills the x < vmin with vmin
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': ymin,
            'ymax': ymax,
            'vmin': 0.01,
            'vmax': 0.5,
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': cmap,
            'norm': None,
            'fancyticks': True,
            'minorticks': True,
            'title': {},
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        ye_dic_xy['cbar'] = {
            'location': 'right -.02 .00',
            'label': r'$Y_e$',
            'fmt': '%.1f',
            'labelsize': 14,
            'fontsize': 14
        }
        o_plot.set_plot_dics.append(ye_dic_xy)
        plot_x_i += 1
    o_plot.main()
    exit(1)

    o_plot = PLOT_MANY_TASKS()
    o_plot.gen_set["figdir"] = __outplotdir__
    o_plot.gen_set["type"] = "cartesian"
    o_plot.gen_set["figsize"] = (4 * len(simlist), 6.0
                                 )  # <->, |] # to match hists with (8.5, 2.7)
    o_plot.gen_set["figname"] = "disk_structure_last.png".format(
        simlist[0])  #"DD2_1512_slices.png" # LS_1412_slices
    o_plot.gen_set["sharex"] = False
    o_plot.gen_set["sharey"] = True
    o_plot.gen_set["dpi"] = 128
    o_plot.gen_set["subplots_adjust_h"] = -0.35
    o_plot.gen_set["subplots_adjust_w"] = 0.05
    o_plot.set_plot_dics = []
    #
    rl = 3
    #
    o_plot.gen_set["figsize"] = (4.2 * len(simlist), 8.0
                                 )  # <->, |] # to match hists with (8.5, 2.7)

    plot_x_i = 1
    for sim, it in zip(simlist, itlist):
        print("sim:{} it:{}".format(sim, it))
        d3class = LOAD_PROFILE_XYXZ(sim)
        d1class = ADD_METHODS_ALL_PAR(sim)

        t = d3class.get_time_for_it(it, d1d2d3prof="prof")
        tmerg = d1class.get_par("tmerg")
        xmin, xmax, ymin, ymax, zmin, zmax = UTILS.get_xmin_xmax_ymin_ymax_zmin_zmax(
            rl)

        # --------------------------------------------------------------------------

        # --------------------------------------------------------------------------
        mask = "x>0"
        #
        v_n = "rho"
        data_arr = d3class.get_data(it, rl, "xz", v_n)
        x_arr = d3class.get_data(it, rl, "xz", "x")
        z_arr = d3class.get_data(it, rl, "xz", "z")
        # print(data_arr); exit(1)

        contour_dic_xz = {
            'task': 'contour',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": z_arr,
            "zarr": data_arr,
            'levels': [1.e13 / 6.176e+17],
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'colors': ['white'],
            'lss': ["-"],
            'lws': [1.],
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': 'rho',
            'xscale': None,
            'yscale': None,
            'fancyticks': True,
            'sharey': False,
            'sharex': True,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        o_plot.set_plot_dics.append(contour_dic_xz)

        rho_dic_xz = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": z_arr,
            "zarr": data_arr,
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'v_n_x': 'x',
            'v_n_y': 'z',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': zmin,
            'ymax': zmax,
            'vmin': 1e-9,
            'vmax': 1e-5,
            'fill_vmin': False,  # fills the x < vmin with vmin
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': 'Greys',
            'norm': "log",
            'fancyticks': True,
            'minorticks': True,
            'title': {
                "text": sim.replace('_', '\_'),
                'fontsize': 12
            },
            #'title': {"text": r'$t-t_{merg}:$' + r'${:.1f}$ [ms]'.format((t - tmerg) * 1e3), 'fontsize': 14},
            'sharey': False,
            'sharex': True,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        #
        data_arr = d3class.get_data(it, rl, "xy", v_n)
        x_arr = d3class.get_data(it, rl, "xy", "x")
        y_arr = d3class.get_data(it, rl, "xy", "y")

        contour_dic_xy = {
            'task': 'contour',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": y_arr,
            "zarr": data_arr,
            'levels': [1.e13 / 6.176e+17],
            'position': (2, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'colors': ['white'],
            'lss': ["-"],
            'lws': [1.],
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': 'rho',
            'xscale': None,
            'yscale': None,
            'fancyticks': True,
            'sharey': False,
            'sharex': True,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        o_plot.set_plot_dics.append(contour_dic_xy)

        rho_dic_xy = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": y_arr,
            "zarr": data_arr,
            'position': (2, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': ymin,
            'ymax': ymax,
            'vmin': 1e-9,
            'vmax': 1e-5,
            'fill_vmin': False,  # fills the x < vmin with vmin
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': 'Greys',
            'norm': "log",
            'fancyticks': True,
            'minorticks': True,
            'title': {},
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        #
        if plot_x_i == 1:
            rho_dic_xy['cbar'] = {
                'location': 'bottom -.05 .00',
                'label': r'$\rho$ [GEO]',  # 'fmt': '%.1e',
                'labelsize': 14,
                'fontsize': 14
            }
        if plot_x_i > 1:
            rho_dic_xz['sharey'] = True
            rho_dic_xy['sharey'] = True

        o_plot.set_plot_dics.append(rho_dic_xz)
        o_plot.set_plot_dics.append(rho_dic_xy)

        # ----------------------------------------------------------------------
        v_n = "dens_unb_bern"
        #
        data_arr = d3class.get_data(it, rl, "xz", v_n)
        x_arr = d3class.get_data(it, rl, "xz", "x")
        z_arr = d3class.get_data(it, rl, "xz", "z")
        dunb_dic_xz = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": z_arr,
            "zarr": data_arr,
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'v_n_x': 'x',
            'v_n_y': 'z',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': zmin,
            'ymax': zmax,
            'vmin': 1e-10,
            'vmax': 1e-7,
            'fill_vmin': False,  # fills the x < vmin with vmin
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': 'Blues',
            'norm': "log",
            'fancyticks': True,
            'minorticks': True,
            'title':
            {},  #{"text": r'$t-t_{merg}:$' + r'${:.1f}$ [ms]'.format((t - tmerg) * 1e3), 'fontsize': 14},
            'sharex': True,  # removes angular citkscitks
            'sharey': False,
            'fontsize': 14,
            'labelsize': 14
        }
        #
        data_arr = d3class.get_data(it, rl, "xy", v_n)
        x_arr = d3class.get_data(it, rl, "xy", "x")
        y_arr = d3class.get_data(it, rl, "xy", "y")
        dunb_dic_xy = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": y_arr,
            "zarr": data_arr,
            'position': (2, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'fill_vmin': False,  # fills the x < vmin with vmin
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': ymin,
            'ymax': ymax,
            'vmin': 1e-10,
            'vmax': 1e-7,
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': 'Blues',
            'norm': "log",
            'fancyticks': True,
            'minorticks': True,
            'title': {},
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        #
        if plot_x_i == 2:
            dunb_dic_xy['cbar'] = {
                'location': 'bottom -.05 .00',
                'label': r'$D_{\rm{unb}}$ [GEO]',  # 'fmt': '%.1e',
                'labelsize': 14,
                'fontsize': 14
            }
        if plot_x_i > 1:
            dunb_dic_xz['sharey'] = True
            dunb_dic_xy['sharey'] = True

        o_plot.set_plot_dics.append(dunb_dic_xz)
        o_plot.set_plot_dics.append(dunb_dic_xy)

        # ----------------------------------------------------------------------
        mask = "x<0"
        #
        v_n = "Ye"
        cmap = "bwr_r"
        #
        data_arr = d3class.get_data(it, rl, "xz", v_n)
        x_arr = d3class.get_data(it, rl, "xz", "x")
        z_arr = d3class.get_data(it, rl, "xz", "z")
        ye_dic_xz = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": z_arr,
            "zarr": data_arr,
            'position': (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'fill_vmin': False,  # fills the x < vmin with vmin
            'v_n_x': 'x',
            'v_n_y': 'z',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': zmin,
            'ymax': zmax,
            'vmin': 0.05,
            'vmax': 0.5,
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': cmap,
            'norm': None,
            'fancyticks': True,
            'minorticks': True,
            'title':
            {},  #{"text": r'$t-t_{merg}:$' + r'${:.1f}$ [ms]'.format((t - tmerg) * 1e3), 'fontsize': 14},
            'sharey': False,
            'sharex': True,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        #
        data_arr = d3class.get_data(it, rl, "xy", v_n)
        x_arr = d3class.get_data(it, rl, "xy", "x")
        y_arr = d3class.get_data(it, rl, "xy", "y")
        ye_dic_xy = {
            'task': 'colormesh',
            'ptype': 'cartesian',
            'aspect': 1.,
            'xarr': x_arr,
            "yarr": y_arr,
            "zarr": data_arr,
            'position': (2, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
            'cbar': {},
            'fill_vmin': False,  # fills the x < vmin with vmin
            'v_n_x': 'x',
            'v_n_y': 'y',
            'v_n': v_n,
            'xmin': xmin,
            'xmax': xmax,
            'ymin': ymin,
            'ymax': ymax,
            'vmin': 0.01,
            'vmax': 0.5,
            'xscale': None,
            'yscale': None,
            'mask': mask,
            'cmap': cmap,
            'norm': None,
            'fancyticks': True,
            'minorticks': True,
            'title': {},
            'sharey': False,
            'sharex': False,  # removes angular citkscitks
            'fontsize': 14,
            'labelsize': 14
        }
        #
        if plot_x_i == 3:
            ye_dic_xy['cbar'] = {
                'location': 'bottom -.05 .00',
                'label': r'$Y_e$',
                'fmt': '%.1f',
                'labelsize': 14,
                'fontsize': 14
            }
        if plot_x_i > 1:
            ye_dic_xz['sharey'] = True
            ye_dic_xy['sharey'] = True

        o_plot.set_plot_dics.append(ye_dic_xz)
        o_plot.set_plot_dics.append(ye_dic_xy)

        # ----------------------------------------------------------
        tcoll = d1class.get_par("tcoll_gw")
        if not np.isnan(tcoll) and t >= tcoll:
            print(tcoll, t)
            v_n = "lapse"
            mask = "z>0.15"
            data_arr = d3class.get_data(it, rl, "xz", v_n)
            x_arr = d3class.get_data(it, rl, "xz", "x")
            z_arr = d3class.get_data(it, rl, "xz", "z")
            lapse_dic_xz = {
                'task': 'colormesh',
                'ptype': 'cartesian',
                'aspect': 1.,
                'xarr': x_arr,
                "yarr": z_arr,
                "zarr": data_arr,
                'position':
                (1, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
                'cbar': {},
                'v_n_x': 'x',
                'v_n_y': 'z',
                'v_n': v_n,
                'xmin': xmin,
                'xmax': xmax,
                'ymin': zmin,
                'ymax': zmax,
                'vmin': 0.,
                'vmax': 0.15,
                'fill_vmin': False,  # fills the x < vmin with vmin
                'xscale': None,
                'yscale': None,
                'mask': mask,
                'cmap': 'Greys',
                'norm': None,
                'fancyticks': True,
                'minorticks': True,
                'title':
                {},  #,{"text": r'$t-t_{merg}:$' + r'${:.1f}$ [ms]'.format((t - tmerg) * 1e3),
                #'fontsize': 14},
                'sharey': False,
                'sharex': True,  # removes angular citkscitks
                'fontsize': 14,
                'labelsize': 14
            }
            #
            data_arr = d3class.get_data(it, rl, "xy", v_n)
            # print(data_arr.min(), data_arr.max()); exit(1)
            x_arr = d3class.get_data(it, rl, "xy", "x")
            y_arr = d3class.get_data(it, rl, "xy", "y")
            lapse_dic_xy = {
                'task': 'colormesh',
                'ptype': 'cartesian',
                'aspect': 1.,
                'xarr': x_arr,
                "yarr": y_arr,
                "zarr": data_arr,
                'position':
                (2, plot_x_i),  # 'title': '[{:.1f} ms]'.format(time_),
                'cbar': {},
                'v_n_x': 'x',
                'v_n_y': 'y',
                'v_n': v_n,
                'xmin': xmin,
                'xmax': xmax,
                'ymin': ymin,
                'ymax': ymax,
                'vmin': 0,
                'vmax': 0.15,
                'fill_vmin': False,  # fills the x < vmin with vmin
                'xscale': None,
                'yscale': None,
                'mask': mask,
                'cmap': 'Greys',
                'norm': None,
                'fancyticks': True,
                'minorticks': True,
                'title': {},
                'sharey': False,
                'sharex': False,  # removes angular citkscitks
                'fontsize': 14,
                'labelsize': 14
            }
            #
            # if plot_x_i == 1:
            #     rho_dic_xy['cbar'] = {'location': 'bottom -.05 .00', 'label': r'$\rho$ [GEO]',  # 'fmt': '%.1e',
            #                           'labelsize': 14,
            #                           'fontsize': 14}
            if plot_x_i > 1:
                lapse_dic_xz['sharey'] = True
                lapse_dic_xy['sharey'] = True

            o_plot.set_plot_dics.append(lapse_dic_xz)
            o_plot.set_plot_dics.append(lapse_dic_xy)

        plot_x_i += 1

    o_plot.main()

    exit(0)
예제 #3
0
def plot_correlation_from_two_datadirs_vertical():

    sims = ['SFHo_M135135_LK', 'SFHo_M135135_M0', "SFHo_M13641364_M0_LK_SR"]
    colors = ["blue", "red", "green"]  #, "orange"]
    lss = ["-", "--", "-."]  #, ":"]
    rowdata = [
        "/data1/numrel/WhiskyTHC/Backup/2017/",
        "/data1/numrel/WhiskyTHC/Backup/2017/",
        "/data1/numrel/WhiskyTHC/Backup/2018/GW170817/"
    ]
    datapaths = [
        "/data01/numrel/vsevolod.nedora/postprocessed_radice2/",
        "/data01/numrel/vsevolod.nedora/postprocessed_radice2/",
        "/data01/numrel/vsevolod.nedora/postprocessed4/"
    ]
    v_ns = ["Y_e", "Y_e", "Y_e"]
    det = 0
    masks = ["geo", "geo", "geo"]

    #

    dic_data = {}
    for sim, v_n, mask, path in zip(sims, v_ns, masks, datapaths):
        Paths.ppr_sims = path
        o = ADD_METHODS_ALL_PAR(sim)
        corr_table = o.get_outflow_corr(det, mask,
                                        "{}_{}".format(v_n, "theta"))
        dic_data[sim] = {}
        dic_data[sim]["data"] = corr_table.T
        hist = o.get_outflow_hist(det, mask, "theta")
        dic_data[sim]['hist'] = hist.T
        print(hist.T.shape)
    Printcolor.green("data in collected")

    #
    # for sim in sims:
    #     dic_data[sim]['data'] /= np.sum(dic_data[sim]['data'][1:, 1:])

    o_plot = PLOT_MANY_TASKS()
    o_plot.gen_set["figdir"] = __outplotdir__
    o_plot.gen_set["type"] = "cartesian"
    o_plot.gen_set["figsize"] = (4.2, 3.6 * len(sims))  # <->, |]
    o_plot.gen_set["figname"] = "comparison.png".format("Ye")
    o_plot.gen_set["sharex"] = True
    o_plot.gen_set["sharey"] = False
    o_plot.gen_set["dpi"] = 128
    o_plot.gen_set["subplots_adjust_h"] = 0.0
    o_plot.gen_set["subplots_adjust_w"] = 0.0
    o_plot.set_plot_dics = []

    i = 1
    for sim, ls, color in zip(sims, lss, colors):
        # HISTOGRAMS
        plot_dic = {
            'task': 'hist1d',
            'ptype': 'cartesian',
            'position': (1, 1),
            'data': dic_data[sim]["hist"],
            'normalize': True,
            'v_n_x': "theta",
            'v_n_y': "mass",
            'color': color,
            'ls': ls,
            'lw': 1.,
            'ds': 'steps',
            'alpha': 1.0,
            'xmin': 50.,
            'xamx': 90.,
            'ymin': 1e-4,
            'ymax': 1e0,
            'xlabel': Labels.labels("theta"),
            'ylabel': r"$M_{\rm{ej}}/M$",
            'label': sim.replace('_', '\_'),
            'yscale': 'log',
            'fancyticks': True,
            'minorticks': True,
            'fontsize': 14,
            'labelsize': 14,
            'sharex': True,  # removes angular citkscitks
            'sharey': False,
            'title': {},  #{'text':sim.replace('_', '\_'), 'fontsize':12},
            # 'textold': {'coords': (0.1, 0.1), 'text':sim.replace('_', '\_'), 'color': 'black', 'fs': 10},
            'legend': {
                'loc': 'best',
                'ncol': 1,
                'fontsize': 10
            }  # 'loc': 'best', 'ncol': 2, 'fontsize': 18
        }
        # if v_n == "tempterature":
        # if i!=1:
        #     plot_dic['sharey'] = True

        o_plot.set_plot_dics.append(plot_dic)
    i = 2
    for sim in sims:
        # CORRELATIONS
        corr_dic2 = {  # relies on the "get_res_corr(self, it, v_n): " method of data object
            'task': 'corr2d', 'dtype': 'corr', 'ptype': 'cartesian',
            'data': dic_data[sim]['data'],
            'position': (i, 1),
            'v_n_x': 'theta', 'v_n_y': 'ye', 'v_n': 'mass', 'normalize': True,
            'cbar': {},
            'cmap': 'viridis', #'set_under': 'white', #'set_over': 'black',
            'xlabel': r"Angle from binary plane", 'ylabel': r"$Y_e$",
            'xmin': 0., 'xmax': 90., 'ymin': 0.05, 'ymax': 0.5, 'vmin': 1e-4, 'vmax': 1e-2,
            'xscale': "linear", 'yscale': "linear", 'norm': 'log',
            'mask_below': None, 'mask_above': None,
            'title': {},  # {"text": o_corr_data.sim.replace('_', '\_'), 'fontsize': 14},
            'fancyticks': True,
            'minorticks': True,
            'sharex': True,  # removes angular citkscitks
            'sharey': False,
            'fontsize': 14,
            'labelsize': 14,
        }
        corr_dic2["axhline"] = {
            "y": 0.25,
            "linestyle": "-",
            "linewidth": 0.5,
            "color": "black"
        }
        # corr_dic2["axvline"] = {"x": 0.25, "linestyle": "-", "linewidth": 0.5, "color": "black"}
        if sim == sims[-1]:
            corr_dic2['sharex'] = False
        if sim == sims[-1]:
            corr_dic2['cbar'] = \
                {'location': 'right .03 .0', 'label': r"$M_{\rm{ej}}/M$",  # 'fmt': '%.1f',
                'labelsize': 14, 'fontsize': 14}
        o_plot.set_plot_dics.append(corr_dic2)
        i = i + 1
    o_plot.main()
예제 #4
0
def plot_correlation():

    sims = ['DD2_M13641364_M0_SR_R04', 'DD2_M13641364_M0_LK_SR_R04']

    v_ns = ["Y_e", "Y_e"]
    det = 0
    masks = ["geo", "geo"]

    #

    dic_data = {}
    for sim, v_n, mask in zip(sims, v_ns, masks):
        o = ADD_METHODS_ALL_PAR(sim)
        corr_table = o.get_outflow_corr(det, mask,
                                        "{}_{}".format(v_n, "theta"))
        dic_data[sim] = {}
        dic_data[sim]["data"] = corr_table.T
        hist = o.get_outflow_hist(det, mask, "theta")
        dic_data[sim]['hist'] = hist.T
        print(hist.T.shape)
    Printcolor.green("data in collected")

    #
    # for sim in sims:
    #     dic_data[sim]['data'] /= np.sum(dic_data[sim]['data'][1:, 1:])

    o_plot = PLOT_MANY_TASKS()
    o_plot.gen_set["figdir"] = __outplotdir__
    o_plot.gen_set["type"] = "cartesian"
    o_plot.gen_set["figsize"] = (8., 5.6)  # <->, |]
    o_plot.gen_set["figname"] = "comparison.png".format("Ye")
    o_plot.gen_set["sharex"] = False
    o_plot.gen_set["sharey"] = False
    o_plot.gen_set["dpi"] = 128
    o_plot.gen_set["subplots_adjust_h"] = 0.0
    o_plot.gen_set["subplots_adjust_w"] = 0.0
    o_plot.set_plot_dics = []

    i = 1
    for sim in sims:
        # HISTOGRAMS
        plot_dic = {
            'task': 'hist1d',
            'ptype': 'cartesian',
            'position': (1, i),
            'data': dic_data[sim]["hist"],
            'normalize': True,
            'v_n_x': "theta",
            'v_n_y': "mass",
            'color': "black",
            'ls': '-',
            'lw': 1.,
            'ds': 'steps',
            'alpha': 1.0,
            'xmin': 0.,
            'xamx': 90.,
            'ymin': 1e-4,
            'ymax': 1e0,
            'xlabel': Labels.labels("theta"),
            'ylabel': r"$M_{\rm{ej}}/M$",
            'label': None,
            'yscale': 'log',
            'fancyticks': True,
            'minorticks': True,
            'fontsize': 14,
            'labelsize': 14,
            'sharex': True,  # removes angular citkscitks
            'sharey': False,
            'title': {
                'text': sim.replace('_', '\_'),
                'fontsize': 12
            },
            # 'textold': {'coords': (0.1, 0.1), 'text':sim.replace('_', '\_'), 'color': 'black', 'fs': 10},
            'legend': {}  # 'loc': 'best', 'ncol': 2, 'fontsize': 18
        }
        # if v_n == "tempterature":
        if i != 1:
            plot_dic['sharey'] = True

        o_plot.set_plot_dics.append(plot_dic)
        # CORRELATIONS
        corr_dic2 = {  # relies on the "get_res_corr(self, it, v_n): " method of data object
            'task': 'corr2d', 'dtype': 'corr', 'ptype': 'cartesian',
            'data': dic_data[sim]['data'],
            'position': (2, i),
            'v_n_x': 'theta', 'v_n_y': 'ye', 'v_n': 'mass', 'normalize': True,
            'cbar': {},
            'cmap': 'viridis', #'set_under': 'white', #'set_over': 'black',
            'xlabel': r"Angle from binary plane", 'ylabel': r"$Y_e$",
            'xmin': 0., 'xmax': 90., 'ymin': 0.05, 'ymax': 0.5, 'vmin': 1e-4, 'vmax': 1e-2,
            'xscale': "linear", 'yscale': "linear", 'norm': 'log',
            'mask_below': None, 'mask_above': None,
            'title': {},  # {"text": o_corr_data.sim.replace('_', '\_'), 'fontsize': 14},
            'fancyticks': True,
            'minorticks': True,
            'sharex': False,  # removes angular citkscitks
            'sharey': False,
            'fontsize': 14,
            'labelsize': 14,
        }
        corr_dic2["axhline"] = {
            "y": 0.25,
            "linestyle": "-",
            "linewidth": 0.5,
            "color": "black"
        }
        # corr_dic2["axvline"] = {"x": 0.25, "linestyle": "-", "linewidth": 0.5, "color": "black"}
        if i != 1:
            corr_dic2['sharey'] = True
        if sim == sims[-1]:
            corr_dic2['cbar'] = \
                {'location': 'right .03 .0', 'label': r"$M_{\rm{ej}}/M$",  # 'fmt': '%.1f',
                'labelsize': 14, 'fontsize': 14}
        o_plot.set_plot_dics.append(corr_dic2)
        i = i + 1
    o_plot.main()
예제 #5
0
def plot_hists_from_different_dirs():

    # sims = ['SFHo_M135135_LK', 'SFHo_M135135_M0', 'SFHo_M13641364_M0_SR', "SFHo_M13641364_M0_LK_SR"]
    # sims = ['LS220_M135135_LK', 'LS220_M135135_M0', 'LS220_M13641364_M0_SR', "LS220_M13641364_M0_LK_SR"]
    # sims = ['DD2_M135135_LK', 'DD2_M135135_M0', 'DD2_M13641364_M0_SR_R04', "DD2_M13641364_M0_LK_SR_R04"]
    # sims = ['BHBlp_M130130_LK', 'BHBlp_M135135_M0']
    # sims = ['BLh_M13651365_M0_SR', 'BLh_M13641364_M0_LK_SR']
    sims = ['SLy4_M13641364_M0_SR', 'SLy4_M13641364_M0_LK_SR']
    colors = ["blue", "red"]#, "green", "purple"]
    lss = ["-", "--"]#, "-.", ":"]
    # datapaths = ["/data01/numrel/vsevolod.nedora/postprocessed_radice2/",
    #                "/data01/numrel/vsevolod.nedora/postprocessed_radice2/"]
    datapaths = ["/data01/numrel/vsevolod.nedora/postprocessed4/",
                  "/data01/numrel/vsevolod.nedora/postprocessed4/"]
    #

    v_ns = ["Y_e", 'theta', 'entropy']
    det = 0
    masks = ['geo', 'geo', 'geo']

    #

    dic_data = {}
    for v_n, mask in zip(v_ns, masks):
        dic_data[v_n+mask] = {}
        for sim, path in zip(sims, datapaths):
            dic_data[v_n+mask][sim] = {}
            Paths.ppr_sims = path
            o = ADD_METHODS_ALL_PAR(sim)
            # corr_table = o.get_outflow_corr(det, mask, "{}_{}".format(v_n, "theta"))
            # dic_data[v_n+mask][sim]["data"] = corr_table.T
            hist = o.get_outflow_hist(det, mask, v_n)
            dic_data[v_n+mask][sim]['hist'] = hist.T
            dic_data[v_n + mask][sim]['mej'] = sum(hist.T[:,1])
            print(hist.T.shape)
    Printcolor.green("data in collected")

    #
    # for sim in sims:
    #     dic_data[sim]['data'] /= np.sum(dic_data[sim]['data'][1:, 1:])

    o_plot = PLOT_MANY_TASKS()
    o_plot.gen_set["figdir"] = __outplotdir__
    o_plot.gen_set["type"] = "cartesian"
    o_plot.gen_set["figsize"] = (4.2*len(v_ns), 3.6)  # <->, |]
    o_plot.gen_set["figname"] = "comparison_sly4.png"
    o_plot.gen_set["sharex"] = False
    o_plot.gen_set["sharey"] = False
    o_plot.gen_set["dpi"] = 128
    o_plot.gen_set["subplots_adjust_h"] = 0.0
    o_plot.gen_set["subplots_adjust_w"] = 0.0
    o_plot.set_plot_dics = []

    i = 1
    for v_n, mask in zip(v_ns, masks):
        # textdic = {'task': 'text', 'ptype': 'cartesian',
        #            'position': (1, i), 'x': 0.5, 'y': 0.5,
        #            'text': r"{}".format(dic_data[v_n + mask][sim]['mej'] * 1e2) + "$[10^2M_{\odot}]$", 'fs': 12,
        #            'color': 'black', 'horal': True, 'transform': True}

        for sim, ls, color in zip(sims, lss, colors):
            # HISTOGRAMS
            mej = np.sum(dic_data[v_n + mask][sim]["hist"][:, 1])
            plot_dic = {
                'task': 'hist1d', 'ptype': 'cartesian',
                'position': (1, i),
                'data': dic_data[v_n+mask][sim]["hist"], 'normalize': False,
                'v_n_x': v_n, 'v_n_y': "mass",
                'color': color, 'ls': ls, 'lw': 1., 'ds': 'steps', 'alpha': 1.0,
                'xmin': 0., 'xamx': 90., 'ymin': 1e-5, 'ymax': 1e-3,
                'xlabel': Labels.labels(v_n), 'ylabel': r"$M_{\rm{ej}}$",
                'label': None, 'yscale': 'log',
                'fancyticks': True, 'minorticks': True,
                'fontsize': 14,
                'labelsize': 14,
                'sharex': False,  # removes angular citkscitks
                'sharey': False,
                # 'yticks': [],
                'title':{},#{'text':sim.replace('_', '\_'), 'fontsize':12},
                # 'textold': {'coords': (0.1, 0.1), 'text':sim.replace('_', '\_'), 'color': 'black', 'fs': 10},
                'legend': {'loc': 'best', 'ncol': 1, 'fontsize': 10}  # 'loc': 'best', 'ncol': 2, 'fontsize': 18
            }

            # textdic = {'task': 'text', 'ptype': 'cartesian',
            #            'position': (1, i), 'x': 0.5, 'y': 0.5,
            #            'text': r"{}".format(mej * 1e2) + "$[10^2M_{\odot}]$", 'fs': 12,
            #            'color': 'black', 'horal': True, 'transform': True}

            # if v_n == "tempterature":
            # if i!=1:
            #     plot_dic['sharey'] = True
            if v_n != v_ns[0]:
                plot_dic['sharey'] = False
                plot_dic['yticks'] = []
                plot_dic['rmylbls'] = True
                plot_dic['ylabel'] = None
            if v_n == v_ns[0]:
                # mej = np.sum(dic_data[v_n+mask][sim]["hist"][:,1])
                # o_plot.set_plot_dics.append(textdic)
                plot_dic['label'] = sim.replace('_', '\_')
            elif v_n == v_ns[-1]:
                mej = np.sum(dic_data[v_n + mask][sim]["hist"][:, 1])
                plot_dic['label'] = r"$M_{\rm{ej}}$ "+"{:.2f}".format(mej * 1e2) + "$ [10^2M_{\odot}]$"

            if v_n == "theta":
                plot_dic['xmin'], plot_dic['xmax'] = 0., 90.
                plot_dic['xmajorticks'] = np.arange(5) * 90. / 4.
                plot_dic['xminorticks'] = np.arange(17) * 90. / 16
                plot_dic['xmajorlabels'] = [r"$0^\circ$", r"$22.5^\circ$", r"$45^\circ$",
                            r"$67.5^\circ$", r"$90^\circ$"]
            elif v_n == "entropy":
                plot_dic['xmin'], plot_dic['xmax'] = 5, 95.
            elif v_n == "Y_e":
                plot_dic['xmin'], plot_dic['xmax'] = 0.05, 0.45



            o_plot.set_plot_dics.append(plot_dic)
        i = i + 1
    o_plot.main()
    exit(1)