예제 #1
0
def plot_resolution_cddf(snap=3, maxfac=1.):
    """Plot the effect of changing resolution on the CDDF."""
    base_large = myname.get_name(7, box=25)
    base_small = myname.get_name(7, box=7.5)
    ahalo_large = CIVPlottingSpectra(snap, base_large, None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,load_halo=True)
    ahalo_small = CIVPlottingSpectra(snap, base_small, None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,load_halo=True)
    maxmass = np.max(ahalo_small.sub_mass)/maxfac
    print("Max mass=",maxmass/1e10," was ",np.max(ahalo_large.sub_mass)/1e10)
    print("Small box has ",np.size(np.where(ahalo_small.sub_mass > maxmass))," larger halos")
    print("Larger box has ",np.size(np.where(ahalo_large.sub_mass > maxmass))," larger halos")
    ahalo_large.get_col_density("C",4)
    ahalo_small.get_col_density("C",4)
    (halos_large,_) = ahalo_large.find_nearest_halo("C",4, thresh=50)
    (halos_small,_) = ahalo_small.find_nearest_halo("C",4, thresh=50)
    ind_large = np.where((ahalo_large.sub_mass[halos_large] < maxmass)*(halos_large > 0))
    ind_small = np.where((ahalo_small.sub_mass[halos_small] < maxmass)*(halos_small > 0))
    print("Now ",np.size(ind_large),np.size(ind_small)," spectra")
    #Editing the private data like this is perilous
    ahalo_large.colden[("C",4)] = ahalo_large.colden[("C",4)][ind_large]
    ahalo_small.colden[("C",4)] = ahalo_small.colden[("C",4)][ind_small]
    (NHI_large, cddf_large) = ahalo_large.column_density_function("C", 4, minN=11.5,maxN=16.5, line=False, close=50.)
    plt.loglog(NHI_large,cddf_large,color="blue", label="25 Mpc Box", ls="-")
    (NHI_small, cddf_small) = ahalo_small.column_density_function("C", 4, minN=11.5,maxN=16.5, line=False, close=50.)
    plt.loglog(NHI_small,cddf_small,color="red", label="7.5 Mpc Box", ls="--")
    ax=plt.gca()
    ax.set_xlabel(r"$N_\mathrm{CIV} (\mathrm{cm}^{-2})$")
    ax.set_ylabel(r"$f(N) (\mathrm{cm}^2)$")
    plt.xlim(10**12, 10**15)
    plt.legend(loc=0)
    ax=plt.gca()
    ax.set_xlabel(r"$N_\mathrm{CIV} (\mathrm{cm}^{-2})$")
    ax.set_ylabel(r"$f(N) (\mathrm{cm}^2)$")
예제 #2
0
def plot_rel_res(sim):
    """Load and make a plot of the difference between two simulations"""
    basel = myname.get_name(sim)
    bases = myname.get_name(sim, box=10)
    plt.figure(1)
    for snap in (1, 3, 5):
        base = dp.PrettyBox(basel, snap, nslice=10)
        cddf_base = base.column_density_function()
        ahalo2 = dp.PrettyBox(bases, snap, nslice=10)
        cddf = ahalo2.column_density_function()
        plt.semilogx(cddf_base[0], np.log10(cddf[1]/cddf_base[1]), color=colors[snap], ls=lss[snap])
        if snap == 3:
            plt.figure(3)
            base.plot_column_density(color=colors[sim], ls=lss[sim], moment=True)
            ahalo2.plot_column_density(color="grey", ls=lss[sim], moment=True)
            dla_data.column_density_data(moment=True)
            save_figure(path.join(outdir,"cosmo_res_cddf_z3_abs"))
            plt.clf()
            base.plot_halo_hist(Mmin=1e7,color=colors[sim])
            ahalo2.plot_halo_hist(Mmin=1e7,color="grey")
            plt.ylim(0,0.1)
            save_figure(path.join(outdir,"cosmo_res_halohist"))
            plt.clf()
            plt.figure(1)
    savefile = "boxhi_grid_noH2.hdf5"
    base = dp.PrettyBox(basel, 3, nslice=10,savefile=savefile)
    cddf_base = base.column_density_function()
    savefile = "boxhi_grid_noH2.hdf5"
    ahalo2 = dp.PrettyBox(bases, 3, nslice=10,savefile=savefile)
    cddf = ahalo2.column_density_function()
    plt.semilogx(cddf_base[0], np.log10(cddf[1]/cddf_base[1]), color=colors[0], ls=lss[0])
    plt.ylim(-0.5,0.5)
    save_figure(path.join(outdir,"cosmo_res_cddf_z"+str(sim)))
    plt.clf()
