Beispiel #1
0
def dust_massfn(files, z, snapnum, i):
    """
    Outputs the dust mass function for input files of a particular redshift, for a given volume
    """

    add = sims[i]
    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    Type = get_.get_var(files[i], 'Type', snap)
    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2
    #Mdust = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[:,0]
    SFR = get_.get_var(files[i], 'Sfr', snap)

    sSFR = SFR / Mstar

    ok = np.logical_and(Mdust > 0.0, Type == 0)
    #ok = np.logical_and(sSFR < get_.sSFR_cut(z), np.logical_and(Mdust > 0.0, Type == 0))
    out = outputs(Mstar[ok], Mdust[ok], sSFR[ok], Type[ok], z)
    dbins = np.arange(
        np.log10(min(out)) - 0.05,
        np.log10(max(out)) + 0.05, 0.2)
    #dbins = np.arange(7, 12, 0.2)
    bins, edges = np.histogram(np.log10(out), dbins)

    xx = (edges[1:] + edges[:-1]) / 2
    binsize = edges[1:] - edges[:-1]
    yy = bins / (vol[i] * binsize)

    return xx, yy
Beispiel #2
0
def dust_prod_rate_redshift(files, z, snap, i):

    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    Type = get_.get_var(files[i], 'Type', snap)
    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
    Mdust = Mdust1 + Mdust2
    SFR = get_.get_var(files[i], 'Sfr', snap)
    sSFR = SFR / Mstar
    dustrates = get_.get_var(files[i], 'DustColdGasRates', snap)
    Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)
    Mcg2 = get_.get_var(files[i], 'ColdGasClouds_elements', snap)
    Mcg = Mcg1 + Mcg2
    Z = (Mcg[:, 4] - Mdust[:, 4]) / (15.9994 * (Mcg[:, 0]))  #O/H ratio
    #Z = np.nansum(Mcg[:,2:], axis = 1)/np.nansum(Mcg, axis = 1)
    Mdust = np.nansum(Mdust, axis=1)
    Mcg = np.nansum(Mcg, axis=1)
    if inp == 0:
        ok = np.logical_and(Mdust > 0, Type == 0)
    else:
        ok = np.logical_and(sSFR > get_.sSFR_cut(z),
                            np.logical_and(Mcg > 1e6, Type == 0))

    dustrates = dustrates[ok]
    SFR = SFR[ok]
    Mstar = Mstar[ok]
    Z = Z[ok]

    return dustrates, Mstar, SFR, Z
def get_vals(files, z, snapnum, i, on):

    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    if on and i == 0:
        ok = np.where(Mstar >= 10**9.0)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.4, Mstar < 10**9.0)
    else:
        ok = np.where(Mstar >= 10**6.9)[0]

    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]
    Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
    Mcg = get_.get_var(files[i],
                       'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                           files[i], 'ColdGasClouds_elements', snap)[ok]
    Mmet = np.nansum(Mcg[:, 2:], axis=1)  #Total metal mass in cold gas

    Z = Mmet / np.nansum(Mcg, axis=1)
    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust = Mdust1 + Mdust2
    Mdust = np.nansum(Mdust, axis=1)  #Total dust mass

    Mratio = Mdust / (Mmet)  #Dust-to-total metal mass ratio. Dimensionless.

    ok = np.where(np.nansum(Mcg, axis=1) > 1e6)

    return Mstar[ok], Mratio[ok], Type[ok], Age[ok], Mcg[ok], Mmet[ok]
def get_vals(files, z, axs, snapnum, i, on):

    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    if on and i == 0:
        ok = np.where(Mstar >= 10**9.0)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.0, Mstar < 10**9.0)
    else:
        ok = np.array([True] * len(Mstar))

    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]
    Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
    Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2
    Mcg = np.nansum(Mcg, axis=1)  #Total cold gas mass

    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust = Mdust1 + Mdust2
    Mdust = np.nansum(Mdust, axis=1)  #Total dust mass

    Mratio = Mdust / Mcg  #Dust-to-total cold gas mass ratio. Dimensionless.

    ok = np.where(
        Mcg > 1e6
    )  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen

    return Mstar[ok], Mratio[ok], Type[ok], Age[ok]
