def scatterplot_vinit_Tfinal(): from pltastro import frame, draw, legend from numpy import histogram frm = frame.multi(2, 1) pars = frm.params pars.left = 0.2 pars.figsize = (6, 8) pnls = frm.panels pars.height_ratios = [4, 1] pnls.ylabels = ["Vinit [km/s]", "frac"] pnls.set_xlabels("log(T_final)") pnls.set_xlims(3.0, 7.0) pnls.ylims[0] = (0.0, 1500.) pnls.ylims[1] = (0.0, 0.3) fig, axs = draw(frm) vi, Tf = [], [] for p in pg3: vi.append(p.track['dv'][0]) Tf.append(log10(p.track['T'][-1])) # Tf.append(p.track['T'][-1]) axs[0].plot(Tf, vi, "b.", alpha=0.3, markersize=4) hist, edges = histogram(Tf, bins=linspace(3, 7, 30)) mid = 0.5 * (edges[1:] + edges[:-1]) norm = sum(hist) hist = array(hist) / (float)(norm) axs[1].plot(mid, hist, "b.-") vi, Tf = [], [] for p in pparts: vi.append(p.track['dv'][0]) Tf.append(p.track['T'][-1]) axs[0].plot(Tf, vi, "r.", alpha=0.3, markersize=4) hist, edges = histogram(Tf, bins=linspace(3, 7, 30)) mid = 0.5 * (edges[1:] + edges[:-1]) norm = sum(hist) hist = array(hist) / (float)(norm) axs[1].plot(mid, hist, "r.-") lgd = legend.legend(axs[0]) lgd.addLine(("Gadget3", "blue", "-", 1)) lgd.addLine(("GIZMO", "red", "-", 1)) lgd.loc = "upper left" lgd.fontsize = 12 lgd.draw() plt.savefig("/scratch/shuiyao/figures/tmp.pdf") plt.show()
aedges = linspace(0., 1., nbins+1) acen = 0.5 * (aedges[1:] + aedges[:-1]) tcen = (tcosmic(acen) - tcosmic(REDSHIFT)) / 1.e9 acen = 1. / acen - 1. # z da = 1. / nbins ZSOLAR = log10(0.0122) def find_windtime_bin(awind): bin_idx = awind / da return (int)(bin_idx) from pltastro import frame, draw import config_mpl frm = frame.multi(3,1) pars = frm.params pars.figsize = (5, 9) pars.left = 0.2 pars.top = 0.92 pars.bottom = 0.2 panels = frm.panels panels.set_xlabels(r"$z$") panels.set_ylabels("Fraction") # panels.set_xlims(0.0, 1.0) # panels.set_xlims(REDSHIFT, 3.0) panels.set_xlims(0.0, 10.0) if(CUMULATIVE_DISTRIBUTION): panels.set_ylims(0.0, 1.0) else: panels.set_ylims(0.0, 0.4)
# lgds = ["l25n144-phew-m5-spl", "l25n288-phew-m5"] # ncpus = [128, 256] lstyles = ["--", "-"] REDSHIFT = 0.0 if (REDSHIFT == 0.0): zstr = "108" if (REDSHIFT == 1.0): zstr = "078" if (REDSHIFT == 2.0): zstr = "058" if (REDSHIFT == 4.0): zstr = "033" if (REDSHIFT == 0.25): zstr = "098" ALIM = acosmic(tcosmic(1. / (1. + REDSHIFT)) - 1.e9) # ALIM = 0 from pltastro import frame, draw import config_mpl frm = frame.multi(2, 1) pars = frm.params pars.figsize = (5, 7) pars.left = 0.2 pars.top = 0.90 pars.bottom = 0.1 panels = frm.panels panels.set_xlabels(r"$\sigma_{gal} [km/s]$") panels.set_xlims(0.0, SIGMAX) panels.set_ylabels("Mass") # <-------------------------------- # panels.set_ylabels("Fraction") # panels.set_ylims(0.0, 1.0) fig, axs = draw(frm) LBOX_MPC = 50.0
cols = array([1, 2, 5, 6, 7, 9, 10]) tab = ioformat.rcol(fnamey, cols + offset, separator=",", linestart=1) for i in range(len(tab)): tab[i] = array(tab[i]) idxs = (tab[-1] > 1.e16) for i in range(len(tab)): tab[i] = log10(tab[i][idxs]) # Strong Correlations # HI: MgII, CIII 2 # OVI: NeVIII 1 # CIV: SiIV 1 # No/Weak Correlations # HI: CIV, OVI 2 # CIV: CIII, OVI 2 from pltastro import frame, draw frm = frame.multi(4,2) pars = frm.params pars.figsize = (8, 10) pars.hspace = 0.40 pars.wspace = 0.25 pars.bottom = 0.08 pars.top = 0.95 pars.left = 0.1 pars.right = 0.9 pnls = frm.panels pnls.xticksON = [True] * 8 pnls.yticksON = [True] * 8 fig, axs = draw(frm) xions = [6, 6, 1, 0, 6, 6, 1, 1] yions = [4, 3, 5, 2, 1, 0, 3, 0]
def figure(): from pltastro import frame, draw import config_mpl pparts = load_particles(filename, fphewsname) frm = frame.multi(3, 2) params = frm.params params.figsize = (9, 10) params.left = 0.12 params.right = 0.95 params.bottom = 0.28 params.top = 0.93 params.wspace = 0.30 params.hspace = 0.05 panels = frm.panels # panels.set_xticks([0., 0.2, 0.4, 0.6, 0.8, 1.0]) panels.set_xlabels(r"$Time [Myr]$") panels.set_xlims(0., 800.) panels.ylims[0] = (0., 1.) panels.ylims[1] = (0., 20.) panels.ylims[2] = (0., 1.) # panels.ylims[3] = (3.5, 5.) panels.ylims[3] = (4.0, 7.0) panels.ylims[4] = (-28., -22.) panels.ylims[5] = (-30., -24.) panels.yticks[0] = [0.2, 0.4, 0.6, 0.8, 1.0] panels.yticks[1] = [5., 10., 15., 20.] panels.yticks[2] = [0.2, 0.4, 0.6, 0.8, 1.0] # panels.yticks[3] = [4.0, 4.5, 5.0] panels.yticks[3] = [5.0, 6.0, 7.0] panels.yticks[4] = [-28., -26., -24., -22.] panels.yticks[5] = [-30., -28., -26., -24.] for i in range(6): panels.yticksON[i] = True panels.ylabels[0] = r"$R/R_\mathrm{vir}$" panels.ylabels[1] = r"$\mathcal{M}$" panels.ylabels[2] = r"$M_\mathrm{c}$" panels.ylabels[3] = r"$T_\mathrm{a}$" panels.ylabels[4] = r"$\rho_\mathrm{c}$" panels.ylabels[5] = r"$\rho_\mathrm{a}$" fig, axs = draw(frm) parts_to_show = select_particles(pparts) # parts_to_show = select_hard_particles(pparts) draw_phew_particles(parts_to_show, axs[0], 'time', 'r/rvir', 'Mvir', nskip=NSKIP, logyscale=False, color_min=11.0, color_max=13.5, alpha=0.4) print(counter_spurious_particles) draw_phew_particles(parts_to_show, axs[1], 'time', 'Mach', 'Mvir', nskip=NSKIP, logyscale=False, color_min=11.0, color_max=13.5, alpha=0.4) draw_phew_particles(parts_to_show, axs[2], 'time', 'M_cloud', 'Mvir', nskip=NSKIP, logyscale=False, color_min=11.0, color_max=13.5, alpha=0.4) draw_phew_particles(parts_to_show, axs[3], 'time', 'T_a', 'Mvir', nskip=NSKIP, logyscale=True, color_min=11.0, color_max=13.5, alpha=0.4) draw_phew_particles(parts_to_show, axs[4], 'time', 'rho_c', 'Mvir', nskip=NSKIP, logyscale=True, color_min=11.0, color_max=13.5, alpha=0.4) draw_phew_particles(parts_to_show, axs[5], 'time', 'rho_a', 'Mvir', nskip=NSKIP, logyscale=True, color_min=11.0, color_max=13.5, alpha=0.4) # axs[1].text(0.5, 0.85, modelname, fontsize=12, transform=axs[1].transAxes) axcbar = fig.add_axes([0.15, 0.15, 0.7, 0.01]) norm1 = mpl.colors.Normalize(vmin=11.0, vmax=13.5) cdcbar = mpl.colorbar.ColorbarBase(axcbar, cmap=plt.get_cmap(CMAP), norm=norm1, orientation="horizontal") cdcbar.set_ticks([11, 11.5, 12, 12.5, 13.0, 13.5]) cdcbar.set_ticklabels(["11", "11.5", "12", "12.5", "13", "13.5"]) cdcbar.set_label(r"$M_\mathrm{vir}$") plt.savefig(DIRS['FIGURE'] + "tmp.pdf") plt.show()
def figure(): from pltastro import frame, draw import config_mpl frm = frame.multi(2, 1) params = frm.params params.figsize = (5, 9) params.hspace = 0.35 params.top = 0.93 params.bottom = 0.28 params.left = 0.20 panels = frm.panels panels.set_ylims(2.5, 8.) panels.xlims[0] = (0., 6000.) panels.xlims[1] = (-31., -23.) panels.xticks[0] = [0, 2000, 4000, 6000] panels.xticks[1] = [-31., -29., -27., -25., -23.] panels.set_yticks([3, 4, 5, 6, 7]) panels.ylabels[0] = r'$\log(T)$' panels.ylabels[1] = r'$\log(T)$' panels.xlabels[0] = "Time [Myr]" panels.xlabels[1] = r"$\log(\rho_a\ [\mathrm{g/cm^3}])$" for i in range(2): panels.yticksON[i] = True for i in range(2): panels.xticksON[i] = True fig, axs = draw(frm) pparts = load_particles() # tracks print("Draw Tracks.....") keys = draw_phew_particles(pparts, axs[0], 'time', 'T', 'Mvir', nskip=NSKIP, logyscale=False, color_min=11.0, color_max=13.5, alpha=0.3, post_recouple=False) keys = draw_phew_particles(pparts, axs[1], 'rho', 'T', 'Mvir', nskip=NSKIP, logyscale=False, color_min=11.0, color_max=13.5, alpha=0.3, post_recouple=False) phews = phew.load_particles(filename_phews, fphewsname) # phews for p in phews: key_to_phew[p.key] = p phews_to_show = [] for key in keys: phews_to_show.append(key_to_phew[key]) print("Draw PhEWs (%d) ....." % (len(phews_to_show))) phew.draw_phew_particles(phews_to_show, axs[0], 'time', 'T_c', 'Mvir', nskip=1, logyscale=True, logxscale=False, color_min=11.0, color_max=13.5, alpha=0.3, allparts=True) phew.draw_phew_particles(phews_to_show, axs[1], 'rho_a', 'T_c', 'Mvir', nskip=1, logyscale=True, logxscale=True, color_min=11.0, color_max=13.5, alpha=0.3, allparts=True) draw_phase_diagram_contour(axs[1]) # axs[0].text(0.5, 0.85, modelname, fontsize=12, transform=axs[1].transAxes) axs[0].set_title(model + ", z = " + str(REDSHIFT)) axcbar = fig.add_axes([0.15, 0.15, 0.7, 0.01]) norm1 = mpl.colors.Normalize(vmin=11.0, vmax=13.5) cdcbar = mpl.colorbar.ColorbarBase(axcbar, cmap=plt.get_cmap(CMAP), norm=norm1, orientation="horizontal") cdcbar.set_ticks([11, 11.5, 12, 12.5, 13.0, 13.5]) cdcbar.set_ticklabels(["11", "11.5", "12", "12.5", "13", "13.5"]) cdcbar.set_label(r"$M_\mathrm{vir}$") plt.savefig("/scratch/shuiyao/figures/tmp.pdf") plt.show()