예제 #3
0
def do_halomass_plots(fosc):
    """Plot halo mass, distance to the halo and the relationship between eq. width and column density"""
    ahalos = {
                    4:CIVPlottingSpectra(5, myname.get_name(4, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[4]+" 25"),
                   9:CIVPlottingSpectra(5, myname.get_name(9, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[9]+" 25"),
                    7:CIVPlottingSpectra(5, myname.get_name(7, box=25), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels[7]+" 25")}
    for (ll, ahalo) in ahalos.items():
        ahalo.plot_eqw_mass("C",4,1548,color=colors[ll])
    plt.legend(loc="upper left")
    save_figure(path.join(outdir,"civ_eqwvsmass"))
    plt.clf()
    for (ll, ahalo) in ahalos.items():
        ahalo.plot_eqw_dist("C",4,1548,color=colors[ll])
    plt.legend(loc="upper left")
    save_figure(path.join(outdir,"civ_eqwvsdist"))
    plt.clf()
    ahalos['I']=CIVPlottingSpectra(68, path.expanduser("~/data/Illustris"), None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,label=labels['I']+" 75")
    ccc = {1e12: "yellow", 1e15:"red"}
    for tag in ('I', 4, 7):
        for nmin in (1e12, 1e15):
            nminstr = str(np.round(np.log10(nmin),1))
            #for (ll, ahalo) in ahalos.iteritems():
            ahalos[tag].plot_mass_hist(elem="C",ion=4,color=ccc[nmin], ls=lss[tag],nmin=nmin, label=ahalos[tag].label+" "+nminstr)
    plt.legend(loc="upper left",ncol=1)
    save_figure(path.join(outdir,"civ_halos_hist"))
    plt.clf()
    ahalos['I'].plot_eq_width_vs_col_den("C",4,1548)
    eqw = np.linspace(-3, 0.5,50)
    plt.semilogy(eqw, linear_cog_col(10**eqw, 1548, fosc), '-',color="black")
    plt.ylim(1e12,1e16)
    plt.xlim(-2.5,0.5)
    save_figure(path.join(outdir,"civ_eqwvscolden"))
    plt.clf()
def plot_agn_rel_cddf(snap):
    """Load and make a plot of the difference between both simulations with and without AGN"""
    basen = myname.get_name(0)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    basen = myname.get_name(4)
    other = dp.PrettyBox(basen, snap, nslice=10)
    cddf = other.column_density_function()
    plt.semilogx(cddf_base[0],
                 cddf[1] / cddf_base[1],
                 color=colors[0],
                 ls=lss[0])
    basen = myname.get_name(1)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    basen = myname.get_name(2)
    other = dp.PrettyBox(basen, snap, nslice=10)
    cddf = other.column_density_function()
    plt.semilogx(cddf_base[0],
                 cddf[1] / cddf_base[1],
                 color=colors[1],
                 ls=lss[1])
    plt.ylim(0.8, 1.5)
    plt.xlim(1e17, 1e22)
    save_figure(path.join(outdir, "cosmo_rel_agn_cddf_z" + str(snap)))
    plt.clf()
def plot_halos(sim, hh):
    """Plot the halo closest in mass and position in the given sim to the halo of the given number in sim 7."""
    ahalo = dp.PrettyHalo(myname.get_name(sim), 3, 20000)
    ahalo7 = dp.PrettyHalo(myname.get_name(7), 3, 20000)
    (mass, cofm, radii) = _load_halo(ahalo, 30)
    (mass7, cofm7, _) = _load_halo(ahalo7, 30)
    dist = np.sum((cofm7[hh] - cofm)**2, axis=1)
    nn = np.where(dist == np.min(dist))
    rhh = hh
    hh = np.ravel(nn)[0]
    print "Requested: ", rhh, "Got: ", hh, " dist:", np.sqrt(
        dist[nn]), " r-mass:", mass[hh] / mass7[rhh], "ormass: ", mass7[rhh]
    plt.title(r"Central Halo: $" +
              dp.pr_num(ahalo.sub_mass[hh] / 0.72 / 1e11) +
              r"\times 10^{11} M_\odot$")
    ahalo.plot_pretty_halo(hh)
    #Backwards because someone is a fortran programmer
    circle = plt.Circle((0, 0), radii[hh], color="black", fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
    #     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh])
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir, "pretty_" + str(sim) + "_halo_" + str(rhh)))
    plt.clf()
    ahalo.plot_pretty_cut_halo(hh)
    circle = plt.Circle((0, 0), radii[hh], color="black", fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
    #     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh]/)
    plt.title(labels[sim] + " at z=3")
    dp.tight_layout_wrapper()
    save_figure(
        path.join(outdir, "pretty_cut_" + str(sim) + "_halo_" + str(rhh)))
    plt.clf()
    del ahalo
def multi_halohist(snap):
    """Plot selected simulations against each other in sigma_DLA"""
    small = myname.get_name(5, True, box=10)
    big = myname.get_name(5, True, box=25)
    ahalo = dp.PrettyBox(small, snap, nslice=10, label=labels[5])
    bighalo = dp.PrettyBox(big, snap, nslice=10, label=labels[5])
    bighalo.plot_sigma_DLA()
    ahalo.plot_sigma_DLA(color="blue", color2="blue")
    plt.ylim(1, 1e5)
    plt.xlim(5e7, 1e12)
    save_figure(path.join(outdir, "halos/cosmo5_10_sigmaDLA_z" + str(snap)))
    plt.clf()
    ahalo.plot_halo_hist(color=colors[0], ls=lss[0], plot_error=True)
    bighalo.plot_halo_hist(color=colors[5], ls=lss[5], plot_error=True)
    plt.ylim(0, 1)
    plt.xlim(1e8, 3e12)
    save_figure(path.join(outdir, "halos/cosmo_10_halohist_z" + str(snap)))
    plt.clf()
    for pair in ((1, 2), (0, 5), (0, 7)):
        small = myname.get_name(pair[0])
        big = myname.get_name(pair[1])
        ahalo = dp.PrettyBox(small, snap, nslice=10, label=labels[5])
        bighalo = dp.PrettyBox(big, snap, nslice=10, label=labels[5])
        bighalo.plot_sigma_DLA()
        ahalo.plot_sigma_DLA(color="blue", color2="blue")
        plt.ylim(1, 1e5)
        plt.xlim(5e7, 1e12)
        save_figure(
            path.join(
                outdir, "halos/cosmo" + str(pair[0]) + str(pair[1]) +
                "_sigmaDLA_z" + str(snap)))
        plt.clf()
예제 #7
0
def plot_halos(sim,hh):
    """Plot the halo closest in mass and position in the given sim to the halo of the given number in sim 7."""
    ahalo = dp.PrettyHalo(myname.get_name(sim),3,20000)
    ahalo7 = dp.PrettyHalo(myname.get_name(7),3,20000)
    (mass, cofm, radii) = _load_halo(ahalo, 30)
    (mass7, cofm7, _) = _load_halo(ahalo7, 30)
    dist = np.sum((cofm7[hh] - cofm)**2, axis=1)
    nn = np.where( dist == np.min(dist))
    rhh = hh
    hh = np.ravel(nn)[0]
    print "Requested: ",rhh,"Got: ",hh," dist:",np.sqrt(dist[nn])," r-mass:",mass[hh]/mass7[rhh], "ormass: ",mass7[rhh]
    plt.title(r"Central Halo: $"+dp.pr_num(ahalo.sub_mass[hh]/0.72/1e11)+r"\times 10^{11} M_\odot$")
    ahalo.plot_pretty_halo(hh)
    #Backwards because someone is a fortran programmer
    circle=plt.Circle((0,0),radii[hh],color="black",fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
#     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh])
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir,"pretty_"+str(sim)+"_halo_"+str(rhh)))
    plt.clf()
    ahalo.plot_pretty_cut_halo(hh)
    circle=plt.Circle((0,0),radii[hh],color="black",fill=False)
    ax = plt.gca()
    ax.add_artist(circle)
#     plot_rvir(ahalo.sub_cofm[hh], cofm, radii,ahalo.sub_radii[hh]/)
    plt.title(labels[sim]+" at z=3")
    dp.tight_layout_wrapper()
    save_figure(path.join(outdir,"pretty_cut_"+str(sim)+"_halo_"+str(rhh)))
    plt.clf()
    del ahalo
예제 #8
0
def multi_halohist(snap):
    """Plot selected simulations against each other in sigma_DLA"""
    small = myname.get_name(5, True,box=10)
    big = myname.get_name(5, True,box=25)
    ahalo = dp.PrettyBox(small, snap, nslice=10, label=labels[5])
    bighalo = dp.PrettyBox(big, snap, nslice=10, label=labels[5])
    bighalo.plot_sigma_DLA()
    ahalo.plot_sigma_DLA(color="blue", color2="blue")
    plt.ylim(1,1e5)
    plt.xlim(5e7,1e12)
    save_figure(path.join(outdir, "halos/cosmo5_10_sigmaDLA_z"+str(snap)))
    plt.clf()
    ahalo.plot_halo_hist(color=colors[0], ls=lss[0],plot_error=True)
    bighalo.plot_halo_hist(color=colors[5], ls=lss[5],plot_error=True)
    plt.ylim(0,1)
    plt.xlim(1e8,3e12)
    save_figure(path.join(outdir, "halos/cosmo_10_halohist_z"+str(snap)))
    plt.clf()
    for pair in ((1,2), (0,5), (0,7)):
        small = myname.get_name(pair[0])
        big = myname.get_name(pair[1])
        ahalo = dp.PrettyBox(small, snap, nslice=10, label=labels[5])
        bighalo = dp.PrettyBox(big, snap, nslice=10, label=labels[5])
        bighalo.plot_sigma_DLA()
        ahalo.plot_sigma_DLA(color="blue", color2="blue")
        plt.ylim(1,1e5)
        plt.xlim(5e7,1e12)
        save_figure(path.join(outdir, "halos/cosmo"+str(pair[0])+str(pair[1])+"_sigmaDLA_z"+str(snap)))
        plt.clf()
예제 #9
0
def test_lowres():
    """Plot the velocity widths with and with top hat vs SPH"""
    halo = myname.get_name(0)
    halolow = myname.get_name(0, ff=False)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(60, halolow, None, None, savefile="rand_spectra_DLA.hdf5")
    plot_check(hspec,hspec2,"lowres")
예제 #10
0
def test_min_wind():
    """Plot the velocity widths for minimum wind velocity"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(5)
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="SLIKE")
    plot_check(hspec, hspec2, "minwind", zz)
예제 #11
0
def test_metal():
    """Plot the velocity widths for metal enrichment"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(8)
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="ENRICH")
    plot_check(hspec, hspec2, "enrich", zz)