def plot_Mstar_dep(files, z, axs, snaps, i, on):

    add = sims[i]
    snap = snaps[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / 0.673
    if on and i == 0:
        ok = np.where(Mstar >= 10**9.0)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.2, Mstar < 10**9.0)
    else:
        ok = np.array([True] * len(Mstar))

    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]

    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust = Mdust1 + Mdust2

    Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2

    SFR = get_.get_var(files[i], 'Sfr', snap)[ok]

    sSFR = SFR / Mstar
    ok = np.where(np.nansum(Mcg, axis=1) > 1e6)
    plot_figure(Mstar[ok], Mcg[ok], Mdust[ok], sSFR[ok], Type[ok], z, axs)

    axs.set_xlim((7.5, 11.6))
    axs.set_xticks([8, 9, 10, 11])

    return add
def get_DTM(z):

    files = '../Dust_output/MR/SA_output_*'
    snap = snapnumMR[np.where(redshift == str(z))[0][0]]

    Mstar = (get_.get_var(files, 'StellarMass', snap) * 1e10) / 0.673
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2
    ok = np.logical_and(Mstar > 10**9.0, Mdust > 0)

    Mstar = Mstar[ok]
    Mdust = Mdust[ok]
    Mcg1 = get_.get_var(files, 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files, 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2

    Mmet = np.nansum(Mcg[:, 2:], axis=1)

    snap = snapnumMRII[np.where(redshift == str(z))[0][0]]
    files = '../Dust_output/MRII/SA_output_*'
    tmp = (get_.get_var(files, 'StellarMass', snap) * 1e10) / 0.673
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    tmp1 = Mdust1 + Mdust2
    ok = np.logical_and(tmp > 10**7.0, np.logical_and(tmp < 10**9.0, tmp1 > 0))

    Mstar = np.append(Mstar, tmp[ok])
    Mdust = np.append(Mdust, tmp1[ok])
    Mcg1 = get_.get_var(files,
                        'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                            files, 'ColdGasClouds_elements', snap)[ok]

    Mmet = np.append(Mmet, np.nansum(Mcg1[:, 2:], axis=1))
    Mcg = np.append(Mcg, Mcg1, axis=0)

    DTM = Mdust / (Mmet)
    ok = np.where(Mcg > 1e6)[0]
    return DTM[ok]
def plot_Mstar_Mdust(fil, z, axs, snapnum, i, on, k, label):

    add = sims[i]
    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    print(fil[i])
    Mstar = (get_.get_var(fil[i], 'StellarMass', snap) * 1e10) / 0.673
    if on and i == 0:
        ok = np.where(Mstar >= 10**8.9)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.5, Mstar < 10**8.9)
    else:
        ok = np.array([True] * len(Mstar))

    Mstar = Mstar[ok]
    Type = get_.get_var(fil[i], 'Type', snap)[ok]
    Mdust1 = get_.get_var(fil[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(fil[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2
    SFR = get_.get_var(fil[i], 'Sfr', snap)[ok]
    sSFR = SFR / Mstar

    xx, yy, yy_up, yy_low = outputs(Mstar, Mdust, sSFR, Type, z)

    xx = np.log10(xx)
    yy = np.log10(yy)
    yy_up = np.log10(yy_up)
    yy_low = np.log10(yy_low)

    plot_figure(axs, z, xx, yy, yy_up, yy_low, k, label)

    xlim = [7.5, 11.7]
    ylim = [1.5, 10.5]
    xticks = [8, 9, 10, 11]

    axs.set_xlim(xlim)
    axs.set_ylim(ylim)

    axs.set_xticks(xticks)

    return add
Beispiel #8
0
def get_vals(files, z, axs, snapnum, i, on):

    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    if on and i == 0:
        ok = np.where(Mstar >= 10**9.0)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.0, Mstar < 10**9.0)
    else:
        ok = np.array([True] * len(Mstar))

    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]
    Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
    Mcg = get_.get_var(files[i],
                       'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                           files[i], 'ColdGasClouds_elements', snap)[ok]
    Mmet = np.nansum(Mcg[:, 2:], axis=1)
    Mcg = np.nansum(Mcg, axis=1)
    Z = Mmet / Mcg
    tacc = get_.get_var(files[i], 't_acc', snap)[ok]

    ok = np.where(
        Mcg > 1e6
    )  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen

    return Mstar[ok], tacc[ok], Type[ok], Age[ok], Z[ok]
Beispiel #9
0
def mu_Krumholz(files, z, snapnum, i):

    add = sims[i]
    snap = snapnum[i][np.where(redshift == str(z))[0][0]]

    Z_sun = 0.0134
    cgas = get_.get_var(files[i], 'ColdGas', snap)
    ok = np.logical_not(cgas == 0.)
    Z_cgas = np.sum(get_.get_var(files[i], 'MetalsColdGas', snap),
                    axis=1) / cgas

    Z_fraction = Z_cgas / Z_sun
    Z_fraction[~ok] = 0.
    Z_fraction[Z_fraction < 0.01] = 0.01

    chi = 3.1 * (1.0 + 3.1 * np.power(Z_fraction, 0.365)) / 4.1
    GasDiskRadius = get_.get_var(files[i], 'GasDiskRadius', snap)
    Sigma_gas = (1.0e10 *
                 (cgas / h)) / (np.pi *
                                ((((GasDiskRadius * 1.0e6) / h) / 3.0) *
                                 (((GasDiskRadius * 1.0e6) / h) / 3.0)))

    ok = np.where(Z_fraction < 1.)[0]
    c_f = np.ones(len(cgas))
    c_f[ok] = (Z_fraction[ok])**(-0.7)

    Sigma_comp = c_f * Sigma_gas

    tau_c = 0.066 * Sigma_comp * Z_fraction
    s = np.log(1.0 + 0.6 * chi + 0.01 * chi * chi) / (0.6 * tau_c)

    f_h2 = np.zeros(len(cgas))
    ok = np.where(s < 2.)
    f_h2[ok] = 1. - (0.75) * (s[ok]) / (1. + 0.25 * s[ok])

    return f_h2, cgas
Beispiel #10
0
def get_vals(files, z, axs, snapnum, i, on):

    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
    if on and i == 0:
        ok = np.where(Mstar >= 10**9.0)[0]
    elif on and i == 1:
        ok = np.logical_and(Mstar > 10**7.0, Mstar < 10**9.0)
    else:
        ok = np.array([True] * len(Mstar))

    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]
    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    #Mdust = np.nansum(get_.get_var(files[i], 'DustEjectedMass_elements', snap)[ok], axis = 1)# + np.nansum(get_.get_var(files[i], 'DustEjectedMass_elements', snap)[ok], axis = 1) + np.nansum(get_.get_var(files[i], 'DustICM_elements', snap)[ok], axis = 1)#
    Mdust = Mdust1 + Mdust2

    Mcg = get_.get_var(files[i],
                       'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                           files[i], 'ColdGasClouds_elements', snap)[ok]

    Mdust_sat = Mcg[:,
                    2] * 0.7 + Mcg[:,
                                   4] * 0.2 + Mcg[:,
                                                  6] + Mcg[:,
                                                           7] + Mcg[:,
                                                                    9] + Mcg[:,
                                                                             10]

    Mcg = np.nansum(Mcg, axis=1)
    ok = np.where(
        Mcg > 1e6
    )  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen

    Mstar = Mstar[ok]
    Mdust = Mdust[ok]
    Type = Type[ok]
    Mdust_sat = Mdust_sat[ok]
    """
    if z > 4:
        bins = 10**(np.linspace(min(np.log10(Mstar)), max(np.log10(Mstar)), num = 10, endpoint = True))
        xx = yy = np.array([])

        for k in range(0, len(bins)-1):
            ok = np.logical_and(Mstar>=bins[k], Mstar<bins[k+1])
            if np.sum(ok)>5:
                xx = np.append(xx, np.nanmax(Mstar[ok]))
                yy = np.append(yy, np.nanmax(Mdust_sat[ok]))

        axs.plot(np.log10(xx), np.log10(yy), ls = 'dotted', lw = 3, color = 'red')
    """
    return Mstar, Mdust, Type
Beispiel #11
0
                        figsize=(10, 8),
                        sharex=False,
                        sharey=True,
                        facecolor='w',
                        edgecolor='k')
axs = axs.ravel()
color = [
    'red', 'green', 'blue', 'orange', 'violet', 'indigo', 'violet', 'brown',
    'yellow'
]
for j, k in enumerate(range(6, 7)):

    i = 0
    z = 6
    snap = snapnum[i][np.where(redshift == str(z))[0][0]]
    Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / 0.673
    ok = np.where(Mstar >= 10**8.85)[0]
    Mstar = Mstar[ok]
    Type = get_.get_var(files[i], 'Type', snap)[ok]
    dustrates = get_.get_var(files[i], 'DustColdGasRates', snap)[ok]
    Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2

    Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
    Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
    Mdust = Mdust1 + Mdust2

    met = (Mcg[:, 4] - Mdust[:, 4]) / (15.9994 * (Mcg[:, 0]))  #O/H ratio

    Mcg = np.sum(Mcg[:, 2:], axis=1)  #Total cold gas mass
def get_vals(files, z, axs, snapnum, i, on):

    if on:
        i = 0
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/0.673
        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
        Mdust = Mdust1 + Mdust2

        ok = np.logical_and(Mstar >= 10**9.0, Mdust > 0.)[0]
        Mstar = Mstar[ok]
        Mdust = Mdust[ok]
        Type = get_.get_var(files[i], 'Type', snap)[ok]
        Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
        Mcg = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok] + get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]

        met = (Mcg[:,4]-Mdust[:,4])/(15.9994*(Mcg[:,0]))  #O/H ratio

        tacc = get_.get_var(files[i], 't_acc', snap)[ok]

        i = 1
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        tmp = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/0.673
        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
        Mdust = Mdust1 + Mdust2

        ok = np.logical_and(tmp > 10**7.0, np.logical_and(tmp < 10**9.0, Mdust > 0))
        Mstar = np.append(Mstar, tmp[ok])
        Type = np.append(Type, get_.get_var(files[i], 'Type', snap)[ok])
        Age = np.append(Age, get_.get_var(files[i], 'MassWeightAge', snap)[ok])
        Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok] + get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]

        met = np.append(met, (Mcg1[:,4]-Mdust[:,4])/(15.9994*(Mcg1[:,0])))
        Mcg = np.append(np.nansum(Mcg, axis = 1), np.nansum(Mcg1, axis = 1))

        tacc = np.append(tacc, get_.get_var(files[i], 't_acc', snap)[ok])
        
        ok = np.logical_and(Mcg > 1e6, 12.+np.log10(met) > 6.)  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen
        add = 'MR_MRII'
    else:
        add = sims[i]
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/0.673

        Type = get_.get_var(files[i], 'Type', snap)
        Mcg = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok] + get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]

        met = (Mcg[:,4])/(15.9994*(Mcg[:,0]))  #O/H ratio
        Mcg = np.nansum(Mcg, axis = 1)
        tacc = get_.get_var(files[i], 't_acc', snap)
        
        ok = np.logical_and(Mcg > 1e6, 12.+np.log10(met) > 6.)  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen
        
    return add, met[ok], tacc[ok], Type[ok], Age[ok]
