def passive_fractions_centrals():

    # Meta-data
    name = ("Fit to the passive fraction - stellar mass (centrals) "
            f"at z=[{redshift_header_info:s}]")
    comment = (
        "The data is taken from https://www.peterbehroozi.com/data.html. "
        "The quenched fractions are defined using the standard criterion where "
        "specific star formation rate < 1e-11 yr^-1. "
        "The stellar mass is the observed stellar mass as defined in Behroozi et al. "
        "(2019) eq. 25. "
        "Uses the Chabrier initial mass function. "
        "The passive fractions are given by the 50th percentile of the posterior "
        "distribution of the fitting model. "
        "Cosmology: Omega_m=0.307, Omega_lambda=0.693, h=0.678, sigma_8=0.823, "
        "n_s=0.96. "
        "Shows the passive fraction of centrals versus galaxy stellar mass.")

    # Store metadata at the top level
    multi_z = MultiRedshiftObservationalData()
    multi_z.associate_citation(citation, bibcode)
    multi_z.associate_name(name)
    multi_z.associate_comment(comment)
    multi_z.associate_cosmology(cosmology)
    multi_z.associate_maximum_number_of_returns(1)

    output_filename = "Behroozi2019_centrals.hdf5"
    output_directory = "../"

    if not os.path.exists(output_directory):
        os.mkdir(output_directory)

    for z, dz_lower, dz_upper, a_str in zip(redshifts, redshifts_lower,
                                            redshifts_upper,
                                            scale_factors_str):
        # Create a single observational-data instance at redshift z
        processed = ObservationalData()

        # Load raw Behroozi2019 data
        data = np.loadtxt(f"../raw/Behroozi2019_qf_groupstats_a{a_str}.dat")

        # Fetch the fields we need
        log_M_star, QF, QF_plus, QF_minus = (
            data[:, 0],
            data[:, 1],
            data[:, 2],
            data[:, 3],
        )

        # We don't want to plot zeros
        mask = np.where(QF > 0.0)

        # Transform stellar mass
        M_star = (10.0**log_M_star) * unyt.Solar_Mass

        # Define scatter with respect to the best-fit value (16 and 84 percentiles)
        QF_scatter = unyt.unyt_array((QF_minus[mask], QF_plus[mask]),
                                     units="dimensionless")

        # Compute \Delta z
        redshift_lower, redshift_upper = [z - dz_lower, z + dz_upper]

        processed.associate_x(
            M_star[mask],
            scatter=None,
            comoving=False,
            description="Galaxy Stellar Mass",
        )
        processed.associate_y(
            QF[mask] * unyt.dimensionless,
            scatter=QF_scatter,
            comoving=False,
            description="Passive Fraction (centrals)",
        )

        processed.associate_redshift(z, redshift_lower, redshift_upper)
        processed.associate_plot_as(plot_as)

        multi_z.associate_dataset(processed)

    output_path = f"{output_directory}/{output_filename}"

    if os.path.exists(output_path):
        os.remove(output_path)

    multi_z.write(filename=output_path)
Example #2
0
        Z_asm = 6.29
        alpha = 0.21
    else:
        Z_asm = 4.84
        alpha = 0.35

    log10_M_star_min = 9.5
    log10_M_star_max = 11.5
    M_star = np.arange(log10_M_star_min, log10_M_star_max, 0.2)
    Z_gas = (Z_asm + alpha * M_star) * unyt.dimensionless  # 12 + log(O/H)
    M_star = 10**M_star * unyt.Solar_Mass

    processed.associate_x(M_star,
                          scatter=None,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Z_gas,
                          scatter=None,
                          comoving=True,
                          description="Gas phase metallicity")
    processed.associate_redshift(z, redshift_lower, redshift_upper)
    processed.associate_plot_as(plot_as)
    multi_z.associate_dataset(processed)

output_path = f"{output_directory}/{output_filename}"

if os.path.exists(output_path):
    os.remove(output_path)

multi_z.write(filename=output_path)
Example #3
0
if not os.path.exists(output_directory):
    os.mkdir(output_directory)
comment = (
    "Assuming Chabrier IMF and Vmax selection, quoted redshift is lower bound of range. "
    f"h-corrected for SWIFT using Cosmology: {cosmology.name}.")
citation = "Ilbert et al. (2013)"
bibcode = "2013A&A...556A..55I"
name = "GSMF from UltraVISTA"

multi_z = MultiRedshiftObservationalData()
multi_z.associate_comment(comment)
multi_z.associate_name(name)
multi_z.associate_citation(citation, bibcode)
multi_z.associate_cosmology(cosmology)