예제 #12
0
def test_metal():
    """Plot the velocity widths for metal enrichment"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(8)
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="ENRICH")
    plot_check(hspec,hspec2,"enrich", zz)
예제 #13
0
def test_min_wind():
    """Plot the velocity widths for minimum wind velocity"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(5)
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="SLIKE")
    plot_check(hspec,hspec2,"minwind", zz)
예제 #14
0
def test_box_resolution():
    """Plot the velocity widths for different size boxes"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(5, box=10)
    #     for zz in (1,3,5):
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="SMALL")
    plot_check(hspec, hspec2, "box", zz)
예제 #15
0
def test_box_resolution():
    """Plot the velocity widths for different size boxes"""
    halo = myname.get_name(7)
    halo10 = myname.get_name(5,box=10)
#     for zz in (1,3,5):
    zz = 3
    hspec = ps.VWPlotSpectra(zz, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(zz, halo10, label="SMALL")
    plot_check(hspec,hspec2,"box", zz)
예제 #16
0
def test_gfm_shield():
    """Plot the velocity widths for dynamical self-shielding vs post-processed self-shielding."""
    halo = myname.get_name(7)
    halo2 = myname.get_name('B')
    hspec = ps.VWPlotSpectra(3, halo, label="2xUV")
    hspec2 = ps.VWPlotSpectra(3, halo2, label="NOSHIELD")
    plot_check(hspec, hspec2, "gfm_shield")
    hspec = ps.VWPlotSpectra(5, halo, label="2xUV")
    hspec2 = ps.VWPlotSpectra(5, halo2, label="NOSHIELD")
    plot_check(hspec, hspec2, "gfm_shield", snap=5)
예제 #17
0
def test_gfm_shield():
    """Plot the velocity widths for dynamical self-shielding vs post-processed self-shielding."""
    halo = myname.get_name(7)
    halo2 = myname.get_name('B')
    hspec = ps.VWPlotSpectra(3, halo, label="2xUV")
    hspec2 = ps.VWPlotSpectra(3, halo2, label="NOSHIELD")
    plot_check(hspec,hspec2,"gfm_shield")
    hspec = ps.VWPlotSpectra(5, halo, label="2xUV")
    hspec2 = ps.VWPlotSpectra(5, halo2, label="NOSHIELD")
    plot_check(hspec,hspec2,"gfm_shield", snap=5)
예제 #18
0
def test_lowres():
    """Plot the velocity widths with and with top hat vs SPH"""
    halo = myname.get_name(0)
    halolow = myname.get_name(0, ff=False)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(60,
                              halolow,
                              None,
                              None,
                              savefile="rand_spectra_DLA.hdf5")
    plot_check(hspec, hspec2, "lowres")
예제 #19
0
def plot_vel_width_SiII(sim, snap):
    """
       Plot the change in velocity widths between the full calculation and
       setting n(Si+)/n(Si) = n(HI)/n(H)
    """
    #Load from a save file only
    halo = myname.get_name(5, box=10)
    hspec_tesc = ps.VWPlotSpectra(snap, halo, savefile="halo_spectra_2.hdf5") #,cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec_tesc.plot_vel_width("Si", 2, color="green", ls="-.")
    halo = myname.get_name(sim)
    hspec = ps.VWPlotSpectra(snap, halo)
    hspecSi = ps.VWPlotSpectra(snap, halo,savefile="SiHI_spectra.hdf5")
    plot_check(hspec, hspecSi,"SiHI")
예제 #20
0
def plot_vel_width_SiII(sim, snap):
    """
       Plot the change in velocity widths between the full calculation and
       setting n(Si+)/n(Si) = n(HI)/n(H)
    """
    #Load from a save file only
    halo = myname.get_name(5, box=10)
    hspec_tesc = ps.VWPlotSpectra(
        snap, halo, savefile="halo_spectra_2.hdf5"
    )  #,cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec_tesc.plot_vel_width("Si", 2, color="green", ls="-.")
    halo = myname.get_name(sim)
    hspec = ps.VWPlotSpectra(snap, halo)
    hspecSi = ps.VWPlotSpectra(snap, halo, savefile="SiHI_spectra.hdf5")
    plot_check(hspec, hspecSi, "SiHI")
예제 #21
0
def do_statistics(sim, snap):
    """Compute statistics"""
    #Get Observational data
    (_, met, vel) = vel_data.load_data(zrange[snap])
    vel = np.log10(vel)
    #Get Simulated data
    halo = myname.get_name(sim, True)
    hspec = ps.VWPlotSpectra(snap, halo)
    svel = hspec.vel_width("Si", 2)
    smet = hspec.get_metallicity()
    #Ignore objects too faint to be seen
    ind2 = np.where(smet > 1e-4)
    smet = np.log10(smet[ind2])
    svel = np.log10(svel[ind2])
    #Fit to both datasets
    (obs_intercept, obs_slope, obs_var) = ls.leastsq(vel,met)
    (s_intercept, s_slope, s_var) = ls.leastsq(svel,smet)
    print("obs fit: ",obs_intercept, obs_slope, np.sqrt(obs_var))
    print("sim fit: ",s_intercept, s_slope, np.sqrt(s_var))
    #Find correlations
    print("obs pearson r: ",ls.pearson(vel, met,obs_intercept, obs_slope))
    print("sim pearson r: ",ls.pearson(svel, smet,s_intercept, s_slope))
    print("obs kstest: ",ls.kstest(vel, met,obs_intercept, obs_slope))
    print("sim kstest: ",ls.kstest(svel, smet,s_intercept, s_slope))
    #Now test whether they come from the same population
    kss = hspec.kstest(10**met, 10**vel)
    print("KS test between simulated and observed samples: ",kss)
    #Do 200 trials and see how many times the KS test is worse
    ntrials = 50
    count = 0
    for _ in range(ntrials):
        rand = np.random.randint(0,np.size(svel), np.size(vel))
        if kss <= hspec.kstest(10**smet[rand], 10**svel[rand]):
            count+=1
    print("Prob KS test between simulated samples was larger: ",count*1./ntrials)
예제 #22
0
def test_tophat():
    """Plot the velocity widths with and with top hat vs SPH"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3, halo, None, None, savefile="grid_spectra_DLA_tophat.hdf5")
    plot_check(hspec,hspec2,"tophat")
