name = "Cosmic Average Star Formation Rate Density" plot_as = "line" a = raw[:, 0] z = 1.0 / a - 1.0 SFR = 10.0**raw[:, 1] a = unyt.unyt_array(a, units=unyt.dimensionless) SFR = unyt.unyt_array(SFR, units=unyt.Msun / unyt.yr / unyt.Mpc**3) processed.associate_x(a, scatter=None, comoving=False, description="Cosmic scale factor") processed.associate_y( SFR, scatter=None, comoving=False, description="Cosmic average star formation rate density", ) processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) zmin = z.min() zmax = z.max() processed.associate_redshift(0.5 * (zmin + zmax), zmin, zmax) processed.associate_plot_as(plot_as) processed.associate_cosmology(cosmology) output_path = f"../FIREbox.hdf5" if os.path.exists(output_path): os.remove(output_path)
"The halo mass used is the 'virial' mass within a spherical region whose mean " "density is 200 times the critical density of the Universe today. " "Plotted is the stellar mass versus halo mass at z=0.") output_filename = "Read2017.hdf5" # Write everything processed = ObservationalData() processed.associate_x( M_halo, scatter=M_halo_scatter, comoving=False, description="Halo Mass ($M_{200, {\rm crit}}$)", ) processed.associate_y(M_star, scatter=M_star_scatter, comoving=False, description="Galaxy Stellar Mass") processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) processed.associate_redshift(redshift, redshift_lower, redshift_upper) 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)
SNIa_rate = ratenu * 1.0e-5 * (h / 0.7)**3 SNIa_err_m = -err_m * 1.0e-5 * (h / 0.7)**3 SNIa_err_p = err_p * 1.0e-5 * (h / 0.7)**3 a = unyt.unyt_array(a, units=unyt.dimensionless) SNIa_rate = unyt.unyt_array(SNIa_rate, units=1.0 / (unyt.yr * unyt.Mpc**3)) SNIa_scatter = unyt.unyt_array((SNIa_err_m, SNIa_err_p), units=1.0 / (unyt.yr * unyt.Mpc**3)) processed.associate_x(a, scatter=None, comoving=False, description="Cosmic scale factor") processed.associate_y( SNIa_rate, scatter=SNIa_scatter, comoving=False, description="Cosmic SNIa rate", ) processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) zmin = z.min() zmax = z.max() processed.associate_redshift(0.5 * (zmin + zmax), zmin, zmax) processed.associate_plot_as(plot_as) processed.associate_cosmology(cosmology) output_path = f"../Graur2011.hdf5" if os.path.exists(output_path): os.remove(output_path)
"There is also a correction to convert the metallicities to the 12+log10(O/H) convention." ) citation = "Lee et al. (2006)" bibcode = "2006ApJ...647..970L" name = "Stellar mass - Gas phase metallicity relation" plot_as = "points" redshift = 0.0 h = h_sim # Write everything processed = ObservationalData() processed.associate_x( M_star, scatter=None, comoving=True, description="Galaxy Stellar Mass" ) processed.associate_y( Z_median, scatter=y_scatter, comoving=True, description="Gas phase metallicity" ) 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)
Zmm = fitcurve(M_star, alpha - alpha_err, beta - beta_err) Z_max = np.maximum(np.maximum(Zpp, Zpm), np.maximum(Zmp, Zmm)) Z_min = np.minimum(np.minimum(Zpp, Zpm), np.minimum(Zmp, Zmm)) Z_scatter = unyt.unyt_array([Z - Z_min, Z_max - Z], units="dimensionless") Z = unyt.unyt_array(Z, units="dimensionless") # Write everything processed = ObservationalData() processed.associate_x(M_star, scatter=None, comoving=False, description="Galaxy Stellar Mass") processed.associate_y( Z, scatter=Z_scatter, comoving=False, description=f"Stellar metallicity ({label})", ) processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) processed.associate_redshift(redshift.mean(), *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)
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 / halo_masses) * unyt.dimensionless, scatter=None, comoving=True, description="Galaxy Stellar Mass / Halo Mass ($M_* / M_{200, {\rm crit}}$)", ) 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)
redshift = 0.0 Fe_over_H_Asplund09 = 7.50 Mstar = 10.0**raw[:, 0] metal = 10.0**(raw[:, 1] - Fe_over_H_Asplund09) Mstar = unyt.unyt_array(Mstar, units=unyt.Msun) metal = unyt.unyt_array(metal, units=unyt.dimensionless) processed.associate_x(Mstar, scatter=None, comoving=False, description="Galaxy Stellar Mass") processed.associate_y( metal, scatter=None, comoving=False, description="Galaxy Stellar Metallicity (3 kpc aperture)", ) 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"../FIREbox.hdf5" if os.path.exists(output_path): os.remove(output_path) processed.write(filename=output_path)
y_scatter = unyt.unyt_array( (M_star_ratio_50 - M_star_ratio_16, M_star_ratio_84 - M_star_ratio_50) ) # A fitting function gives us the data at any z. Hence, no need to have \Delta z redshift_lower, redshift_upper = [z, z] processed.associate_x( M_halo, scatter=None, comoving=True, description=f"Halo Mass ({latex_name:s})", ) processed.associate_y( M_star_ratio_50, scatter=y_scatter, comoving=True, description="Galaxy Stellar Mass (30kpc, 3D) / Halo Mass ({latex_name:s})", ) 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)
bibcode = "2018A&A...609A..37C" name = "Neutral Gas Mass - Dust Mass data" plot_as = "points" redshift = 0.02 h = h_sim x_scatter = unyt.unyt_array([M_nerr, M_nerr]) y_scatter = unyt.unyt_array([M_derr, M_derr]) # Write everything processed = ObservationalData() processed.associate_x( M_neut, scatter=x_scatter, comoving=True, description="Galaxy Star Formation Rate" ) processed.associate_y( M_dust, scatter=y_scatter, comoving=True, description="Galaxy Neutral Gas Mass" ) 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_werr}" if os.path.exists(output_path): os.remove(output_path) processed.write(filename=output_path)
redshift = 0.0 redshift_lower = 0.0 redshift_upper = 3.0 h = 0.7 # Write everything outobj = ObservationalData() outobj.associate_x( logD2S_med, scatter=x_scatter, comoving=True, description="Gas phase dust-to-stellar mass ratio", ) 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)
citation = "NGC6822 (Gratier et al. 2010)" bibcode = "2010A&A...512A..68G" name = "Stellar mass - H2 Gas to Stellar Mass ratio" plot_as = "points" redshift = 0.0 h = h_sim # Write everything processed = ObservationalData() processed.associate_x(M_star, scatter=None, comoving=True, description="Galaxy Stellar Mass") processed.associate_y( MH2_p_Mstar, scatter=None, comoving=True, description="Stellar mass - H2 Gas to Stellar Mass ratio", ) processed.associate_citation(citation, bibcode) processed.associate_name(name) processed.associate_comment(comment) processed.associate_redshift(redshift, 0, 2) 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)
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)
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 = ( "Pozzi et al. (2020), Figure 5. Obtained using Herschel+GAMA" "data, and derived using the MAGPHYS SED fitting package." f"h-corrected for SWIFT using Cosmology: {cosmology.name}." ) citation = "Pozzi et al. (2020)" bibcode = "2020MNRAS.491.5073P" name = "GDMF from Herschel+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
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/pc**2", ) processed.associate_x(SigmaH2, scatter=SigmaH2_err, comoving=False, description="H2 Surface density") processed.associate_y( SigmaSFR, scatter=SigmaSFR_err, 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) output_path = f"../Querejeta2021.hdf5" if os.path.exists(output_path): os.remove(output_path)
def cddf_noterdaeme(): # Meta-data name = f"CDDF from Noterdaeme et al. (2012)" comment = "" citation = "Noterdaeme et al. (2012)" bibcode = "2012A&A...547L...1N" plot_as = "points" output_filename = "Noterdaeme2012.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_Noterdaeme2012.dat") # Fetch the fields we need logNHI_minus = data[:, 0] logNHI_plus = data[:, 1] f_NHI = 10.0**data[:, 2] f_NHI_minus = 10.0**(data[:, 2] - data[:, 4]) f_NHI_plus = 10.0**(data[:, 2] + data[:, 4]) 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 = 3.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)