# z_bins is a 1-D ndarray containing the lower edges of the redshift bins
# gsmf_and_Mstar is a list of 2D ndarrays, one per redshift
# Each contains five columns as follows:
# log(Mstar) bins, Mstar errors, log(GSMF), GSMF +- errors
z_bins, gsmf_and_Mstar = load_file_and_split_by_z(input_filename)

for z, gsmf_and_Mstar_at_z in zip(z_bins, gsmf_and_Mstar):
    multi_z.associate_dataset(process_for_redshift(z, gsmf_and_Mstar_at_z))

output_path = f"{output_directory}/{output_filename}"

if os.path.exists(output_path):
    os.remove(output_path)

multi_z.write(filename=output_path)
def Phi_passive_galaxies():

    # Meta-data
    name = f"Fit to the quenched galaxy stellar mass function at z=[{redshift_header_info:s}]"
    comment = (
        "The data is taken from https://www.peterbehroozi.com/data.html. "
        "The stellar mass is the observed stellar mass as defined in Behroozi et al. "
        "(2019) eq. 25. "
        "The quenched fractions are defined using the standard criterion where specific"
        " star formation rate < 1e-11 yr^-1. "
        "Uses the Chabrier initial mass function. "
        "GSMF is incomplete below 10**7.0 Msun at z=0 and 10**8.5 Msum at z=8. "
        "Cosmology: Omega_m=0.307, Omega_lambda=0.693, h=0.678, sigma_8=0.823, "
        "n_s=0.96. "
        "Shows the quenched galaxy stellar mass function (number densities in comoving"
        " Mpc^-3 dex^-1 vs. stellar mass).")

    # Store metadata at the top level
    multi_z = MultiRedshiftObservationalData()
    multi_z.associate_citation(citation, bibcode)
    multi_z.associate_name(name)
    multi_z.associate_comment(comment)
    multi_z.associate_cosmology(cosmology)
    multi_z.associate_maximum_number_of_returns(1)

    output_filename = "Behroozi2019_passive.hdf5"
    output_directory = "../"

    if not os.path.exists(output_directory):
        os.mkdir(output_directory)

    for z, dz_lower, dz_upper, a_str in zip(redshifts, redshifts_lower,
                                            redshifts_upper,
                                            scale_factors_str):
        # Create a single observational-data instance at redshift z
        processed = ObservationalData()

        # Load raw Behroozi2019 data
        data = np.loadtxt(f"../raw/Behroozi2019_smf_a{a_str}.dat")

        # Fetch the fields we need
        log_M_star, Phi, Phi_plus, Phi_minus = (
            data[:, 0],
            data[:, 7],
            data[:, 8],
            data[:, 9],
        )

        # We don't want to plot zeros
        mask = np.where(Phi > 0.0)

        # Transform stellar mass
        M_star = (10.0**log_M_star) * unyt.Solar_Mass

        # Define scatter with respect to the best-fit value (16 and 84 percentiles)
        Phi_scatter = unyt.unyt_array((Phi_minus[mask], Phi_plus[mask]),
                                      units=unyt.Mpc**(-3))

        # Compute \Delta z
        redshift_lower, redshift_upper = [z - dz_lower, z + dz_upper]

        processed.associate_x(
            M_star[mask],
            scatter=None,
            comoving=False,
            description="Galaxy Stellar Mass",
        )
        processed.associate_y(
            Phi[mask] * (h_sim / ORIGINAL_H)**3 * unyt.Mpc**(-3),
            scatter=Phi_scatter * (h_sim / ORIGINAL_H)**3,
            comoving=True,
            description="Phi (GSMF)",
        )

        processed.associate_redshift(z, redshift_lower, redshift_upper)
        processed.associate_plot_as(plot_as)

        multi_z.associate_dataset(processed)

    output_path = f"{output_directory}/{output_filename}"

    if os.path.exists(output_path):
        os.remove(output_path)

    multi_z.write(filename=output_path)
Example #5
0
    processed_sf.associate_redshift(0.5 * sum(redshift_bin), *redshift_bin)
    processed_sf.associate_plot_as(plot_as)

    processed_nsf.associate_x(centers_nsf,
                              scatter=None,
                              comoving=False,
                              description="Galaxy Stellar Mass")
    processed_nsf.associate_y(
        medians_nsf,
        scatter=deviations_nsf,
        comoving=False,
        description="Galaxy Half-Mass Radius",
    )
    processed_nsf.associate_redshift(0.5 * sum(redshift_bin), *redshift_bin)
    processed_nsf.associate_plot_as(plot_as)

    multi_z_sf.associate_dataset(processed_sf)
    multi_z_nsf.associate_dataset(processed_nsf)

