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 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
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, 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
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
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)
# 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) output_path = f"{output_directory}/{output_filename}" if os.path.exists(output_path): os.remove(output_path) outobj.write(filename=output_path) # Also output median and scatter points for composite sample x_all = np.hstack(x_all) * unyt.dimensionless y_all = np.hstack(y_all) * unyt.dimensionless
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) outobj_coz.associate_y( d2g_coz_med, scatter=y_scatter_coz, comoving=True, description="Dust-to-gas ratio (using X_CO,Z)", ) outobj_comw.associate_citation(citation_coz, bibcode) outobj_coz.associate_name(name_coz)
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)
def cddf_ho(): # Meta-data name = f"CDDF from Ho et al. (2021)" comment = "" citation = "Ho et al. (2021)" bibcode = "2021MNRAS.507..704H" plot_as = "points" output_filename = "Ho2021.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 data data = np.loadtxt(f"../raw/cddf_Ho2021.dat") # Fetch the fields we need logNHI_minus = data[:, 0] logNHI_plus = data[:, 1] # add pre-factor 10^{-21} f_NHI = data[:, 2] * 1.0e-21 f_NHI_minus = data[:, 3] * 1.0e-21 f_NHI_plus = data[:, 4] * 1.0e-21 logNHI = 0.5 * (logNHI_minus + logNHI_plus) dlogNHI = logNHI_plus - logNHI_minus dNHI = 10.0**logNHI_plus - 10.0**logNHI_minus # convert from d/dN to d/dlogN f_NHI *= dNHI / dlogNHI f_NHI_minus *= dNHI / dlogNHI f_NHI_plus *= dNHI / dlogNHI NHI_bin = unyt.unyt_array(10.0**logNHI, units="cm**(-2)") NHI_scatter = unyt.unyt_array( (10.0**logNHI - 10.0**logNHI_minus, 10.0**logNHI_plus - 10.0**logNHI), units="cm**(-2)", ) f_NHI_bin = unyt.unyt_array(f_NHI, units="dimensionless") f_NHI_scatter = unyt.unyt_array((f_NHI - f_NHI_minus, f_NHI_plus - f_NHI), units="dimensionless") processed.associate_x(NHI_bin, scatter=NHI_scatter, comoving=False, description="Column density") processed.associate_y( f_NHI_bin, scatter=f_NHI_scatter, comoving=False, description="Column density distribution function", ) z_minus = 2.0 z_plus = 5.0 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)
def cosmic_star_formation_history_enia(): # Meta-data name = f"Star formation rate density from Enia et al. (2022)" comment = ("Uses the Chabrier initial mass function. " "Cosmology: Planck 2016: H0=67.8, OmegaM=0.308.") citation = "Enia et al. (2022)" bibcode = "2022arXiv220200019E" plot_as = "points" output_filename = "Enia2022.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 Enia2022 data data = np.loadtxt(f"../raw/sfr_enia2022.dat") # Fetch the fields we need z_minus, z_plus = data[:, 0], data[:, 1] SFR, SFR_stderr = data[:, 2], data[:, 3] # Enia (2022) fig. 10 uses specific values for z in each bin, but does not # explicitly list those in their table 4. We simply use the middle of each # bin. z = 0.5 * (z_minus + z_plus) a = 1.0 / (1.0 + z) a_minus = 1.0 / (1.0 + z_plus) a_plus = 1.0 / (1.0 + z_minus) a_bin = unyt.unyt_array(a, units="dimensionless") a_scatter = unyt.unyt_array((a - a_minus, a_plus - a), units="dimensionless") # convert from log10(SFRD) to SFRD and carry the uncertainties SFR_minus = 10.0**(SFR - SFR_stderr) SFR_plus = 10.0**(SFR + SFR_stderr) 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_minus.min() z_plus = 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)
redshift_distant = 2.0 redshift_local = 0.0 h = h_sim # Write distant processed_distant = ObservationalData() processed_distant.associate_x(oabundance, scatter=None, comoving=False, description="[O/H]") processed_distant.associate_y(d2g_distant, scatter=None, comoving=False, description="Dust-to-Gas Ratio") processed_distant.associate_citation(citation_distant, bibcode) processed_distant.associate_name(name_distant) processed_distant.associate_comment(comment) processed_distant.associate_redshift(redshift_distant, 0.5, 5.5) processed_distant.associate_plot_as(plot_as) processed_distant.associate_cosmology(cosmology) output_path = f"{output_directory}/{output_filename_distant}" if os.path.exists(output_path): os.remove(output_path) processed_distant.write(filename=output_path) # Write local processed_local = ObservationalData() processed_local.associate_x(oabundance,
def cddf_berg(): # Meta-data comment = "" bibcode = "2019MNRAS.488.4356B" plot_as = "points" output_directory = "../" for dataset in ["subDLA", "DLA"]: output_filename = f"Berg2019_{dataset}.hdf5" citation = f"Berg et al. (2019) - {dataset}s" name = f"CDDF from Berg et al. (2019) - {dataset}s" # 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 data data = np.loadtxt(f"../raw/cddf_Berg2019_{dataset}.dat") # Fetch the fields we need logNHI = data[:, 0] f_NHI = data[:, 3] f_NHI_minus = data[:, 2] f_NHI_plus = data[:, 4] # create NHI bins from the given values # for each interval in log space, we assign half to the lower bin and # half to the upper bin. We further assume that the lowest and highest # bin are symmetric (in log space) around the central value logNHI_plus = np.zeros(logNHI.shape) logNHI_minus = np.zeros(logNHI.shape) logNHI_plus[:-1] = 0.5 * (logNHI[1:] + logNHI[:-1]) logNHI_minus[1:] = 0.5 * (logNHI[1:] + logNHI[:-1]) logNHI_plus[-1] = 2.0 * logNHI[-1] - logNHI_minus[-1] logNHI_minus[0] = 2.0 * logNHI[0] - logNHI_plus[0] dlogNHI = logNHI_plus - logNHI_minus dNHI = 10.0**logNHI_plus - 10.0**logNHI_minus # convert from d/dN to d/dlogN f_NHI *= dNHI / dlogNHI f_NHI_minus *= dNHI / dlogNHI f_NHI_plus *= dNHI / dlogNHI NHI_bin = unyt.unyt_array(10.0**logNHI, units="cm**(-2)") NHI_scatter = unyt.unyt_array( ( 10.0**logNHI - 10.0**logNHI_minus, 10.0**logNHI_plus - 10.0**logNHI, ), units="cm**(-2)", ) f_NHI_bin = unyt.unyt_array(f_NHI, units="dimensionless") f_NHI_scatter = unyt.unyt_array( (f_NHI - f_NHI_minus, f_NHI_plus - f_NHI), units="dimensionless") processed.associate_x(NHI_bin, scatter=NHI_scatter, comoving=False, description="Column density") processed.associate_y( f_NHI_bin, scatter=f_NHI_scatter, comoving=False, description="Column density distribution function", ) z_minus = 2.3 z_plus = 3.2 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)
def cosmic_star_formation_history_gruppioni(): # Meta-data name = f"Star formation rate density from Gruppioni et al. (2020)" comment = ("Uses the Chabrier initial mass function. " "Cosmology: H0=70, OmegaM=0.3, OmegaL=0.7") citation = "Gruppioni et al. (2020)" bibcode = "2020A&A...643A...8G" plot_as = "points" output_filename = "Gruppioni2020.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 Gruppioni2020 data data = np.loadtxt(f"../raw/sfr_gruppioni2020.dat") # Fetch the fields we need z_minus, z_plus = data[:, 0], data[:, 1] SFR, SFR_min, SFR_max = data[:, 2], data[:, 3], data[:, 4] z = 0.5 * (z_minus + z_plus) a = 1.0 / (1.0 + z) a_minus = 1.0 / (1.0 + z_plus) a_plus = 1.0 / (1.0 + z_minus) a_bin = unyt.unyt_array(a, units="dimensionless") a_scatter = unyt.unyt_array((a - a_minus, a_plus - a), units="dimensionless") SFR_scatter = unyt.unyt_array((SFR - SFR_min, SFR_max - 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_minus.min() z_plus = 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)
def cddf_zwaan(): # Meta-data name = f"CDDF fit from Zwaan et al. (2005)" comment = "" citation = "Zwaan et al. (2005)" bibcode = "2005MNRAS.364.1467Z" plot_as = "line" output_filename = "Zwaan2005.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) # Fit parameters (equation 3 in the paper) NHI_star = 10.0**21.2 f_star = 0.0193 beta = 1.24 logNHI = np.linspace(19.8, 22.1, 100) dlogNHI = logNHI[1] - logNHI[0] logNHI_minus = logNHI - 0.5 * dlogNHI logNHI_plus = logNHI + 0.5 * dlogNHI dlogNHI = logNHI_plus - logNHI_minus dNHI = 10.0**logNHI_plus - 10.0**logNHI_minus NHI = 10.0**logNHI f_NHI = (f_star / NHI_star) * (NHI_star / NHI)**beta * np.exp( -NHI / NHI_star) # convert from d/dN to d/dlogN f_NHI *= dNHI / dlogNHI NHI_bin = unyt.unyt_array(NHI, units="cm**(-2)") NHI_scatter = unyt.unyt_array( (NHI - 10.0**logNHI_minus, 10.0**logNHI_plus - NHI), units="cm**(-2)", ) f_NHI_bin = unyt.unyt_array(f_NHI, units="dimensionless") processed.associate_x(NHI_bin, scatter=NHI_scatter, comoving=False, description="Column density") processed.associate_y( f_NHI_bin, scatter=None, comoving=False, description="Column density distribution function", ) z_minus = 0.0 z_plus = 0.0 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)
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): os.remove(output_path) processed.write(filename=output_path)
def cddf_kim(): # Meta-data name = f"CDDF from Kim et al. (2013)" comment = "" citation = "Kim et al. (2013)" bibcode = "2013A&A...552A..77K" plot_as = "points" 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 data data = np.loadtxt(f"../raw/cddf_Kim2013.dat") # Fetch the fields we need logNHI = data[:, 0] # create NHI bins from the given values # for each interval in log space, we assign half to the lower bin and # half to the upper bin. We further assume that the lowest and highest # bin are symmetric (in log space) around the central value logNHI_plus = np.zeros(logNHI.shape) logNHI_minus = np.zeros(logNHI.shape) logNHI_plus[:-1] = 0.5 * (logNHI[1:] + logNHI[:-1]) logNHI_minus[1:] = 0.5 * (logNHI[1:] + logNHI[:-1]) logNHI_plus[-1] = 2.0 * logNHI[-1] - logNHI_minus[-1] logNHI_minus[0] = 2.0 * logNHI[0] - logNHI_plus[0] dlogNHI = logNHI_plus - logNHI_minus dNHI = 10.0**logNHI_plus - 10.0**logNHI_minus for zm, zp, ofs in zip([1.9, 1.9, 2.4], [3.2, 2.4, 3.2], [1, 4, 7]): output_filename = f"Kim2013_z{zm:.1f}_{zp:.1f}.hdf5" f_NHI = data[:, ofs] # mask out empty rows mask = f_NHI < 0 f_NHI_plus = data[:, ofs + 1] f_NHI_minus = data[:, ofs + 2] # if Delta(f)_minus is not gives, assume the same as Delta(f)_plus f_NHI_minus[f_NHI_minus == 0] = f_NHI_plus[f_NHI_minus == 0] f_NHI_plus = 10.0**(f_NHI + f_NHI_plus) f_NHI_minus = 10.0**(f_NHI - f_NHI_minus) f_NHI = 10.0**f_NHI # convert from d/dN to d/dlogN f_NHI *= dNHI / dlogNHI f_NHI_minus *= dNHI / dlogNHI f_NHI_plus *= dNHI / dlogNHI NHI_bin = unyt.unyt_array(10.0**logNHI[mask], units="cm**(-2)") NHI_scatter = unyt.unyt_array( ( 10.0**logNHI[mask] - 10.0**logNHI_minus[mask], 10.0**logNHI_plus[mask] - 10.0**logNHI[mask], ), units="cm**(-2)", ) f_NHI_bin = unyt.unyt_array(f_NHI[mask], units="dimensionless") f_NHI_scatter = unyt.unyt_array( (f_NHI[mask] - f_NHI_minus[mask], f_NHI_plus[mask] - f_NHI[mask]), units="dimensionless", ) processed.associate_x(NHI_bin, scatter=NHI_scatter, comoving=False, description="Column density") processed.associate_y( f_NHI_bin, scatter=f_NHI_scatter, comoving=False, description="Column density distribution function", ) z_minus = zm z_plus = zp 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)