예제 #23
0
def plot_H2_effect(sim, snap):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, True)
    savefile = "boxhi_grid_noH2.hdf5"
    ahalo = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile, label=r"No $H_2$")
    ahalo.plot_column_density(color="blue", ls="--", moment=True)
    savefile = "boxhi_grid_H2.hdf5"
    ahalo2 = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile, label=r"$H_2$")
    ahalo2.plot_column_density(color="red",moment=True)
#     savefile = path.join(halo,"snapdir_"+str(snap).rjust(3,'0'),"boxhi_grid_H2-old.hdf5")
#     ahalo2 = dp.PrettyBox(halo, snap, nslice=10, savefile=savefile)
#     ahalo2.plot_column_density(color="green",moment=True)
    dla_data.column_density_data(moment=True)
#     dla_data.noterdaeme_12_data(path.join(path.dirname(__file__),"../dla_data"), moment=True)
    plt.legend(loc=3)
    plt.xlim(1e20,2e22)
    plt.ylim(1e-5,0.1)
#     plt.title("CDDF for "+labels[sim]+" at z="+str(redshifts[snap]))
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_H2_"+str(snap)))
    plt.clf()
    cddf_base = ahalo.column_density_function()
    cddf = ahalo2.column_density_function()
    plt.semilogx(cddf_base[0], np.log10(cddf[1]/cddf_base[1]), color=colors[sim], ls=lss[sim])
    plt.ylim(-0.5,0.5)
    tight_layout_wrapper()
    ax = plt.gca()
    ylab = ax.set_ylabel(r"$N_\mathrm{HI} f(N)$")
    save_figure(path.join(outdir, "cosmo_rel"+str(sim)+"_H2_"+str(snap)))
    plt.clf()