Beispiel #13
0
def plot_Mstar_Mdust_age(files, z, axs, snapnum, i, on):

    add = sims[i]
    snap = snapnum[i][np.where(redshift == str(z))[0][0]]

    try:
        data = np.load('data/Mstar_{}_snap_{}.npz'.format(add, snap))
        Mstar = data['Mstar']
        data = np.load('data/Type_{}_snap_{}.npz'.format(add, snap))
        Type = data['Type']
        data = np.load('data/Age_{}_snap_{}.npz'.format(add, snap))
        Age = data['Age']
        data = np.load('data/DustColdGasDiff_elements_{}_snap_{}.npz'.format(
            add, snap))
        Mdust1 = data['DustColdGasDiff_elements']
        data = np.load('data/DustColdGasClouds_elements_{}_snap_{}.npz'.format(
            add, snap))
        Mdust2 = data['DustColdGasClouds_elements']

    except:
        Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h

        if on and i == 0:
            ok = np.where(Mstar >= 10**8.9)[0]
        elif on and i == 1:
            ok = np.logical_and(Mstar > 10**7.5, Mstar < 10**8.9)
        else:
            ok = np.array([True] * len(Mstar))

        Mstar = Mstar[ok]
        np.savez_compressed('data/Mstar_{}_snap_{}'.format(add, snap),
                            Mstar=Mstar)
        Type = get_.get_var(files[i], 'Type', snap)[ok]
        np.savez_compressed('data/Type_{}_snap_{}'.format(add, snap),
                            Type=Type)
        Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
        np.savez_compressed('data/Age_{}_snap_{}'.format(add, snap), Age=Age)
        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        np.savez_compressed('data/DustColdGasDiff_elements_{}_snap_{}'.format(
            add, snap),
                            DustColdGasDiff_elements=Mdust1)
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        np.savez_compressed(
            'data/DustColdGasClouds_elements_{}_snap_{}'.format(add, snap),
            DustColdGasClouds_elements=Mdust2)

    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2

    x, y, xx, yy, yy_up, yy_low, den = create_out.out_age(
        Mstar, Mdust, Type, Age, z)

    x = np.log10(x)
    y = np.log10(y)
    xx = np.log10(xx)
    yy = np.log10(yy)
    yy_up = np.log10(yy_up)
    yy_low = np.log10(yy_low)

    p = make_fig.fig_age(axs, z, x, y, xx, yy, yy_up, yy_low, den)

    xlim = [7.5, 11.9]
    ylim = [1.5, 10.8]
    xticks = [8, 9, 10, 11]

    axs.set_xlim(xlim)
    axs.set_ylim(ylim)
    axs.set_xticks(xticks)

    return add, p, den
