def set_dic_yminymax(v_n, dic, yarr, extra=2.): # if v_n == "Mej_tot-geo" or v_n == "Mej": dic['ymin'], dic['ymax'] = 0, 1.5 elif v_n == "Mej_tot-geo_2" or v_n == "Mej2": dic['ymin'], dic['ymax'] = 0, 2 elif v_n == "Mej_tot-geo_1" or v_n == "Mej1": dic['ymin'], dic['ymax'] = 0, 0.7 elif v_n == "Mej_tot-geo_3" or v_n == "Mej3": dic['ymin'], dic['ymax'] = 0, 2 elif v_n == "Mej_tot-geo_4" or v_n == "Mej4": dic['ymin'], dic['ymax'] = 0, .75 elif v_n == "Mej_tot-geo_5" or v_n == "Mej5": dic['ymin'], dic['ymax'] = 0, 10. elif v_n == "Mej_tot-geo_6" or v_n == "Mej6": dic['ymin'], dic['ymax'] = 0, 0.06 elif v_n == "Mej_tot-geo_entropy_above_10" or v_n == "Mej_shocked": dic['ymin'], dic['ymax'] = 0, 0.7 elif v_n == "Mej_tot-geo_entropy_below_10" or v_n == "Mej_tidal": dic['ymin'], dic['ymax'] = 0, 0.5 else: dic['ymin'], dic['ymax'] = np.array(yarr).min(), np.array( yarr).max() + (extra * (np.array(yarr).max() - np.array(yarr).min())) Printcolor.yellow("xlimits are not set for v_n_x:{}".format(v_n)) return dic
def compute_outflow_new_mask(self, det, sim, mask, rewrite): # get_tmax60 # ms print("\tAdding mask:{}".format(mask)) o_outflow = EJECTA_PARS(sim, add_mask=mask) if not os.path.isdir(Paths.ppr_sims + sim +"/" +"outflow_{:d}/".format(det) + mask + '/'): os.mkdir(Paths.ppr_sims + sim +"/" +"outflow_{:d}/".format(det) + mask + '/') Printcolor.blue("Creating new outflow mask dir:{}" .format(sim +"/" +"outflow_{:d}/".format(det) + mask + '/')) for task in self.outflow_tasks: if task == "hist": # from outflowed import outflowed_historgrams outflowed_historgrams(o_outflow, [det], [mask], o_outflow.list_hist_v_ns, rewrite=rewrite) elif task == "corr": # from outflowed import outflowed_correlations outflowed_correlations(o_outflow, [det], [mask], o_outflow.list_corr_v_ns, rewrite=rewrite) elif task == "totflux": # from outflowed import outflowed_totmass outflowed_totmass(o_outflow, [det], [mask], rewrite=rewrite) elif task == "timecorr": # from outflowed import outflowed_timecorr outflowed_timecorr(o_outflow, [det], [mask], o_outflow.list_hist_v_ns, rewrite=rewrite) else: raise NameError("method for computing outflow with new mask is not setup for task:{}".format(task))
def set_dic_xminxmax(v_n, dic, xarr): # if v_n == "Mej_tot-geo" or v_n == "Mej": dic['xmin'], dic['xmax'] = 0, 1.5 elif v_n == "Lambda": dic['xmin'], dic['xmax'] = 5, 1500 elif v_n == "Mej_tot-geo_entropy_above_10" or v_n == "Mej_shocked": dic['xmin'], dic['xmax'] = 0, 0.7 elif v_n == "Mej_tot-geo_entropy_below_10" or v_n == "Mej_tidal": dic['xmin'], dic['xmax'] = 0, 0.5 else: dic['xmin'], dic['xmax'] = np.array(xarr).min(), np.array(xarr).max() Printcolor.yellow("xlimits are not set for v_n_x:{}".format(v_n)) return dic
def get_post_geo_delta_t(self, det): # o_par1 = ALL_PAR(self.sim1) # o_par2 = ALL_PAR(self.sim2) # tmerg1 = self.o_par1.get_par("tmerger") # tmerg2 = self.o_par2.get_par("tmerger") t98geomass1 = self.o_par1.get_outflow_par(det, "geo", "t98mass") t98geomass2 = self.o_par2.get_outflow_par(det, "geo", "t98mass") t98geomass3 = self.o_par3.get_outflow_par(det, "geo", "t98mass") tend1 = self.o_par1.get_outflow_par(det, "geo", "tend") tend2 = self.o_par2.get_outflow_par(det, "geo", "tend") tend3 = self.o_par3.get_outflow_par(det, "geo", "tend") if tend1 < t98geomass1: Printcolor.red("tend1:{} < t98geomass1:{}".format(tend1, t98geomass1)) return np.nan if tend2 < t98geomass2: Printcolor.red("tend2:{} < t98geomass2:{}".format(tend2, t98geomass2)) return np.nan if tend3 < t98geomass3: Printcolor.red("tend3:{} < t98geomass3:{}".format(tend3, t98geomass3)) return np.nan Printcolor.yellow("Relaxing the time limits criteria") # if tend1 < t98geomass2: # Printcolor.red("Delta t does not overlap tend1:{} < t98geomass2:{}".format(tend1, t98geomass2)) # return np.nan # if tend2 < t98geomass1: # Printcolor.red("Delta t does not overlap tend2:{} < t98geomass1:{}".format(tend2, t98geomass1)) # return np.nan # assert tmerg1 < t98geomass1 # assert tmerg2 < t98geomass2 # tend1 = tend1 - tmerg1 # tend2 = tend2 - tmerg2 # t98geomass1 = t98geomass1 - tmerg1 # t98geomass2 = t98geomass2 - tmerg2 delta_t1 = tend1 - t98geomass1 delta_t2 = tend2 - t98geomass2 delta_t3 = tend3 - t98geomass3 print("\tTime window for bernoulli ") print("\t{} {:.2f} [ms]".format(self.sim1, delta_t1 * 1e3)) print("\t{} {:.2f} [ms]".format(self.sim2, delta_t2 * 1e3)) print("\t{} {:.2f} [ms]".format(self.sim3, delta_t3 * 1e3)) # exit(1) delta_t = np.min([delta_t1, delta_t2, delta_t3]) if delta_t < 0.005: return np.nan# ms return delta_t
dic['ymin'], dic['ymax'] = 0, 0.5 else: dic['ymin'], dic['ymax'] = np.array(yarr).min(), np.array( yarr).max() + (extra * (np.array(yarr).max() - np.array(yarr).min())) Printcolor.yellow("xlimits are not set for v_n_x:{}".format(v_n)) return dic ''' --------------------------------------------------------------- ''' total_x = [] # for fits total_y = [] # for fits Printcolor.blue("Collecting Data") o_tbl = GET_PAR_FROM_TABLE() o_tbl.set_intable = simtable o_tbl.load_table() data = {} all_x = [] all_y = [] all_col = [] all_marker = [] for eos in simlist.keys(): data[eos] = {} for usim in simlist[eos].keys(): data[eos][usim] = {} sims = simlist[eos][usim] print("\t{} [{}] Chrip:{}".format(usim, len(sims), o_tbl.get_par(sims[0], "mchirp")))
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)
def get_tmax_d3_data(self): isd3_1, itd3_1, td3_1 = self.o_par1.get_ittime("profiles", "prof") isd3_2, itd3_2, td3_2 = self.o_par2.get_ittime("profiles", "prof") isd3_3, itd3_3, td3_3 = self.o_par3.get_ittime("profiles", "prof") if len(td3_1) == 0: Printcolor.red("D3 data not found for sim1:{}".format(self.sim1)) return np.nan if len(td3_2) == 0: Printcolor.red("D3 data not found for sim2:{}".format(self.sim2)) return np.nan if len(td3_3) == 0: Printcolor.red("D3 data not found for sim3:{}".format(self.sim3)) return np.nan tmerg1 = self.o_par1.get_par("tmerger") tmerg2 = self.o_par2.get_par("tmerger") tmerg3 = self.o_par3.get_par("tmerger") Printcolor.blue("\ttd3_1[-1]:{} tmerg1:{} -> {}".format(td3_1[-1], tmerg1, td3_1[-1] - tmerg1)) Printcolor.blue("\ttd3_2[-1]:{} tmerg2:{} -> {}".format(td3_2[-1], tmerg2, td3_2[-1] - tmerg2)) Printcolor.blue("\ttd3_3[-1]:{} tmerg3:{} -> {}".format(td3_3[-1], tmerg3, td3_3[-1] - tmerg3)) td3_1 = np.array(td3_1 - tmerg1) td3_2 = np.array(td3_2 - tmerg2) td3_3 = np.array(td3_3 - tmerg3) # if td3_1.min() > td3_2.max(): Printcolor.red("D3 data does not overlap. sim1 has min:{} that is > than sim2 max: {}" .format(td3_1.min(), td3_2.max())) return np.nan if td3_1.min() > td3_3.max(): Printcolor.red("D3 data does not overlap. sim1 has min:{} that is > than sim3 max: {}" .format(td3_1.min(), td3_3.max())) return np.nan if td3_2.min() > td3_3.max(): Printcolor.red("D3 data does not overlap. sim2 has min:{} that is > than sim3 max: {}" .format(td3_2.min(), td3_3.max())) return np.nan # --- if td3_1.max() < td3_2.min(): Printcolor.red("D3 data does not overlap. sim1 has max:{} that is < than sim2 min: {}" .format(td3_1.max(), td3_2.min())) return np.nan if td3_1.max() < td3_3.min(): Printcolor.red("D3 data does not overlap. sim1 has max:{} that is < than sim3 min: {}" .format(td3_1.max(), td3_3.min())) return np.nan if td3_2.max() < td3_3.min(): Printcolor.red("D3 data does not overlap. sim2 has max:{} that is < than sim3 min: {}" .format(td3_2.max(), td3_3.min())) return np.nan tmax = np.min([td3_1.max(), td3_2.max(), td3_3.max()]) Printcolor.blue("\ttmax for D3 data: {}".format(tmax)) return float(tmax)
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()
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()
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)