Пример #1
0
def process_for_redshift(z, Mstar_bins, gsmf_at_z):
    """
    Output an `ObservationalData` instance containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for
    Mstar_bins: the list of stellar mass bins for which the GSMF is tabulated
    gsmf_at_z: the values of the GSMF at the chosen redshift
    """

    processed = ObservationalData()

    plot_as = "line"
    h = cosmology.h

    M = Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
    M_err = None
    Phi = gsmf_at_z * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    Phi_err = None

    processed.associate_x(M,
                          scatter=M_err,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_redshift(z)
    processed.associate_plot_as(plot_as)

    return processed
def process_for_redshift(z, mstar_bins, gsmf_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for. The given value corresponds to the lower
    edge of a range in redshift, which has width 0.25 for z < 1.5 and 0.5 for z >= 1.5
    mstar_bins: the list of stellar mass bins for which the GSMF is tabulated
    gsmf_at_z: the slice of the GSMF array at the chosen redshift
    """

    processed = ObservationalData()

    plot_as = "points"
    h = cosmology.h

    M = 10 ** mstar_bins * (h / ORIGINAL_H) ** (-2) * unyt.Solar_Mass
    Phi = 10 ** gsmf_at_z[:, 0] * (h / ORIGINAL_H) ** 3 * unyt.Mpc ** (-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    Phi_err = (
        (10 ** gsmf_at_z[:, [0]] * np.log(10) * gsmf_at_z[:, [2, 1]]).T
        * (h / ORIGINAL_H) ** 3
        * unyt.Mpc ** (-3)
    )

    processed.associate_x(
        M, scatter=None, comoving=True, description="Galaxy Stellar Mass"
    )
    processed.associate_y(Phi, scatter=Phi_err, comoving=True, description="Phi (GSMF)")
    processed.associate_redshift(sum(z) * 0.5, *z)
    processed.associate_plot_as(plot_as)

    return processed
def process_for_redshift(z, gdmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GDMF at a given redshift.

    z: the redshift to produce the GDMF for. The given value corresponds to the lower
    edge of a range in redshift of width 0.5, except for the first bin 0.2 < z < 0.5,
    and the last bin 3.0 < z < 4.0
    gdmf_and_mstar_at_z: the array containing stellar mass bins and the GDMF at the
    chosen redshift
    """

    processed = ObservationalData()

    comment = (
        "Beeston et al. (2018). Obtained using H-ATLAS+GAMA"
        f"data, h-corrected for SWIFT using Cosmology: {cosmology.name}.")
    citation = "Beeston et al. (2018)"
    bibcode = "2018MNRAS.479.1077B"
    name = "GDMF from H-ATLAS+GAMA"
    plot_as = "points"
    redshift = z
    h = cosmology.h

    Mstar_bins = gdmf_and_Mstar_at_z[:, 0]
    M = 10**Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
    Phi = 10**gdmf_and_Mstar_at_z[:, 1] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    M_err = ((10**gdmf_and_Mstar_at_z[:, 2][:, None] * np.log(10) *
              gdmf_and_Mstar_at_z[:, [2, 3]]).T * (h / ORIGINAL_H)**3 *
             unyt.Solar_Mass)

    Phi_err = ((10**gdmf_and_Mstar_at_z[:, 2][:, None] * np.log(10) *
                gdmf_and_Mstar_at_z[:, [4, 5]]).T * (h / ORIGINAL_H)**3 *
               unyt.Mpc**(-3))

    processed.associate_x(M,
                          scatter=M_err,
                          comoving=True,
                          description="Galaxy Dust Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GDMF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for. The given value corresponds to the lower
    edge of a range in redshift of width 0.5, except for the first bin 0.2 < z < 0.5,
    and the last bin 3.0 < z < 4.0
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    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"
    plot_as = "points"
    redshift = z
    h = cosmology.h

    Mstar_bins = gsmf_and_Mstar_at_z[:, 0]
    M = 10**Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
    Phi = 10**gsmf_and_Mstar_at_z[:, 1] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    Phi_err = ((10**gsmf_and_Mstar_at_z[:, 1][:, None] * np.log(10) *
                gsmf_and_Mstar_at_z[:, 2:]).T * (h / ORIGINAL_H)**3 *
               unyt.Mpc**(-3))

    processed.associate_x(M,
                          scatter=None,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for. The given value corresponds to the lower
    edge of a range in redshift of width 0.5, except for the first bin 0.2 < z < 0.5,
    and the last bin 3.0 < z < 4.0
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    plot_as = "points"
    h = cosmology.h

    Mstar_bins = gsmf_and_Mstar_at_z[:, 0]
    Mstar_Chab = Mstar_bins - np.log10(
        kroupa_to_chabrier_mass
    )  # convert from Kroupa IMF
    M = 10 ** Mstar_Chab * (h / ORIGINAL_H) ** (-2) * unyt.Solar_Mass
    M_err = (
        (10 ** Mstar_Chab * np.log(10) * gsmf_and_Mstar_at_z[:, 1])
        * (h / ORIGINAL_H) ** (-2)
        * unyt.Solar_Mass
    )
    Phi = 10 ** gsmf_and_Mstar_at_z[:, 2] * (h / ORIGINAL_H) ** 3 * unyt.Mpc ** (-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    Phi_err = (
        (
            10 ** gsmf_and_Mstar_at_z[:, 2][:, None]
            * np.log(10)
            * gsmf_and_Mstar_at_z[:, [4, 3]]
        ).T
        * (h / ORIGINAL_H) ** 3
        * unyt.Mpc ** (-3)
    )

    processed.associate_x(
        M, scatter=M_err, comoving=True, description="Galaxy Stellar Mass"
    )
    processed.associate_y(Phi, scatter=Phi_err, comoving=True, description="Phi (GSMF)")
    processed.associate_redshift(sum(z) * 0.5, *z)
    processed.associate_plot_as(plot_as)

    return processed
Пример #6
0
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for. The given value corresponds to the lower
    edge of a range in redshift of width 0.5 for z < 3.0, and width 1.0 for z > 3.0
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    comment = (
        "Assuming Chabrier IMF and Vmax selection, quoted redshift is lower bound of range. "
        f"h-corrected for SWIFT using Cosmology: {cosmology.name}.")
    citation = "Deshmukh et al. (2018)"
    bibcode = "2018ApJ...864..166D"
    name = "GSMF from SMUVS"
    plot_as = "points"
    redshift = z
    h = cosmology.h

    Mstar_bins = gsmf_and_Mstar_at_z[:, 0]
    M = 10**Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
    # GSMF and errors are stored in datafile with units 10^-4 Mpc^-3 dex^-1
    Phi = 1e-4 * gsmf_and_Mstar_at_z[:,
                                     1] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    Phi_err = (1e-4 * gsmf_and_Mstar_at_z[:, 2:].T * (h / ORIGINAL_H)**3 *
               unyt.Mpc**(-3))

    processed.associate_x(M,
                          scatter=None,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
Пример #7
0
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for. The given value corresponds to the lower
    edge of a range in redshift of width 0.5 for z < 3.0, and width 1.0 for z > 3.0
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    plot_as = "points"
    redshift = z
    h = cosmology.h

    Mstar_bins = 10**gsmf_and_Mstar_at_z[:, 0]
    M = Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
    # Mass errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    M_err = (Mstar_bins * np.log(10) * gsmf_and_Mstar_at_z[:, 1] *
             (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass)

    Phi = gsmf_and_Mstar_at_z[:, 2] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    Phi_err = gsmf_and_Mstar_at_z[:,
                                  3:].T * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)

    processed.associate_x(M,
                          scatter=M_err,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
Пример #8
0
def process_for_redshift(z, sfrf_at_z):
    """
    Output an HDF5 file containing the SFRF at a given redshift.

    z: the redshift to produce the SFRF for.
    sfrf_at_z: the array containing SFR and Phi_SFR bins at the chosen redshift
    """

    processed = ObservationalData()

    comment = (
        "Assuming Chabrier IMF and Vmax selection. Includes dust corrections as "
        "described in Katsianis et. al. 2017, section 2. "
        f"h-corrected for SWIFT using Cosmology: {cosmology.name}.")
    citation = "van der Burg et. al. (2010)"
    bibcode = "2010A&A...523A..74V"
    name = "SFRF from CFHT Legacy Survey"
    plot_as = "points"
    redshift = z
    h = cosmology.h

    SFR_bins = sfrf_at_z[:, 0]
    SFR = SFR_bins * unyt.Solar_Mass / unyt.year
    # SFRF and errors are stored in datafile with units 10^-2 Mpc^-3 dex^-1
    Phi = sfrf_at_z[:, 1] * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    Phi_err = sfrf_at_z[:, 2:].T * unyt.Mpc**(-3)

    processed.associate_x(SFR,
                          scatter=None,
                          comoving=True,
                          description="Star Formation Rate")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (SFRF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
def process_for_redshift(z, sfrf_at_z):
    """
    Output an HDF5 file containing the SFRF at a given redshift.

    z: the redshift to produce the SFRF for.
    sfrf_at_z: the array containing SFR and Phi_SFR bins at the chosen redshift
    """

    processed = ObservationalData()

    comment = (
        "Assuming Chabrier IMF and Vmax selection. Includes dust corrections as "
        "described in Katsianis et. al. 2017, section 2. "
        f"h-corrected for SWIFT using Cosmology: {cosmology.name}."
    )
    citation = "Smit et. al. (2012)"
    bibcode = "2013MNRAS.428.1128S"
    name = "SFRF from Bouwens+2007;2011"
    plot_as = "points"
    redshift = z
    h = cosmology.h

    SFR_bins = sfrf_at_z[:, 0]
    SFR = 10 ** SFR_bins * unyt.Solar_Mass / unyt.year
    Phi = sfrf_at_z[:, 1] * unyt.Mpc ** (-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    Phi_err = sfrf_at_z[:, 2] * unyt.Mpc ** (-3)

    processed.associate_x(
        SFR, scatter=None, comoving=True, description="Star Formation Rate"
    )
    processed.associate_y(Phi, scatter=Phi_err, comoving=True, description="Phi (SFRF)")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    return processed
Пример #10
0
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift to produce the GSMF for.
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    plot_as = "points"
    h = cosmology.h

    Mstar_bins = gsmf_and_Mstar_at_z[:, 0]
    M = 10**Mstar_bins * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass

    M_err = ((10**Mstar_bins * np.log(10) * gsmf_and_Mstar_at_z[:, 1]) *
             (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass)
    Phi = 10**gsmf_and_Mstar_at_z[:, 2] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    Phi_err = ((10**gsmf_and_Mstar_at_z[:, 2][:, None] *
                np.abs(gsmf_and_Mstar_at_z[:, [4, 3]]) * np.log(10)).T *
               (h / ORIGINAL_H)**3 * unyt.Mpc**(-3))

    processed.associate_x(M,
                          scatter=M_err,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_redshift(z)
    processed.associate_plot_as(plot_as)

    return processed
def process_for_redshift(z, gsmf_and_Mstar_at_z):
    """
    Output an HDF5 file containing the GSMF at a given redshift.

    z: the redshift range to produce the GSMF for.
    gsmf_and_mstar_at_z: the array containing stellar mass bins and the GSMF at the
    chosen redshift
    """

    processed = ObservationalData()

    plot_as = "points"
    h = cosmology.h

    Mstar_bins = (gsmf_and_Mstar_at_z[:, 0] * salpeter_to_chabrier_mass
                  )  # convert from Salpeter IMF
    M = Mstar_bins * h**-2 * unyt.Solar_Mass

    Phi = 10**gsmf_and_Mstar_at_z[:, 1] * h**3 * unyt.Mpc**(-3)
    # y_scatter should be a 1xN or 2xN array describing offsets from
    # the median point 'y'
    # Errors are log error dz = 1/ln(10) dy/y
    # We want dy = y ln(10) dz
    Phi_err = ((10**gsmf_and_Mstar_at_z[:, [1]] * np.log(10) *
                gsmf_and_Mstar_at_z[:, [3, 2]]).T * h**3 * unyt.Mpc**(-3))

    processed.associate_x(M,
                          scatter=None,
                          comoving=True,
                          description="Galaxy Stellar Mass")
    processed.associate_y(Phi,
                          scatter=Phi_err,
                          comoving=True,
                          description="Phi (GSMF)")
    processed.associate_redshift(sum(z) * 0.5, *z)
    processed.associate_plot_as(plot_as)

    return processed
Пример #12
0
    comment = (
        "Data obtained directly from Relano et al 2020, which uses",
        "A Chabrier et al (2003) IMF intrinsically.",
    )
    citation = f"{surv} (Relano et. al 2020)"
    bibcode = "10.1051/0004-6361/201937087"
    name = "Specific star formation rate - Grain Size Ratio Data"
    plot_as = "points"
    redshift = 0.02
    h = h_sim

    # Write everything
    processed = ObservationalData()
    processed.associate_x(
        M_star,
        scatter=None,
        comoving=True,
        description="Galaxy Specific Star Formation Rate",
    )
    processed.associate_y(S2L,
                          scatter=None,
                          comoving=True,
                          description="Galaxy Dust Grain Size Ratio")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift, 0, 0.5)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    output_path = f"{output_directory}/{output_filename}"
def cosmic_star_formation_history_true():

    # Meta-data
    name = f"Fit to true star formation rate history from Behroozi et al. (2019)"
    comment = (
        "The data is taken from https://www.peterbehroozi.com/data.html. "
        "The cosmic star formation rate is the true one. This means that no"
        "observational systematics (e.g., due to dust) are accounted for. "
        "Uses the Chabrier initial mass function. "
        "The scatter shows the 16th-84th percentile range from the posterior. "
        "Cosmology: Omega_m=0.307, Omega_lambda=0.693, h=0.678, sigma_8=0.823, "
        "n_s=0.96. "
        "Shows total true cosmic star formation rate (Msun/yr/Mpc^3) for "
        "the best-fitting model from Behroozi et al. (2019)")

    citation = "Behroozi et al. (2019) [True]"
    bibcode = "2019MNRAS.488.3143B"
    plot_as = "line"
    output_filename = "Behroozi2019_true.hdf5"
    output_directory = "../"

    # Create observational data instance
    processed = ObservationalData()
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_cosmology(cosmology)

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

    # Load raw Behroozi2019 data
    data = np.loadtxt(f"../raw/Behroozi2019_csfrs.dat")

    # Fetch the fields we need
    scale_factor = unyt.unyt_array(data[:, 0], units="dimensionless")
    SFR, SFR_plus, SFR_minus = data[:, 7], data[:, 9], data[:, 8]

    # Define scatter with respect to the best-fit value (16 and 84 percentiles)
    SFR_scatter = unyt.unyt_array((SFR_minus, SFR_plus),
                                  units="Msun/yr/Mpc**3")

    redshift, redshift_lower, redshift_upper = 5.0, 0.0, 10.0

    processed.associate_x(
        scale_factor,
        scatter=None,
        comoving=False,
        description="Cosmic scale factor",
    )
    processed.associate_y(
        SFR * SFR_scatter.units,
        scatter=SFR_scatter,
        comoving=False,
        description="Cosmic average star formation rate density",
    )

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

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

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

    processed.write(filename=output_path)
Пример #14
0
def KS(sigma_g, n, A):
    return A * sigma_g**n


Sigma_g = 10**array_of_interest
Sigma_star = KS(Sigma_g, 1.4, 1.515e-4)

Sigma_H2 = Sigma_g
Sigma_SFR = Sigma_star

SigmaH2 = unyt.unyt_array(Sigma_H2, units="Msun/pc**2")
SigmaSFR = unyt.unyt_array(Sigma_SFR, units="Msun/yr/kpc**2")

processed.associate_x(SigmaH2,
                      scatter=None,
                      comoving=False,
                      description="H2 Surface density")
processed.associate_y(
    SigmaSFR,
    scatter=None,
    comoving=False,
    description="Star Formation Rate Surface Density",
)

processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(0.0, 0.0, 0.0)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)
    "omegaL=0.7."
)
citation = "Moustakas et al. (2013) (SDSS)"
bibcode = "2013ApJ...767...50M"
name = "Galaxy Stellar Mass - Passive Fraction from SDSS"
plot_as = "points"
redshift = 0.1
h = cosmology.h

log_M = raw.T[2]
M = unyt.unyt_array(10 ** (log_M), units=unyt.Solar_Mass)
passive_frac = unyt.unyt_array(raw.T[4] / raw.T[3], units="dimensionless")


processed.associate_x(
    M, scatter=None, comoving=False, description="Galaxy Stellar Mass"
)
processed.associate_y(
    passive_frac, scatter=None, comoving=False, description="Passive Fraction"
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
    os.remove(output_path)
Пример #16
0
    # Meta-data
    comment = f"values for individual galaxies derived from {label} survey"
    citation = f"{label} compiled by De Looze et al. (2020)"
    bibcode = "2020MNRAS.496.3668D"
    name = "MHI/Mstar as a function of 12 + log10(O/H)"
    plot_as = "points"
    redshift = 0.0
    redshift_lower = 0.0
    redshift_upper = 3.0
    h = 0.7

    # Write everything
    outobj = ObservationalData()
    outobj.associate_x(
        oabundance_med,
        scatter=x_scatter,
        comoving=True,
        description="Gas phase 12 + log10(O/H)",
    )
    outobj.associate_y(
        logMHIMstar_med,
        scatter=y_scatter,
        comoving=True,
        description="HI mass to stellar mass ratio",
    )
    outobj.associate_citation(citation, bibcode)
    outobj.associate_name(name)
    outobj.associate_comment(comment)
    outobj.associate_redshift(redshift, redshift_lower, redshift_upper)
    outobj.associate_plot_as(plot_as)
    outobj.associate_cosmology(cosmology)
Пример #17
0
    if z < 2:
        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)
    units="Msun/yr/kpc**2",
)

array_x_bin_std_up = array_of_interest[1:] - binned_data[0]
array_x_bin_std_down = binned_data[0] - array_of_interest[:-1]

SigmaH2_err = unyt.unyt_array(
    [
        10**(binned_data[0]) - 10**(binned_data[0] - array_x_bin_std_down),
        10**(binned_data[0] + array_x_bin_std_up) - 10**(binned_data[0]),
    ],
    units="Msun/kpc**2",
)

processed.associate_x(SigmaH2,
                      scatter=SigmaH2_err,
                      comoving=False,
                      description="$\\Sigma_{\\rm H_2}$")

processed.associate_y(SigmaSFR,
                      scatter=SigmaSFR_err,
                      comoving=False,
                      description="$\\Sigma_{\\rm SFR}$")

processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(0.0, 0.0, 0.0)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

output_path = f"../Abdurrouf2022.hdf5"
Пример #19
0
y = unyt.unyt_array(OFe_zhang * unyt.dimensionless)

# Meta-data
comment = (
    "Solar abundances are taken from Asplund et al. (2009), "
    "[Fe/H]Sun = 7.5 and [Mg/H]Sun = 7.6"
)
citation = "Zhang & Zhao (2005), MW"
bibcode = "2005MNRAS.364..712Z"
name = "[O/Fe] as a function of [Fe/H]"
plot_as = "points"
redshift = 0.0

# Write everything
processed = ObservationalData()
processed.associate_x(x, scatter=None, comoving=False, description="[Fe/H]")
processed.associate_y(y, scatter=None, comoving=False, description="[O/Fe]")
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

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

processed.write(filename=output_path)
Пример #20
0
bibcode = "2018MNRAS.477....2J"
name = "HIMF from ALFALFA at z=0"
plot_as = "points"
redshift = 0.0
h = cosmology.h

M = 10**data[:, 0] * (h / ORIGINAL_H)**(-2) * unyt.Solar_Mass
Phi = 10**data[:, 1] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)

# no error in M_HI provided
M_err = np.row_stack([M * 0.0] * 2) * M.units
Phi_err = np.abs((10**data[:, [2, 3]] * (h / ORIGINAL_H)**3 * unyt.Mpc**(-3)) -
                 Phi[:, None]).T

processed.associate_x(M,
                      scatter=M_err,
                      comoving=True,
                      description="Galaxy HI Mass")
processed.associate_y(Phi,
                      scatter=Phi_err,
                      comoving=True,
                      description="Phi (HIMF)")
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
Пример #21
0
def cosmic_star_formation_history_novak():

    # Meta-data
    name = f"Star formation rate density from Novak et al. (2017)"
    comment = (
        "based on JVLA COSMOS radio observations at 3 GHz "
        "cosmology is H0=70, OmegaM=0.3, OmegaL=0.7 "
        "Uses a Chabrier IMF"
    )

    citation = "Novak et al. (2017)"
    bibcode = "2017A&A...602A...5N"
    plot_as = "points"
    output_filename = "Novak2017.hdf5"
    output_directory = "../"

    # Create observational data instance
    processed = ObservationalData()
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_cosmology(cosmology)

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

    # Load raw Novak2017 data
    data = np.loadtxt(f"../raw/sfr_novak2017.dat")

    # Fetch the fields we need
    z, delta_z_minus, delta_z_plus = data[:, 0], data[:, 1], data[:, 2]
    SFR, delta_SFR_minus, delta_SFR_plus = data[:, 3], data[:, 4], data[:, 5]

    a = 1.0 / (1.0 + z)
    # division turns large into small, so minus <-> plus
    a_minus = 1.0 / (1.0 + z + delta_z_plus)
    a_plus = 1.0 / (1.0 + z + delta_z_minus)
    delta_a_minus = a - a_minus
    delta_a_plus = a_plus - a

    a_bin = unyt.unyt_array(a, units="dimensionless")
    a_scatter = unyt.unyt_array((delta_a_minus, delta_a_plus), units="dimensionless")
    # convert from log10(SFRD) to SFRD and carry the uncertainties
    SFR_minus = 10.0 ** (SFR + delta_SFR_minus)
    SFR_plus = 10.0 ** (SFR + delta_SFR_plus)
    SFR = 10.0 ** SFR
    SFR_scatter = unyt.unyt_array(
        (SFR - SFR_minus, SFR_plus - SFR), units="Msun/yr/Mpc**3"
    )
    SFR = unyt.unyt_array(SFR, units="Msun/yr/Mpc**3")

    processed.associate_x(
        a_bin, scatter=a_scatter, comoving=False, description="Cosmic scale factor"
    )
    processed.associate_y(
        SFR,
        scatter=SFR_scatter,
        comoving=False,
        description="Cosmic average star formation rate density",
    )

    z_minus = (z + delta_z_minus).min()
    z_plus = (z + delta_z_plus).max()
    processed.associate_redshift(0.5 * (z_minus + z_plus), z_minus, z_plus)
    processed.associate_plot_as(plot_as)

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

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

    processed.write(filename=output_path)
Phi_HI = (phi_star / M_star) * np.exp(-M_HI / M_star) * (M_HI / M_star)**alpha
Phi_HI = Phi_HI * M_HI * np.log(10)

# Meta-data
comment = "Best-fit Schechter function to the data from 1000 galaxies"
citation = "Zwaan et al. (2003) (HIPASS)"
bibcode = "2003AJ....125.2842Z"
name = "HI mass function from the HIPASS survey"
plot_as = "line"
redshift = 0.0
h = 0.7

# Write everything
processed = ObservationalData()
processed.associate_x(M_HI,
                      scatter=None,
                      comoving=True,
                      description="HI masses")
processed.associate_y(Phi_HI,
                      scatter=None,
                      comoving=True,
                      description="Phi (M_HI)")
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
name = "Galaxy Stellar Mass-Galaxy Size EAGLE NoAGN (25 Mpc)"
plot_as = "points"
redshift = 0.100_639
h_obs = 0.7
h = cosmology.h

M = raw.T[0] * unyt.Solar_Mass
R = raw.T[1] * unyt.kpc

bins = unyt.unyt_array(np.logspace(8.5, 12, 20), units=unyt.Solar_Mass)

# Now bin the line
centers, median, deviation = binned_median_line(x=M, y=R, x_bins=bins)

processed.associate_x(
    centers, scatter=None, comoving=False, description="Galaxy Stellar Mass (30kpc, 3D)"
)
processed.associate_y(
    median,
    scatter=deviation,
    comoving=False,
    description="Galaxy Half-Mass Radius (whole subhalo, 3D)",
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

output_path = f"{output_directory}/{output_filename}"
Пример #24
0
comment = "Median data binned by oxygen abundance 12+log10(O/H)"
citation_comw = "Rémy-Ruyer et al. [data, MW] (2014)"
citation_coz = "Rémy-Ruyer et al. [data, Z] (2014)"
bibcode = "2014A&A...563A..31R"
name_comw = "Dust-to-gas ratio as a function of metallicity assuming X_CO,MW conversion"
name_coz = "Dust-to-gas ratio as a function of metallicity assuming X_CO,Z conversion"
plot_as = "points"
redshift = 0.0
redshift_lower = 0.0
redshift_upper = 3.0
h = 0.7

# Write everything
outobj_comw = ObservationalData()
outobj_comw.associate_x(oabundance,
                        scatter=None,
                        comoving=True,
                        description="Gas Phase 12 + log10(O/H)")
outobj_comw.associate_y(
    d2g_comw_med,
    scatter=y_scatter_comw,
    comoving=True,
    description="Dust-to-gas ratio (using X_CO,Z)",
)
outobj_comw.associate_citation(citation_comw, bibcode)
outobj_comw.associate_name(name_comw)
outobj_comw.associate_comment(comment)
outobj_comw.associate_redshift(redshift, redshift_lower, redshift_upper)
outobj_comw.associate_plot_as(plot_as)
outobj_comw.associate_cosmology(cosmology)

outobj_coz = copy.deepcopy(outobj_comw)
# Meta-data
comment = (
    "Model fitted to X-ray luminosity data combining Chandra, ROSAT and ASCA surveys."
    f"h-corrected for SWIFT using cosmology: {cosmology.name}. ")
citation = "Aird et al. (2015)"
bibcode = "2015MNRAS.451.1892A"
name = "Redshift - Black-hole Mass Accretion Rate Density relation"
plot_as = "line"
redshift = np.mean(z)
h = h_sim

# Write everything
processed = ObservationalData()
processed.associate_x(a,
                      scatter=None,
                      comoving=True,
                      description="Scale-factor")
processed.associate_y(BHARD,
                      scatter=None,
                      comoving=True,
                      description="Black-hole Accretion Rate Density")
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
Пример #26
0
y_scatter = unyt.unyt_array((M_BH - M_BH_low, M_BH_high - M_BH))

comment = ("Masses are provided h-free and cosmology-independent, so no "
           "h-correction made. "
           "Masses are (mostly) determined dynamically, with some stallar "
           "masses obtained from K-band luminosities with a fixed conversion "
           "factor. Halo masses are defined as M200_crit.")
citation = "Marasco et al. (2021)"
bibcode = "2021arXiv210510508M"
name = "Halo Mass-Black Hole Mass"
plot_as = "points"
redshift = 0.0
h = cosmology.h

processed.associate_x(M_halo,
                      scatter=x_scatter,
                      comoving=False,
                      description="Halo mass")
processed.associate_y(M_BH,
                      scatter=y_scatter,
                      comoving=False,
                      description="Black hole mass")
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
    if i < 3:
        x_vals = 10**tables[i][:, 0] * units[i]
    else:
        x_vals = tables[i][:, 0] * units[i]

    # no x err
    x_err = x_vals * 0.0

    fhi = 10**tables[i][:, 1] * unitless

    fhi_plus_err = (10**(tables[i][:, 1] + tables[i][:, 2]) * unitless) - fhi
    fhi_minus_err = fhi - (10**(tables[i][:, 1] - tables[i][:, 2]) * unitless)
    fhi_err = np.row_stack([fhi_minus_err, fhi_plus_err])

    processed.associate_x(x_vals,
                          scatter=x_err,
                          comoving=0,
                          description=labels[i])
    processed.associate_y(
        fhi,
        scatter=fhi_err,
        comoving=0,
        description="Average Galaxy HI to stellar fraction",
    )
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    output_path = f"{output_directory}/{output_filename.format(filetag[i])}"
# Meta-data
comment = (
    "Ionized gas out of 94 clusters combining Chandra, WISE and 2MASS. "
    "Data was corrected for the simulation's cosmology."
)
citation = "Lin et al. (2012; $z<0.25$ only)"
bibcode = "2012ApJ...745L...3L"
name = "Halo mass - Gas fraction relation from Chandra-observed clusters."
plot_as = "points"
redshift = 0.1
h = h_sim

# Write everything
processed = ObservationalData()
processed.associate_x(
    M_500, scatter=x_scatter, comoving=True, description="Halo mass (M_500)"
)
processed.associate_y(
    fb_500, scatter=y_scatter, comoving=True, description="Gas fraction (<R_500)"
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)

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

if os.path.exists(output_path):
    os.remove(output_path)
    processed = ObservationalData()

    # Take values from the 'Binning' method in Table 5 from Saintonge et al. (2017)
    if i != 2:
        x_vals = 10**tables[i][:, 4] * units[i]
    else:
        x_vals = tables[i][:, 4] * units[i]

    fh2 = 10**tables[i][:, 6] * unitless

    fh2_plus_err = (10**(tables[i][:, 6] + tables[i][:, 7]) * unitless) - fh2
    fh2_minus_err = fh2 - (10**(tables[i][:, 6] - tables[i][:, 7]) * unitless)
    fh2_err = np.row_stack([fh2_minus_err, fh2_plus_err])

    processed.associate_x(x_vals,
                          scatter=None,
                          comoving=False,
                          description=labels[i])
    processed.associate_y(fh2,
                          scatter=fh2_err,
                          comoving=False,
                          description="Average Galaxy H2 fraction")
    processed.associate_citation(citation, bibcode)
    processed.associate_name(name)
    processed.associate_comment(comment)
    processed.associate_redshift(redshift)
    processed.associate_plot_as(plot_as)
    processed.associate_cosmology(cosmology)

    output_path = f"{output_directory}/{output_filename.format(filetag[i])}"

    if os.path.exists(output_path):
Пример #30
0
comment = (
    "Fit obtained directly from paper using the smhmr module in "
    "velociraptor-python. No cosmology correction needed."
)
citation = "Moster et al. (2013)"
bibcode = "2013MNRAS.428.3121M"
name = "Fit to the stellar mass - stellar halo mass relation at z=0."
plot_as = "line"
redshift = 0.0
h = h_sim

# Write everything
processed = ObservationalData()
processed.associate_x(
    halo_masses * unyt.Solar_Mass,
    scatter=None,
    comoving=False,
    description="Halo Mass ($M_{200, {\rm crit}}$)",
)
processed.associate_y(
    stellar_masses * unyt.Solar_Mass,
    scatter=None,
    comoving=True,
    description="Galaxy Stellar Mass",
)
processed.associate_citation(citation, bibcode)
processed.associate_name(name)
processed.associate_comment(comment)
processed.associate_redshift(redshift)
processed.associate_plot_as(plot_as)
processed.associate_cosmology(cosmology)