output_path_sf = f"{output_directory}/Mosleh2020_SF.hdf5"
output_path_nsf = f"{output_directory}/Mosleh2020_Q.hdf5"

if os.path.exists(output_path_sf):
    os.remove(output_path_sf)

if os.path.exists(output_path_nsf):
    os.remove(output_path_nsf)

multi_z_sf.write(filename=output_path_sf)
multi_z_nsf.write(filename=output_path_nsf)
    f"Assuming Chabrier IMF, quoted redshift is average in range. "
    "h-corrected for SWIFT using Cosmology: {cosmology.name}."
)
citation = "Tomczak et al (2013)"
bibcode = "2014ApJ...783...85T"
name = "GSMF from ZFOURGE/CANDELS"

multi_z = MultiRedshiftObservationalData()
multi_z.associate_comment(comment)
multi_z.associate_name(name)
multi_z.associate_citation(citation, bibcode)
multi_z.associate_cosmology(cosmology)
multi_z.associate_maximum_number_of_returns(2)


# z_bins, mstar_bins are 1-D ndarrays containing the redshift ranges and the log(stellar mass) bins respectively
# gsmf is a 3-D ndarray with axes 0 and 1 corresponding to redshift ranges and stellar mass bins
# Axis 2 ranges from 0..2 and contains log(GSMF), and the +- errors respectively
z_bins, mstar_bins, gsmf = load_file_and_split_by_z(input_filename)


for z, gsmf_at_z in zip(z_bins, gsmf):
    multi_z.associate_dataset(process_for_redshift(z, mstar_bins, gsmf_at_z))

output_path = f"{output_directory}/{output_filename}"

if os.path.exists(output_path):
    os.remove(output_path)

multi_z.write(output_path)
def StellarMassHaloMassRatios_vs_StellarMass():

    name = f"Fit to the stellar mass / halo mass - stellar mass relation at z=[{redshift_header_info:s}]"
    comment = (
        "The data is taken from https://www.peterbehroozi.com/data.html. "
        "Median fit to the raw data for centrals (i.e. excluding satellites). "
        "The stellar mass is the true stellar mass (i.e. w/o observational "
        "corrections). "
        "The halo mass is the peak halo mass that follows the Bryan & Norman (1998) "
        "spherical overdensity definition. "
        "The fitting function does not include the intrahalo light contribution to the "
        "stellar mass. "
        "Cosmology: Omega_m=0.307, Omega_lambda=0.693, h=0.678, sigma_8=0.823, "
        "n_s=0.96. "
        "Shows the ratio between stellar mass and halo mass as a function of stellar "
        "mass. ")

    # Store metadata at the top level
    multi_z = MultiRedshiftObservationalData()
    multi_z.associate_citation(citation, bibcode)
    multi_z.associate_name(name)
    multi_z.associate_comment(comment)
    multi_z.associate_cosmology(cosmology)
    multi_z.associate_maximum_number_of_returns(1)

    output_filename = "Behroozi2019RatioStellar.hdf5"
    output_directory = "../"

    if not os.path.exists(output_directory):
        os.mkdir(output_directory)

    for z, dz_lower, dz_upper in zip(redshifts, redshifts_lower,
                                     redshifts_upper):
        # Create a single observational-data instance at redshift z
        processed = ObservationalData()

        # Stellar masses (for the given halo masses, at redshift z)
        # Stellar masses (for the given halo masses, at redshift z)
        M_star, M_84, M_16 = behroozi_2019_raw_with_uncertainties(
            z, M_BN98,
            "../raw/Behroozi_2019_fitting_params_smhm_true_med_cen.txt")

        # Compute \Delta z
        redshift_lower, redshift_upper = [z - dz_lower, z + dz_upper]

        # Define scatter
        y_scatter = unyt.unyt_array(
            ((M_star - M_16) / M_BN98, (M_84 - M_star) / M_BN98))

        processed.associate_x(
            M_star * unyt.Solar_Mass,
            scatter=None,
            comoving=True,
            description="Galaxy Stellar Mass",
        )
        processed.associate_y(
            (M_star / M_BN98) * unyt.dimensionless,
            scatter=y_scatter * unyt.dimensionless,
            comoving=True,
            description=
            "Galaxy Stellar Mass / Halo Mass ($M_* / M_{\\rm BN98}$)",
        )

        processed.associate_redshift(z, redshift_lower, redshift_upper)
        processed.associate_plot_as(plot_as)

        multi_z.associate_dataset(processed)

    output_path = f"{output_directory}/{output_filename}"

    if os.path.exists(output_path):
        os.remove(output_path)

    multi_z.write(filename=output_path)