예제 #24
0
def test_big_box():
    """Plot the velocity widths for different size boxes"""
    halo = myname.get_name(0)
    halobig = path.expanduser("~/data/Illustris")
    hspec = ps.VWPlotSpectra(3, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(59, halobig, label="ILLUS")
    plot_check(hspec,hspec2,"bigbox")
예제 #25
0
def test_spec_resolution():
    """Plot the velocity widths for different spectral resolutions"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA_res.hdf5")
    plot_check(hspec,hspec2,"specres")
예제 #26
0
def test_pecvel():
    """Plot the velocity widths with and without peculiar velocities"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3, halo, None, None, savefile="grid_spectra_DLA_pecvel.hdf5")
    plot_check(hspec,hspec2,"pecvel")
예제 #27
0
def plot_halo_stellar_mass():
    """Plot a histogram of nearby halos"""
    for sim in (1, 7, 9):  #xrange(8):
        halo = myname.get_name(sim, True)
        hms = []
        sms = []
        sfrs = []
        zz = []
        for snap in (1, 3, 5):
            ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
            (hm, sm, sfr) = ahalo.get_avg_stellar_mass()
            hms.append(hm)
            sms.append(sm)
            sfrs.append(sfr)
            zz.append(redshifts[snap])
        plt.figure(1)
        plt.semilogy(zz, hms, color=colors[sim], ls="-", label=labels[sim])
        plt.semilogy(zz, sms, color=colors[sim], ls="--", label=labels[sim])
        plt.figure(2)
        plt.semilogy(zz, sfrs, color=colors[sim], ls="--", label=labels[sim])
    plt.figure(1)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_smhm_z" + str(snap)))
    plt.figure(2)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_sfr_z" + str(snap)))
    plt.clf()
예제 #28
0
def plot_halo_stellar_mass():
    """Plot a histogram of nearby halos"""
    for sim in (1,7,9):   #xrange(8):
        halo = myname.get_name(sim, True)
        hms = []
        sms = []
        sfrs = []
        zz = []
        for snap in (1,3,5):
            ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
            (hm, sm, sfr) = ahalo.get_avg_stellar_mass()
            hms.append(hm)
            sms.append(sm)
            sfrs.append(sfr)
            zz.append(redshifts[snap])
        plt.figure(1)
        plt.semilogy(zz, hms, color=colors[sim], ls="-", label=labels[sim])
        plt.semilogy(zz, sms, color=colors[sim], ls="--", label=labels[sim])
        plt.figure(2)
        plt.semilogy(zz, sfrs, color=colors[sim], ls="--", label=labels[sim])
    plt.figure(1)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_smhm_z"+str(snap)))
    plt.figure(2)
    plt.legend(loc=1)
    save_figure(path.join(outdir, "halos/avg_sfr_z"+str(snap)))
    plt.clf()
예제 #29
0
def plot_dndx_breakdown(sim):
    """Make the rho_HI plot with labels etc"""
    halo = myname.get_name(sim, True, 25)
    snaps = {4:1, 3.5:2, 3:3, 2.5:4, 2:5}
    fractions=[]
    zzz = []
    omegadla = []
    for zzzz in (4, 3.5, 3, 2.5, 2):
        ahalo = dp.PrettyBox(halo, snaps[zzzz], nslice=10)
        (massbins, fracs) = ahalo.get_omega_hi_mass_breakdown(False)
        fractions.append(fracs)
        zzz.append(zzzz)
        omegadla.append(ahalo.line_density())
    fractions = np.array(fractions)
    for i in xrange(np.size(fractions[0,:])-2):
        plt.plot(zzz,fractions[:,i+1], color=colors[i], ls=lss[i], label=dp.pr_num(np.log10(massbins[i]))+" - "+dp.pr_num(np.log10(massbins[i+1])))
    plt.plot(zzz,fractions[:,-1], color=colors[6], ls=lss[6], label="Field")
    plt.plot(zzz,omegadla, color=colors[sim], ls=lss[sim], label="Total")
    plt.xlabel("z")
    plt.ylabel(r"$dN/dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2,4)
    plt.ylim(0,0.15)
    plt.legend(loc=1, ncol=2)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_dndx_break"+str(sim)))
    plt.clf()
예제 #30
0
def test_big_box():
    """Plot the velocity widths for different size boxes"""
    halo = myname.get_name(0)
    halobig = path.expanduser("~/data/Illustris")
    hspec = ps.VWPlotSpectra(3, halo, label="DEF")
    hspec2 = ps.VWPlotSpectra(59, halobig, label="ILLUS")
    plot_check(hspec, hspec2, "bigbox")
def plot_dndx_breakdown(sim):
    """Make the rho_HI plot with labels etc"""
    halo = myname.get_name(sim, True, 25)
    snaps = {4: 1, 3.5: 2, 3: 3, 2.5: 4, 2: 5}
    fractions = []
    zzz = []
    omegadla = []
    for zzzz in (4, 3.5, 3, 2.5, 2):
        ahalo = dp.PrettyBox(halo, snaps[zzzz], nslice=10)
        (massbins, fracs) = ahalo.get_omega_hi_mass_breakdown(False)
        fractions.append(fracs)
        zzz.append(zzzz)
        omegadla.append(ahalo.line_density())
    fractions = np.array(fractions)
    for i in xrange(np.size(fractions[0, :]) - 2):
        plt.plot(zzz,
                 fractions[:, i + 1],
                 color=colors[i],
                 ls=lss[i],
                 label=dp.pr_num(np.log10(massbins[i])) + " - " +
                 dp.pr_num(np.log10(massbins[i + 1])))
    plt.plot(zzz, fractions[:, -1], color=colors[6], ls=lss[6], label="Field")
    plt.plot(zzz, omegadla, color=colors[sim], ls=lss[sim], label="Total")
    plt.xlabel("z")
    plt.ylabel(r"$dN/dX$")
    dla_data.dndx_not()
    dla_data.dndx_pro()
    plt.xlim(2, 4)
    plt.ylim(0, 0.15)
    plt.legend(loc=1, ncol=2)
    tight_layout_wrapper()
    save_figure(path.join(outdir, "cosmo_dndx_break" + str(sim)))
    plt.clf()
예제 #32
0
def test_spec_resolution():
    """Plot the velocity widths for different spectral resolutions"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA_res.hdf5")
    plot_check(hspec, hspec2, "specres")
예제 #33
0
def test_vel_abswidth():
    """Plot the velocity widths for different minimum absorber widths"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo)
    hspec2 = ps.VWPlotSpectra(3, halo)
    hspec2.minwidth = 250.
    plot_check(hspec,hspec2,"abswidth")
예제 #34
0
def plot_covering_frac(sim, snap, ff=True):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10)
    ahalo.plot_sigma_DLA()
    del ahalo
    save_figure(path.join(outdir, "cosmo"+str(sim)+"_covering_z"+str(snap)))
    plt.clf()
예제 #35
0
def test_shield():
    """Plot velocity width for spectra using self-shielding like in Tescari 2009"""
    halo = myname.get_name(7)
    hspec = ps.VWPlotSpectra(3, halo)
    hspec2 = ps.VWPlotSpectra(3,
                              halo,
                              savefile="grid_spectra_DLA_noshield.hdf5")
    plot_check(hspec, hspec2, "no_shield")
예제 #36
0
def test_vel_abswidth():
    """Plot the velocity widths for different minimum absorber widths"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo)
    hspec2 = ps.VWPlotSpectra(3, halo)
    hspec2.minwidth = 250.
    plot_check(hspec, hspec2, "abswidth")
예제 #37
0
def test_tescari_halos(sim, snap):
    """Plot velocity width for spectra through the center of halos, like in Tescari 2009"""
    halo = myname.get_name(sim, box=10)
    hspec = ps.VWPlotSpectra(snap, halo, savefile="halo_spectra_2.hdf5",cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec.plot_vel_width("Si", 2, color="red")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir,"cosmo_tescari_halos"))
    plt.clf()
예제 #38
0
def plot_cutoff():
    """Plot effect with a cutoff self-shielding"""
    halo = myname.get_name(0, True)
    savefile = "boxhi_grid_cutoff_H2.hdf5"
    ahalo = dp.PrettyBox(halo, 3, nslice=10, savefile=savefile)
    cutoff0 = ahalo.column_density_function()
    ahalo = dp.PrettyBox(halo, 3, nslice=10)
    normal0 = ahalo.column_density_function()
    halo = myname.get_name(1, True)
    savefile = "boxhi_grid_cutoff_H2.hdf5"
    ahalo = dp.PrettyBox(halo, 3, nslice=10, savefile=savefile)
    cutoff1 = ahalo.column_density_function()
    ahalo = dp.PrettyBox(halo, 3, nslice=10)
    normal1 = ahalo.column_density_function()
    plt.semilogx(cutoff0[0], np.log10(cutoff0[1]/cutoff1[1]), color="red", ls="-")
    plt.semilogx(normal0[0], np.log10(normal0[1]/normal1[1]), color="blue", ls="--")
    save_figure(path.join(outdir, "cosmo_rel_cutoff"))
    plt.clf()
예제 #39
0
def test_atten():
    """Plot the effect of the self-shielding correction"""
    halo = myname.get_name(7)
    hspec = ps.VWPlotSpectra(3, halo, label="ATTEN")
    hspec2 = ps.VWPlotSpectra(3,
                              halo,
                              savefile="grid_spectra_DLA_no_atten.hdf5",
                              label="NOATTEN")
    plot_check(hspec, hspec2, "no_atten")
def plot_metal_halo(sim, snap, ff=True, lls=False):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
    if lls:
        ahalo.plot_lls_metallicity(color=colors[sim], ls=lss[sim])
    else:
        ahalo.plot_dla_metallicity(color=colors[sim], ls=lss[sim])
    del ahalo
예제 #41
0
def plot_UVB_effect():
    """Load a simulation and plot its cddf"""
    for i in (0,5,7):
        halo = myname.get_name(i, True)
        ahalo = dp.PrettyBox(halo, 3, nslice=10)
        ahalo.plot_column_density(color=colors[i], ls=lss[i],moment=True)
    dla_data.column_density_data(moment=True)
    save_figure(path.join(outdir, "cosmo_UVB_3"))
    plt.clf()
def plot_covering_frac(sim, snap, ff=True):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10)
    ahalo.plot_sigma_DLA()
    del ahalo
    save_figure(
        path.join(outdir, "cosmo" + str(sim) + "_covering_z" + str(snap)))
    plt.clf()
def plot_UVB_effect():
    """Load a simulation and plot its cddf"""
    for i in (0, 5, 7):
        halo = myname.get_name(i, True)
        ahalo = dp.PrettyBox(halo, 3, nslice=10)
        ahalo.plot_column_density(color=colors[i], ls=lss[i], moment=True)
    dla_data.column_density_data(moment=True)
    save_figure(path.join(outdir, "cosmo_UVB_3"))
    plt.clf()
예제 #44
0
def plot_metal_halo(sim, snap, ff=True, lls=False):
    """Load a simulation and plot its cddf"""
    halo = myname.get_name(sim, ff)
    ahalo = dp.PrettyBox(halo, snap, nslice=10, label=labels[sim])
    if lls:
        ahalo.plot_lls_metallicity(color=colors[sim], ls=lss[sim])
    else:
        ahalo.plot_dla_metallicity(color=colors[sim], ls=lss[sim])
    del ahalo
예제 #45
0
def plot_vel_width_SiII_keating(sim, snap):
    """
       Plot the change in velocity widths between the full calculation and
       setting n(Si+)/n(Si) = n(HI)/n(H)
    """
    halo = myname.get_name(sim)
    #Load from a save file only
    hspec = ps.VWPlotSpectra(snap, halo)
    hspecSi2 = ps.VWPlotSpectra(snap, halo,savefile="si_colden_spectra.hdf5")
    plot_check(hspec, hspecSi2,"SiHI_keating")
예제 #46
0
def plot_rel_cddf(snap):
    """Load and make a plot of the difference between two simulations"""
    basen = myname.get_name(7)
    base = dp.PrettyBox(basen, snap, nslice=10)
    cddf_base = base.column_density_function()
    for xx in (0,4,2,1,3,9):
        halo2 = myname.get_name(xx)
        ahalo2 = dp.PrettyBox(halo2, snap, nslice=10)
        cddf = ahalo2.column_density_function()
        plt.semilogx(cddf_base[0], cddf[1]/cddf_base[1], color=colors[xx], ls=lss[xx], label=labels[xx])
    plt.legend(loc=3, ncol=2)
    plt.xlabel(r"$N_\mathrm{HI}$ (cm$^{-2}$)")
    plt.ylabel(r"$f(N)/f_\mathrm{"+labels[7]+"}(N)$")
    plt.title("CDDF relative to "+labels[7]+" at z="+str(redshifts[snap]))
    plt.ylim(-0.2,1.8)
    plt.xlim(1e17, 1e22)
    tight_layout_wrapper()
    save_figure(path.join(outdir,"cosmo_rel_cddf_z"+str(snap)))
    plt.clf()
예제 #47
0
def plot_vel_widths_cloudy():
    """Plot some velocity width data for different cloudy models"""
    #Load sims
    hspec0 = ps.VWPlotSpectra(3, myname.get_name(0, True))
    hspec1 = ps.VWPlotSpectra(3, myname.get_name(0,True), savefile="rand_spectra_DLA_fancy_atten.hdf5")
    #Make abs. plot
    hspec0.plot_vel_width("Si", 2, color="blue", ls="--")
    hspec1.plot_vel_width("Si", 2, color="red", ls="-")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir,"cosmo_feedback_cloudy_z3"))
    plt.clf()
    #Make rel plot
    (vbin, vels0) = hspec0.vel_width_hist("Si", 2)
    (vbin, vels2) = hspec1.vel_width_hist("Si", 2)
    mm = np.min((np.size(vels2),np.size(vels0)))
    plt.semilogx(vbin[:mm], vels0[:mm]/vels2[:mm], color="blue",ls="-")
    plt.xlim(1, 1000)
    save_figure(path.join(outdir,"cosmo_rel_vel_cloudy_z3"))
    plt.clf()
예제 #48
0
def get_hspec(sim, snap, snr=0., box = 25):
    """Get a spectra object, possibly from the cache"""
    halo = myname.get_name(sim, True, box=box)
    #Load from a save file only
    try:
        hspec = hspec_cache[(halo, snap)]
    except KeyError:
        hspec = ps.VWPlotSpectra(snap, halo, label=labels[sim], snr=snr)
        hspec_cache[(halo, snap)] = hspec
    return hspec
예제 #49
0
def plot_galactic_metallicity(sim, snap=5):
    """Plot histograms of the stellar metallicity."""
    base = myname.get_name(sim, box=25)
    subs=subfindhdf.SubFindHDF5(base, snap)
    stellar_metallicity = subs.get_grp("GroupStarMetallicity")
    solarz = 0.0134/0.7381
    bins = np.logspace(-8,0)
    (metallicity,sm) = np.histogram(stellar_metallicity, bins=bins, density=True)
    sm = (sm[1:]+sm[:-1])/2./solarz
    plt.loglog(sm, metallicity, color=colors[sim], ls=lss[sim], label=labels[sim])
예제 #50
0
def plot_vel_width_SiII_keating(sim, snap):
    """
       Plot the change in velocity widths between the full calculation and
       setting n(Si+)/n(Si) = n(HI)/n(H)
    """
    halo = myname.get_name(sim)
    #Load from a save file only
    hspec = ps.VWPlotSpectra(snap, halo)
    hspecSi2 = ps.VWPlotSpectra(snap, halo, savefile="si_colden_spectra.hdf5")
    plot_check(hspec, hspecSi2, "SiHI_keating")
예제 #51
0
def get_hspec(sim, snap, box=25):
    """Get a spectra object, possibly from the cache"""
    halo = myname.get_name(sim, True, box=box)
    #Load from a save file only
    try:
        hspec = hspec_cache[(halo, snap)]
    except KeyError:
        hspec = ps.VWPlotSpectra(snap, halo, label=labels[sim])
        hspec_cache[(halo, snap)] = hspec
    return hspec
def plot_rel_res(sim):
    """Load and make a plot of the difference between two simulations"""
    basel = myname.get_name(sim)
    bases = myname.get_name(sim, box=10)
    plt.figure(1)
    for snap in (1, 3, 5):
        base = dp.PrettyBox(basel, snap, nslice=10)
        cddf_base = base.column_density_function()
        ahalo2 = dp.PrettyBox(bases, snap, nslice=10)
        cddf = ahalo2.column_density_function()
        plt.semilogx(cddf_base[0],
                     np.log10(cddf[1] / cddf_base[1]),
                     color=colors[snap],
                     ls=lss[snap])
        if snap == 3:
            plt.figure(3)
            base.plot_column_density(color=colors[sim],
                                     ls=lss[sim],
                                     moment=True)
            ahalo2.plot_column_density(color="grey", ls=lss[sim], moment=True)
            dla_data.column_density_data(moment=True)
            save_figure(path.join(outdir, "cosmo_res_cddf_z3_abs"))
            plt.clf()
            base.plot_halo_hist(Mmin=1e7, color=colors[sim])
            ahalo2.plot_halo_hist(Mmin=1e7, color="grey")
            plt.ylim(0, 0.1)
            save_figure(path.join(outdir, "cosmo_res_halohist"))
            plt.clf()
            plt.figure(1)
    savefile = "boxhi_grid_noH2.hdf5"
    base = dp.PrettyBox(basel, 3, nslice=10, savefile=savefile)
    cddf_base = base.column_density_function()
    savefile = "boxhi_grid_noH2.hdf5"
    ahalo2 = dp.PrettyBox(bases, 3, nslice=10, savefile=savefile)
    cddf = ahalo2.column_density_function()
    plt.semilogx(cddf_base[0],
                 np.log10(cddf[1] / cddf_base[1]),
                 color=colors[0],
                 ls=lss[0])
    plt.ylim(-0.5, 0.5)
    save_figure(path.join(outdir, "cosmo_res_cddf_z" + str(sim)))
    plt.clf()
예제 #53
0
def plot_Omega_DLA(sim, color="red", ff=True):
    """Plot Omega_DLA over a range of redshifts"""
    halo = myname.get_name(sim, ff)
    om = {}
    for snap in (1,3,5):
        hspec = ps.PlottingSpectra(snap, halo)
        om[hspec.red] = hspec.omega_abs()
    plt.semilogy(list(om.keys()), list(om.values()), 'o-', color=color)
    plt.xlabel("z")
    plt.ylabel(r"$\Omega_{DLA}$")
    return om
예제 #54
0
def test_pecvel():
    """Plot the velocity widths with and without peculiar velocities"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3,
                              halo,
                              None,
                              None,
                              savefile="grid_spectra_DLA_pecvel.hdf5")
    plot_check(hspec, hspec2, "pecvel")
