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 = f"Schaye2015_Ref_100_{f'{halo:s}'}_RatioStellar.hdf5" output_directory = "../" if not os.path.exists(output_directory): os.mkdir(output_directory) for z in redshifts: # Create a single observational-data instance at redshift z processed = ObservationalData() if not os.path.exists(output_directory): os.mkdir(output_directory) data = np.loadtxt( f"../raw/EAGLE_SMHM_{f'{halo:s}'}_ratio_stellar_L100N1504_{f'z{z:03.1f}'.replace('.', 'p')}.txt" ) M_star = unyt.unyt_array(data[:, 0], units=unyt.Solar_Mass) M_star_ratio_16 = unyt.unyt_array(data[:, 1], units=unyt.dimensionless) M_star_ratio_50 = unyt.unyt_array(data[:, 2], units=unyt.dimensionless) M_star_ratio_84 = unyt.unyt_array(data[:, 3], units=unyt.dimensionless) # Define the scatter as offset from the mean value y_scatter = unyt.unyt_array((M_star_ratio_50 - M_star_ratio_16,
# Read densities rho_Z_gas = unyt.unyt_array(raw[:, 2], "Msun") rho_Z_gas /= unyt.unyt_quantity(100.0, "Mpc")**3 # Meta-data comment = ("Data obtained summing up all the gas particles in the snapshots. " "No cosmology correction needed.") citation = "Schaye et al. (2015) (EAGLE)" bibcode = "2015MNRAS..446..521S" name = "Gas phase metal mass density obtained from the Ref EAGLE model" redshift = np.mean(z) plot_as = "points" # Write everything processed = ObservationalData() processed.associate_x(a, scatter=None, comoving=True, description="Scale-factor") processed.associate_y(rho_Z_gas, scatter=None, comoving=True, description="Gas Phase Metal Mass 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) processed.associate_redshift(redshift, np.min(redshift), np.max(redshift))
# Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) # Cosmologies h_obs = 0.7 h_sim = cosmology.h output_filename = "Driver2021FLAMINGOBias.hdf5" output_directory = "../" if not os.path.exists(output_directory): os.mkdir(output_directory) processed = ObservationalData() # Table 5 log10_Mstar = np.array([ 6.875, 7.125, 7.375, 7.625, 7.875, 8.125, 8.375, 8.625, 8.875, 9.125, 9.375, 9.625,
import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = "../raw/Gilbank2010.txt" delimiter = None output_filename = "Gilbank2010.hdf5" output_directory = "../" if not os.path.exists(output_directory): os.mkdir(output_directory) processed = ObservationalData() raw = np.loadtxt(input_filename, delimiter=delimiter) comment = ( "Assuming Kroupa IMF. z=0.01 - 0.2. No h-correction " "was required as data was supplied h-free. " "Adopts cosmological parameters of h=0.7, omega0=0.3 " "omegaL=0.7." ) citation = "Gilbank et al. (2010) (SDSS)" bibcode = "2010MNRAS.405.2594G" name = "Galaxy Stellar Mass - Passive Fraction from SDSS" plot_as = "points" redshift = 0.1 h = cosmology.h
statistic=lambda x: np.percentile(x, 16.0), bins=array_x_bin) y_array_bin_std_up = y_array_bin_std_up - y_array_bin y_array_bin_std_down = y_array_bin - y_array_bin_std_down return array_x_bin_centres, y_array_bin, y_array_bin_std_down, y_array_bin_std_up # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = f"../raw/Abdurrouf2022_neutralgas.txt" processed = ObservationalData() comment = "Based on the Things and Heracles data" citation = "Abdurro'uf et al. (2022)" bibcode = "2022arXiv220708382A" name = "Spatially-resolved $\\Sigma_{\\rm HI+H_2}$ vs $\\Sigma_{\\rm SFR}$" plot_as = "points" # Reading the Abdurro'uf 2022 data array_of_interest = np.arange(-1, 3, 0.25) + 6.0 minimum_surface_density = 6.5 # in their paper this seems to be the limit they can observe, however they do not say anything about this array_of_interest = array_of_interest[ array_of_interest >= minimum_surface_density] if array_of_interest[0] > minimum_surface_density: array_of_interest = np.append([minimum_surface_density], array_of_interest)
# We purposely make this data show up not only a z=0 but also at higher z redshift_lower, redshift_upper = 5.0, 7.0 h = h_sim # stellar mass versus halo mass comment = ( "Measurements of stellar mass-halo mass relation from the entire mass " "of stars within each halo." "Cosmology: Planck 2015 (un-corrected). " "The data is extracted by hand from Fig. 4, and is a mean not median. " ) output_filename = "Rosdahl2022.hdf5" # Write everything processed = ObservationalData() processed.associate_x( M_halo, scatter=None, comoving=False, description="Halo Mass ($M_{\\rm vir}$)", ) processed.associate_y( M_star, scatter=None, comoving=False, description="Subhalo 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)
bibcode = "2012MNRAS.427.3244D" name = "Luminosity functions in the ugrizYJHK bands from the GAMA survey. Single-Schechter fits to the data." plot_as = "line" redshift = 0.1 h = h_sim for i in range(len(bands)): M = np.linspace(min_M[i], max_M[i], 256) arg = 0.4 * (M_star[i] - M) Phi = (unyt.Mpc**(-3) * 0.4 * np.log(10) * phi_star[i] * ((10.0**arg)**(1.0 + alpha[i])) * np.exp(-(10.0**arg))) M = unyt.unyt_array(M, "dimensionless") # Write everything processed = ObservationalData() processed.associate_x(M, scatter=None, comoving=True, description="Magnitudes %s-band" % bands[i]) processed.associate_y(Phi, scatter=None, comoving=True, description="Phi (M)") 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)
"from Salpeter to Chabrier IMF and using h=0.7324 (Clark+18). " f"h-corrected for SWIFT using cosmology: {cosmology.name}. " "Values obtained using the CIGALE code (see Bianchi+18)", ) citation = "Dustpedia + CIGALE (Bianchi et. al 2018)" bibcode = "2018A&A...609A..37C" name = "Stellar mass - Dust Mass data" plot_as = "points" redshift = 0.02 h = h_sim x_scatter = unyt.unyt_array([M_serr, M_serr]) y_scatter = unyt.unyt_array([M_derr, M_derr]) # Write everything processed = ObservationalData() processed.associate_x(M_star, scatter=x_scatter, comoving=True, description="Galaxy Stellar Mass") processed.associate_y(M_dust, scatter=y_scatter, comoving=True, description="Galaxy Dust 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)
from velociraptor.observations.objects import ObservationalData import unyt import numpy as np import os import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = f"../raw/FIREbox_z0.txt" processed = ObservationalData() raw = np.loadtxt(input_filename) comment = "Showing all central galaxies, using a 10 kpc aperture. The FIREbox results have been multiplied with 1.36 to take into account the contribution from Helium, as is done in observations." citation = f"Feldmann et al. (2022, FIREbox)" bibcode = "2022arXiv220515325F" name = f"Galaxy Stellar Mass - H2 mass fraction (FIREbox)" plot_as = "line" redshift = 0.0 Mstar = 10.0**raw[:, 0] MH2 = 10.0**raw[:, 1] # add Helium correction MH2 *= 1.36 H2frac = MH2 / Mstar Mstar = unyt.unyt_array(Mstar, units=unyt.Msun) H2frac = unyt.unyt_array(H2frac, units=unyt.dimensionless)
from velociraptor.observations.objects import ObservationalData import unyt import numpy as np import os import sys import matplotlib.pyplot as plt # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) processed = ObservationalData() comment = "galaxy-averaged" citation = "Kennicutt et al. (1998)" bibcode = "1998ApJ...498..541K" name = ( "galaxy-averaged H2+HI Gas Surface Density vs Star Formation Rate Surface Density" ) plot_as = "line" # Reading the Kennicutt 1998 data array_of_interest = np.arange(1, 3 + 0.25, 0.25) def KS(sigma_g, n, A): return A * sigma_g**n
data = np.loadtxt("../raw/HMF_Colossus.txt") M_200 = unyt.unyt_array(data[:, 0], units=unyt.Solar_Mass) Phi = unyt.unyt_array(data[:, 1], units=unyt.Mpc**(-3)) comment = ("Halo mass functions at z=0 from the colossus package (Diemer+18) " "assuming a 'planck13' cosmology. " "Corrected to h-free units and dn/dlog10(M) (from dn/dln(M)).") citation = "Tinker et al. (2008)" bibcode = "2008ApJ...688..709T" name = "Halo mass function fit to simulations" plot_as = "line" redshift = 0.0 h = 0.6777 processed = ObservationalData() processed.associate_x(M_200, scatter=None, comoving=True, description="Halo Mass") processed.associate_y(Phi, scatter=None, comoving=True, description="Phi (HMF)") 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)
x_scatter = unyt.unyt_array( (oabundance_med - oabundance_lo, oabundance_hi - oabundance_med)) # 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)
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)
comment = ( "Oxygen-based gas metallicity versus stellar mass for 472 star-forming galaxies " "extracted from the SAMI Galaxy Survey. " "Data obtained assuming a Chabrier IMF and h=0.704. " "The R-calibration of Pilyugin & Grebel (2016) was employed to determine oxygen abundances. " "The metallicity is expressed as 12 + log10(O/H). In these units the solar metallicity is 8.69." ) citation = "Fraser-McKelvie et al. (2021)" bibcode = " 2021MNRAS.tmp.3132F" name = "Stellar mass - gas phase metallicity relation " plot_as = "points" redshift = 0.1 h = h_sim # Write everything processed = ObservationalData() processed.associate_x( Mstar_arr, scatter=None, comoving=True, description="Galaxy Stellar Mass" ) processed.associate_y( Zgas_arr, scatter=None, 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}"
from velociraptor.observations.objects import ObservationalData import unyt import numpy as np import os import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = "../raw/Frohmaier2019.dat" processed = ObservationalData() raw = np.loadtxt(input_filename) comment = "Based on the Palomar Transient Factory survey." citation = "Frohmaier et al. (2019)" bibcode = "2019MNRAS.486.2308F" name = "Cosmic SNIa rate" plot_as = "points" z = raw[0] ratenu = raw[1] sys_err_p = raw[2] sys_err_m = raw[3] stat = raw[4] h = cosmology.h a = 1.0 / (1.0 + z)
# Build scatter x_scatter = unyt.unyt_array((a - a_lo, a_hi - a)) y_scatter = unyt.unyt_array((rho_star - rho_star_lo, rho_star_hi - rho_star)) # Meta-data comment = ("Data obtained assuming a Chabrier IMF and h = 0.7. " "Objects with stellar mass > 10^8 Msun are considered. " f"h-corrected for SWIFT using cosmology: {cosmology.name}. ") citation = "Muzzin et al. (2013) (COSMOS)" bibcode = "2013ApJ...777...18M" name = "Stellar mass density obtained intagrating the GSMF from COSMOS/ultraVISTA." redshift = np.mean(z) plot_as = "points" # Write everything processed = ObservationalData() processed.associate_x(a, scatter=x_scatter, comoving=True, description="Scale-factor") processed.associate_y(rho_star, scatter=y_scatter, comoving=True, description="Stellar Mass 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)
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 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
comment = ( "Fit obtained directly from Peter Behroozi's webpage. " "Stellar Masses: Chabrier IMF, BC03 SPS model, Blanton et al. dust model (i.e., kcorrect)." "Cosmology: Omega_m = 0.27, ns = 0.95, Omega_b = 0.046, sigma_8 = 0.82, h = 0.7." "No cosmology correction needed. " "Halo masses have been corrected from M_vir to M_200_cr." "Shows the relation between stellar mass and halo mass.") citation = "Behroozi et al. (2013)" bibcode = "2013ApJ...770...57B" name = "Fit to the stellar mass - halo mass relation at z=0." plot_as = "line" redshift = 0.0 h = h_sim # Write everything processed = ObservationalData() processed.associate_x(M_200, scatter=None, comoving=True, description="Halo Mass ($M_{200, {\rm crit}}$)") processed.associate_y(M_star, 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)
input_filename = { "H": "../raw/Lange2015HBand.txt", "r": "../raw/Lange2015rBand.txt" } delimiter = None half_mass = 1 log_mass = 0 output_filename = {"H": "Lange2015HBand.hdf5", "r": "Lange2015rBand.hdf5"} output_directory = "../" if not os.path.exists(output_directory): os.mkdir(output_directory) for band in ["r", "H"]: processed = ObservationalData() raw = np.loadtxt(input_filename[band], delimiter=delimiter) comment = ( "Assuming Chabrier IMF (2003), assumes a standard LCDM cosmology with " "H=70 km/s/Mpc and O_lambda=0.7. Provided h-free so no h-correction made. " f"This data is for the {band}-band only.") citation = f"Lange et al. (2015, {band}-band)" bibcode = "2015MNRAS.447.2603L" name = "Galaxy Stellar Mass-Galaxy Size" plot_as = "points" redshift = 0.05 h_obs = 0.7 h = cosmology.h half_mass = 10**(raw.T[1]) * unyt.kpc
y_scatter = unyt.unyt_array((error_fb_500_m, error_fb_500_p)) # Meta-data comment = ( "Gas fraction data by taking the median for a large set of HSE data. " "This is the HSE calibration data for FLAMINGO. Includes fiducial bias. " "Data was corrected for the simulation's cosmology.") citation = "FLAMINGO HSE Data" bibcode = " Personal collection" name = "HSE Gas Fractions" plot_as = "points" redshift = 0.1 h = h_sim # Write everything processed = ObservationalData() processed.associate_x(M_500, scatter=None, 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)
halo_masses = np.logspace(4, 16, 512) stellar_masses = moster_raw(0.0, halo_masses) # Meta-data comment = ("Fit obtained directly from paper using the smhmr module in " "velociraptor-python. No cosmology correction needed. " "Shows the ratio betweeen stellar mass and halo mass") 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 / 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)
# Meta-data comment = ( "Stellar Masses obtained assuming a Chabrier (2003) IMF. " "local measurements decoupled from the Hubble flow (no h)." "H2 measurements via CO detection from NGVS." ) citation = "VCC2062 (Lisenfeld et al. 2016)" bibcode = "2016A&A...590A..92L" 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=x_scatter, comoving=True, description="Galaxy Stellar Mass" ) processed.associate_y( MH2_p_Mstar, scatter=y_scatter, 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)
from velociraptor.observations.objects import ObservationalData import unyt import numpy as np import os import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = "../raw/FIREbox.txt" processed = ObservationalData() raw = np.loadtxt(input_filename) comment = "Includes all gas in the simulation." citation = "Feldmann et al. (2022, FIREbox)" bibcode = "2022arXiv220515325F" name = "HI Mass Cosmic History (FIREbox)" plot_as = "line" a = raw[:, 0] z = 1.0 / a - 1.0 rhoHI = 10.0**raw[:, 1] a = unyt.unyt_array(a, units=unyt.dimensionless) rhoHI = unyt.unyt_array(rhoHI, units=unyt.Msun / unyt.Mpc**3) processed.associate_x(a, scatter=None, comoving=False,
from velociraptor.observations.objects import ObservationalData import unyt import numpy as np import os import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = f"../raw/FIREbox_z0.txt" processed = ObservationalData() raw = np.loadtxt(input_filename) comment = "Showing all galaxies, using a 3 kpc aperture. The gas metallicity is shown as 12 + log10(O/H)." citation = f"Feldmann et al. (2022, FIREbox)" bibcode = "2022arXiv220515325F" name = f"Galaxy Stellar Mass - Gas Metallicity (FIREbox)" plot_as = "line" redshift = 0.0 Mstar = 10.0**raw[:, 0] metal = raw[:, 1] Mstar = unyt.unyt_array(Mstar, units=unyt.Msun) metal = unyt.unyt_array(metal, units=unyt.dimensionless) processed.associate_x(Mstar, scatter=None, comoving=False,
units = [ pow(h / ORIGINAL_H, -2) * unyt.Solar_Mass, unyt.Solar_Mass * pow(unyt.kpc, -2), pow(unyt.yr, -1), ] labels = [ "Galaxy Stellar Mass", "Galaxy Central Stellar Surface density", "Galaxy Specific Star Formation Rate", ] filetag = ["abcissa_M_star", "abcissa_mu_star", "abcissa_sSFR"] for i in range(len(tables)): processed = ObservationalData() x_vals = 10**tables[i][:, 0] * units[i] fneut = 10**tables[i][:, 1] * unitless log10_fh2 = np.interp( tables[i][:, 0], tables_h2[i][:, 0], tables_h2[i][:, 2], tables_h2[i][0, 2], tables_h2[i][-1, 2], ) fh2 = 10**log10_fh2 * unitless fgas = fh2 / fneut
import sys # Exec the master cosmology file passed as first argument with open(sys.argv[1], "r") as handle: exec(handle.read()) input_filename = "../raw/LiWhite2009.txt" delimiter = None output_filename = "LiWhite2009.hdf5" output_directory = "../" if not os.path.exists(output_directory): os.mkdir(output_directory) processed = ObservationalData() raw = np.loadtxt(input_filename, delimiter=delimiter) comment = ("Note stellar mass here is Msun/h^2. Converted. Poisson errors. " f"h-corrected for SWIFT using cosmology: {cosmology.name}.") citation = "Li and White (2009)" bibcode = "2009MNRAS.398.2177L" name = "GSMF from SDSS DR7" plot_as = "points" redshift = 0.07 h = cosmology.h log_M = raw.T[0] M = 10**(log_M) * unyt.Solar_Mass / (h**2) # TODO: X errors Phi = (10**raw.T[1]) * unyt.Mpc**(-3) * h**3
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)
OH_koch = data[:, 2] OFe_koch = OH_koch - FeH_koch + O_over_Fe_AG89 - O_over_Fe x = unyt.unyt_array(FeH_koch * unyt.dimensionless) y = unyt.unyt_array(OFe_koch * 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 = "Koch et al. (2008), Carina" bibcode = "2008AJ....135.1580K" name = "[O/Fe] as a function of [Fe/H] for Carina" 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)
# Meta-data comment = ( "Data obtained assuming the total stellar mass is the same as the bulge mass. " "No cosmology correction needed.") citation = "McConnell & Ma (2013) (Data)" bibcode = "2013ApJ...764..184M" name = "Black hole mass - stellar mass relation from 36 local galaxies." plot_as = "points" # We purposely make this data show up not only a z=0 but also at higher z redshift_lower, redshift_upper = -0.1, 3.1 redshift = 0.0 h = h_sim # Write everything processed = ObservationalData() processed.associate_x(M_star, scatter=x_scatter, comoving=True, description="Galaxy Stellar Mass") processed.associate_y(M_BH, scatter=y_scatter, comoving=True, description="Black Hole 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)