Beispiel #14
0
def get_vals(z):

    snap = snapnumMR[np.where(redshift == str(z))[0][0]]
    files = '../Dust_output/MR/SA_output_*'
    Mstar = (get_.get_var(files, 'StellarMass', snap) * 1e10) / h
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2
    ok = np.logical_and(Mstar > 10**9.0, Mdust > 0)

    Mstar = Mstar[ok]
    Mdust = Mdust[ok]
    Age = get_.get_var(files, 'MassWeightAge', snap)[ok]
    mu = get_.get_var(files, 'mu_gas', snap)[ok]
    Type = get_.get_var(files, 'Type', snap)[ok]
    Mcg1 = get_.get_var(files, 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files, 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2

    Mmet = np.nansum(Mcg[:, 2:], axis=1)
    Mcg = np.nansum(Mcg, axis=1)

    snap = snapnumMRII[np.where(redshift == str(z))[0][0]]
    files = '../Dust_output/MRII/SA_output_*'
    tmp = (get_.get_var(files, 'StellarMass', snap) * 1e10) / h
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    tmp1 = Mdust1 + Mdust2
    ok = np.logical_and(tmp > 10**7.4, np.logical_and(tmp < 10**9.0, tmp1 > 0))

    Mstar = np.append(Mstar, tmp[ok])
    Mdust = np.append(Mdust, tmp1[ok])
    Age = np.append(Age, get_.get_var(files, 'MassWeightAge', snap)[ok])
    mu = np.append(mu, get_.get_var(files, 'mu_gas', snap)[ok])
    Mcg1 = get_.get_var(files, 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files, 'ColdGasClouds_elements', snap)[ok]
    Type = np.append(Type, get_.get_var(files, 'Type', snap)[ok])

    Mmet = np.append(Mmet, np.nansum(Mcg1[:, 2:] + Mcg2[:, 2:], axis=1))
    Mcg = np.append(Mcg, np.nansum(Mcg1 + Mcg2, axis=1))

    Z = Mmet / Mcg
    DTM = Mdust / (Mmet)
    ok = np.where(Mcg > 1e6)

    Mdust = Mdust[ok]
    DTM = DTM[ok]
    Z = Z[ok]
    Mstar = Mstar[ok]
    Age = Age[ok]
    Type = Type[ok]
    mu = mu[ok]

    out = get_.remove_(np.array([Mdust, DTM, Z, Mstar, Age, Type, mu]),
                       np.array([5]))
    out = out[(out[5] == 0)]
    out = np.array(out).T

    return out[0], out[1], out[2], out[3], out[4], out[5]
Beispiel #15
0
def get_vals(tacc, z):

    snap = snapnumMR[np.where(redshift == str(z))[0][0]]
    files = '../test_rmol/def_{}/MR/SA_output_*'.format(tacc)
    Mstar = (get_.get_var(files, 'StellarMass', snap) * 1e10) / 0.673
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    Mdust = Mdust1 + Mdust2
    ok = np.logical_and(Mstar >= 10**9, Mdust > 0)

    Mstar = Mstar[ok]
    Mdust = Mdust[ok]
    Age = get_.get_var(files, 'MassWeightAge', snap)[ok]
    Mcg1 = get_.get_var(files, 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files, 'ColdGasClouds_elements', snap)[ok]
    Mcg = Mcg1 + Mcg2

    Mmet = np.nansum(Mcg[:, 2:], axis=1)
    Mcg = np.nansum(Mcg, axis=1)

    snap = snapnumMRII[np.where(redshift == str(z))[0][0]]
    files = '../test_rmol/def_{}/MRII/SA_output_*'.format(tacc)
    tmp = (get_.get_var(files, 'StellarMass', snap) * 1e10) / 0.673
    Mdust1 = get_.get_var(files, 'DustColdGasDiff_elements', snap)
    Mdust2 = get_.get_var(files, 'DustColdGasClouds_elements', snap)
    Mdust1 = np.nansum(Mdust1, axis=1)
    Mdust2 = np.nansum(Mdust2, axis=1)
    tmp1 = Mdust1 + Mdust2
    ok = np.logical_and(tmp > 10**7.5, np.logical_and(tmp < 10**9, tmp1 > 0))

    Mstar = np.append(Mstar, tmp[ok])
    Mdust = np.append(Mdust, tmp1[ok])
    Age = np.append(Age, get_.get_var(files, 'MassWeightAge', snap)[ok])
    Mcg1 = get_.get_var(files, 'ColdGasDiff_elements', snap)[ok]
    Mcg2 = get_.get_var(files, 'ColdGasClouds_elements', snap)[ok]

    Mmet = np.append(Mmet, np.nansum(Mcg1[:, 2:] + Mcg2[:, 2:], axis=1))
    Mcg = np.append(Mcg, np.nansum(Mcg1 + Mcg2, axis=1))

    Z = Mmet / Mcg
    DTM = Mdust / (Mmet)
    ok = np.where(Mcg > 1e6)
    return Mdust[ok], DTM[ok], Z[ok], Mstar[ok], Age[ok]
Beispiel #16
0
def get_vals(files, z, axs, snapnum, i, on):

    if on:
        i = 0
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/h
        ok = np.where(Mstar >= 10**9)[0]
        Mstar = Mstar[ok]
        Type = get_.get_var(files[i], 'Type', snap)[ok]
        Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
        Mcg = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok] + get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]

        met = (Mcg[:,4])/(15.9994*(Mcg[:,0]))  #O/H ratio

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        Mdust = Mdust1 + Mdust2
        met = met - (Mdust[:,4])/(15.9994*(Mcg[:,0]))

        Mcg = np.sum(Mcg, axis = 1) #Total cold gas mass
        Mdust = np.nansum(Mdust, axis = 1)

        Mratio = Mdust/Mcg   #Dust-to-total cold gas mass ratio. Dimensionless.

        i = 1
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        tmp = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/h
        ok = np.logical_and(tmp > 10**7.5, tmp < 10**8.98)
        Mstar = np.append(Mstar, tmp[ok])
        Type = np.append(Type, get_.get_var(files[i], 'Type', snap)[ok])
        Age = np.append(Age, get_.get_var(files[i], 'MassWeightAge', snap)[ok])
        tmp1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok] + get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        tmp2 = Mdust1 + Mdust2

        met = np.append(met, (tmp1[:,4]-tmp2[:,4])/(15.9994*(tmp1[:,0])))

        tmp1 = np.nansum(tmp1, axis = 1)
        tmp2 = np.nansum(Mdust1 + Mdust2, axis = 1)

        Mdust = np.append(Mdust, tmp2)

        Mratio = np.append(Mratio, tmp2/tmp1)
        
        Mcg = np.append(Mcg, tmp1)
        ok = np.logical_and(Mcg > 1e6, 12.+np.log10(met) > 6.)  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen

        add = 'MR_MRII'
    else:
        add = sims[i]
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap)*1e10)/h
        
        Type = get_.get_var(files[i], 'Type', snap)
        Age = get_.get_var(files[i], 'MassWeightAge', snap)
        Mcg = get_.get_var(files[i], 'ColdGas_elements', snap)

        met = (Mcg[:,4])/(15.9994*(Mcg[:,0]))  #O/H ratio

        Mcg = np.nansum(Mcg, axis = 1) #Total cold gas mass

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
        Mdust1 = np.nansum(Mdust1, axis = 1)
        Mdust2 = np.nansum(Mdust2, axis = 1)
        Mdust = Mdust1 + Mdust2

        Mratio = Mdust/Mcg   #Dust-to-total cold gas mass ratio. Dimensionless.
        
        ok = np.logical_and(Mcg > 1e6, 12.+np.log10(met) > 6.)  #Only selecting galaxies with cold gas mass above this value, so the galaxies we are looking at are realistic for the dust content usually seen
        
    return add, met[ok], Mratio[ok], Type[ok], Age[ok]