예제 #55
0
def test_tophat():
    """Plot the velocity widths with and with top hat vs SPH"""
    halo = myname.get_name(7)
    #Higher resolution spectrum
    hspec = ps.VWPlotSpectra(3, halo, savefile="grid_spectra_DLA.hdf5")
    hspec2 = ps.VWPlotSpectra(3,
                              halo,
                              None,
                              None,
                              savefile="grid_spectra_DLA_tophat.hdf5")
    plot_check(hspec, hspec2, "tophat")
예제 #56
0
def plot_vel_widths_cloudy():
    """Plot some velocity width data for different cloudy models"""
    #Load sims
    hspec0 = ps.VWPlotSpectra(3, myname.get_name(0, True))
    hspec1 = ps.VWPlotSpectra(3,
                              myname.get_name(0, True),
                              savefile="rand_spectra_DLA_fancy_atten.hdf5")
    #Make abs. plot
    hspec0.plot_vel_width("Si", 2, color="blue", ls="--")
    hspec1.plot_vel_width("Si", 2, color="red", ls="-")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir, "cosmo_feedback_cloudy_z3"))
    plt.clf()
    #Make rel plot
    (vbin, vels0) = hspec0.vel_width_hist("Si", 2)
    (vbin, vels2) = hspec1.vel_width_hist("Si", 2)
    mm = np.min((np.size(vels2), np.size(vels0)))
    plt.semilogx(vbin[:mm], vels0[:mm] / vels2[:mm], color="blue", ls="-")
    plt.xlim(1, 1000)
    save_figure(path.join(outdir, "cosmo_rel_vel_cloudy_z3"))
    plt.clf()
