-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added smhmr with stellar mass on xaxisg
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
data/GalaxyStellarMassHaloMass/conversion/convertBehroozi2013RatioStellar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from velociraptor.observations.objects import ObservationalData | ||
from velociraptor.fitting_formulae.smhmr import moster_raw, behroozi_raw | ||
|
||
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()) | ||
|
||
# Cosmology | ||
h_sim = cosmology.h | ||
|
||
output_filename = "Behroozi2013RatioStellar.hdf5" | ||
output_directory = "../" | ||
|
||
if not os.path.exists(output_directory): | ||
os.mkdir(output_directory) | ||
|
||
|
||
halo_masses = np.logspace(4, 16, 512) | ||
stellar_masses = behroozi_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 = "Behroozi et al. (2013)" | ||
bibcode = "2013ApJ...770...57B" | ||
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( | ||
stellar_masses * unyt.Solar_Mass, | ||
scatter=None, | ||
comoving=False, | ||
description="Galaxy Stellar Mass", | ||
) | ||
processed.associate_y( | ||
(stellar_masses / halo_masses) * unyt.dimensionless, | ||
scatter=None, | ||
comoving=True, | ||
description="Galaxy Stellar Mass / Halo 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): | ||
os.remove(output_path) | ||
|
||
processed.write(filename=output_path) |
65 changes: 65 additions & 0 deletions
65
data/GalaxyStellarMassHaloMass/conversion/convertMoster2013RatioStellar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from velociraptor.observations.objects import ObservationalData | ||
from velociraptor.fitting_formulae.smhmr import moster_raw, behroozi_raw | ||
|
||
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()) | ||
|
||
# Cosmology | ||
h_sim = cosmology.h | ||
|
||
output_filename = "Moster2013RatioStellar.hdf5" | ||
output_directory = "../" | ||
|
||
if not os.path.exists(output_directory): | ||
os.mkdir(output_directory) | ||
|
||
|
||
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( | ||
stellar_masses * unyt.Solar_Mass, | ||
scatter=None, | ||
comoving=False, | ||
description="Galaxy Stellar Mass", | ||
) | ||
processed.associate_y( | ||
(stellar_masses / halo_masses) * unyt.dimensionless, | ||
scatter=None, | ||
comoving=True, | ||
description="Galaxy Stellar Mass / Halo 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): | ||
os.remove(output_path) | ||
|
||
processed.write(filename=output_path) |