def get_vals(files, z, axs, snapnum, i, on):

    if on == False:
        add = sims[i]
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h

        Age = get_.get_var(files[i], 'MassWeightAge', snap)

        Type = get_.get_var(files[i], 'Type', snap)
        Mcg = get_.get_var(files[i],
                           'ColdGasDiff_elements', snap) + get_.get_var(
                               files[i], 'ColdGasClouds_elements', snap)
        met = Mcg[:, 4] / (15.9994 * Mcg[:, 0])  #O/H ratio

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)
        Mdust = Mdust1 + Mdust2

        met = met - Mdust[:, 4] / (15.9994 * Mcg[:, 0])

        Mdust = np.nansum(Mdust, axis=1)

        ok = np.logical_and(Mcg > 1e6, 12. + np.log10(met) > 6.)

    else:
        i = 0
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
        ok = np.where(Mstar >= 10**9.0)[0]

        Mstar = Mstar[ok]
        Age = get_.get_var(files[i], 'MassWeightAge', snap)[ok]
        Type = get_.get_var(files[i], 'Type', snap)[ok]
        Mcg = get_.get_var(files[i],
                           'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                               files[i], 'ColdGasClouds_elements', snap)[ok]

        met = Mcg[:, 4] / (15.9994 * Mcg[:, 0])  #O/H ratio

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        Mdust = Mdust1 + Mdust2

        met = met - Mdust[:, 4] / (15.9994 * Mcg[:, 0])

        Mdust = np.nansum(Mdust, axis=1)

        i = 1
        snap = snapnum[i][np.where(redshift == str(z))[0][0]]
        tmp = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / h
        ok = np.logical_and(tmp > 10**7.0, tmp < 10**9.0)
        Mstar = np.append(Mstar, tmp[ok])

        Type = np.append(Type, get_.get_var(files[i], 'Type', snap)[ok])
        Age = np.append(Age, get_.get_var(files[i], 'MassWeightAge', snap)[ok])
        Mcg1 = get_.get_var(files[i],
                            'ColdGasDiff_elements', snap)[ok] + get_.get_var(
                                files[i], 'ColdGasClouds_elements', snap)[ok]

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        tmp = Mdust1 + Mdust2

        met = np.append(met, (Mcg1[:, 4] - tmp[:, 4]) / (15.9994 * Mcg[:, 0]))

        Mdust = np.append(Mdust, np.nansum(tmp, axis=1))

        Mcg = np.append(np.nansum(Mcg, axis=1), np.nansum(Mcg1, axis=1))
        ok = np.logical_and(Mcg > 1e6, 12. + np.log10(met) > 6.)
        add = 'MR_MRII'

    return add, met[ok], Mdust[ok], Type[ok], Age[ok]
def plot_Z_dep(files, z, axs, snaps, i, on):

    if on:
        add = sims[0] + '_' + sims[1]
        snap = snaps[0][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[0], 'StellarMass', snap) * 1e10) / 0.673
        ok = np.where(Mstar >= 1e9)
        Mstar = Mstar[ok]
        Type = get_.get_var(files[0], 'Type', snap)[ok]

        Mdust1 = get_.get_var(files[0], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[0], 'DustColdGasClouds_elements', snap)[ok]
        Mdust = Mdust1 + Mdust2

        Mcg1 = get_.get_var(files[0], 'ColdGasDiff_elements', snap)[ok]
        Mcg2 = get_.get_var(files[0], 'ColdGasClouds_elements', snap)[ok]
        Mcg = Mcg1 + Mcg2

        SFR = get_.get_var(files[0], 'Sfr', snap)[ok]

        snap = snaps[1][np.where(redshift == str(z))[0][0]]
        tmp = (get_.get_var(files[1], 'StellarMass', snap) * 1e10) / 0.673
        ok = np.logical_and(tmp > 1e7, tmp <= 1e9)
        Mstar = np.append(Mstar, tmp[ok])

        Type = np.append(Type, get_.get_var(files[1], 'Type', snap)[ok])

        tmp1 = get_.get_var(files[1], 'DustColdGasDiff_elements', snap)[ok]
        tmp2 = get_.get_var(files[1], 'DustColdGasClouds_elements', snap)[ok]
        Mdust = np.append(Mdust, tmp1 + tmp2, axis=0)

        tmp1 = get_.get_var(files[1], 'ColdGasDiff_elements', snap)[ok]
        tmp2 = get_.get_var(files[1], 'ColdGasClouds_elements', snap)[ok]
        Mcg = np.append(Mcg, tmp1 + tmp2, axis=0)

        SFR = np.append(SFR, get_.get_var(files[1], 'Sfr', snap)[ok])

    else:

        add = sims[i]
        snap = snaps[0][np.where(redshift == str(z))[0][0]]
        Mstar = (get_.get_var(files[i], 'StellarMass', snap) * 1e10) / 0.673
        if i == 0:
            ok = np.where(Mstar >= 1e9)[0]
        else:
            ok = np.logical_and(Mstar > 1e7, Mstar <= 1e9)

        Mstar = Mstar[ok]
        Type = get_.get_var(files[i], 'Type', snap)[ok]

        Mdust1 = get_.get_var(files[i], 'DustColdGasDiff_elements', snap)[ok]
        Mdust2 = get_.get_var(files[i], 'DustColdGasClouds_elements', snap)[ok]
        Mdust = Mdust1 + Mdust2

        Mcg1 = get_.get_var(files[i], 'ColdGasDiff_elements', snap)[ok]
        Mcg2 = get_.get_var(files[i], 'ColdGasClouds_elements', snap)[ok]
        Mcg = Mcg1 + Mcg2

        SFR = get_.get_var(files[i], 'Sfr', snap)[ok]

    sSFR = SFR / Mstar

    pltx = (Mcg[:, 4] - Mdust[:, 4]) / (15.9994 * (Mcg[:, 0]))

    plot_figure(pltx, Mcg, Mdust, sSFR, Type, z, axs)

    xlim = [6.8, 9.8]
    xticks = [7, 7.5, 8, 8.5, 9, 9.5]

    axs.set_xlim(xlim)
    axs.set_xticks(xticks)

    return add