예제 #57
0
def test_tescari_halos(sim, snap):
    """Plot velocity width for spectra through the center of halos, like in Tescari 2009"""
    halo = myname.get_name(sim, box=10)
    hspec = ps.VWPlotSpectra(
        snap,
        halo,
        savefile="halo_spectra_2.hdf5",
        cdir=path.expanduser("~/codes/cloudy_tables/ion_out_no_atten/"))
    hspec.plot_vel_width("Si", 2, color="red")
    vel_data.plot_prochaska_2008_data()
    save_figure(path.join(outdir, "cosmo_tescari_halos"))
    plt.clf()
예제 #58
0
def setup_test(molec, sim):
    """Setup the test case with a simulation"""
    name = myname.get_name(sim)

    f = hdfsim.get_file(3, name, 0)

    redshift = f["Header"].attrs["Redshift"]
    hubble = f["Header"].attrs["HubbleParam"]
    bar = f["PartType0"]

    cold = cold_gas.RahmatiRT(redshift, hubble, molec=molec)

    return (cold, bar)
예제 #59
0
def plot_rho_HI(sim, color="red", ff=True):
    """Plot rho_HI across redshift"""
    halo = myname.get_name(sim, ff)
    zzz = {4:1, 3:3, 2:5}
    rho_HI = {}
    for zz in (4,3,2):
        try:
            hspec = ps.PlottingSpectra(zzz[zz], halo)
            rho_HI[zz]=hspec.omega_abs()
            del hspec
        except TypeError:
            pass
    plt.plot(list(rho_HI.keys()),list(rho_HI.values()), color=color)
예제 #60
0
def plot_dndx(sim, color="red", ff=True):
    """Plot dndx (cross-section) across redshift"""
    halo = myname.get_name(sim, ff)
    zzz = {4:1, 3:3, 2:5}
    dndx={}
    for zz in (4,3,2):
        try:
            hspec = ps.PlottingSpectra(zzz[zz], halo)
            dndx[zz]=hspec.line_density()
            del hspec
        except TypeError:
            pass
    plt.plot(list(dndx.keys()),list(dndx.values()), color=color)