Skip to content

Commit 27909b5

Browse files
authored
Merge pull request #26 from SWIFTSIM/add_z_to_obs_data_labels
Behroozi 2019 SMHM data (fit for all z)
2 parents b017bc5 + 325aaab commit 27909b5

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

velociraptor/fitting_formulae/smhmr.py

+85
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,88 @@ def behroozi_raw(z, Mhalo):
164164
logmstar = np.log10(eps * m1) + f - f0
165165
return 10.0 ** logmstar
166166

167+
168+
def behroozi_2019_raw(z, Mhalo):
169+
"""
170+
Stellar mass-halo mass relation from Behroozi +2019.
171+
172+
The data is taken from https://www.peterbehroozi.com/data.html
173+
174+
This function is a median fit to the raw data for centrals (i.e. excluding
175+
satellites)
176+
177+
The stellar mass is the true stellar mass (i.e. w/o observational corrections)
178+
179+
The fitting function does not include the intrahalo light contribution to the
180+
stellar mass
181+
182+
The halo mass is the peak halo mass that follows the Bryan & Norman (1998)
183+
spherical overdensity definition
184+
185+
Provided by Evgenii Chaikin.
186+
"""
187+
188+
Mhalo_log = np.log10(Mhalo)
189+
190+
params = {
191+
"EFF_0": -1.431495,
192+
"EFF_0_A": 1.75703,
193+
"EFF_0_A2": 1.350451,
194+
"EFF_0_Z": -0.217846,
195+
"M_1": 12.07402,
196+
"M_1_A": 4.599896,
197+
"M_1_A2": 4.423389,
198+
"M_1_Z": -0.7324986,
199+
"ALPHA": 1.973839,
200+
"ALPHA_A": -2.468417,
201+
"ALPHA_A2": -1.816299,
202+
"ALPHA_Z": 0.18208,
203+
"BETA": 0.4702271,
204+
"BETA_A": -0.8751643,
205+
"BETA_Z": -0.486642,
206+
"DELTA": 0.3822958,
207+
"GAMMA": -1.160189,
208+
"GAMMA_A": -3.633671,
209+
"GAMMA_Z": -1.2189,
210+
}
211+
212+
a = 1.0 / (1.0 + z)
213+
a1 = a - 1.0
214+
lna = np.log(a)
215+
216+
zparams = {}
217+
218+
zparams["m_1"] = (
219+
params["M_1"]
220+
+ a1 * params["M_1_A"]
221+
- lna * params["M_1_A2"]
222+
+ z * params["M_1_Z"]
223+
)
224+
zparams["sm_0"] = (
225+
zparams["m_1"]
226+
+ params["EFF_0"]
227+
+ a1 * params["EFF_0_A"]
228+
- lna * params["EFF_0_A2"]
229+
+ z * params["EFF_0_Z"]
230+
)
231+
zparams["alpha"] = (
232+
params["ALPHA"]
233+
+ a1 * params["ALPHA_A"]
234+
- lna * params["ALPHA_A2"]
235+
+ z * params["ALPHA_Z"]
236+
)
237+
zparams["beta"] = params["BETA"] + a1 * params["BETA_A"] + z * params["BETA_Z"]
238+
zparams["delta"] = params["DELTA"]
239+
zparams["gamma"] = 10 ** (
240+
params["GAMMA"] + a1 * params["GAMMA_A"] + z * params["GAMMA_Z"]
241+
)
242+
243+
dm = Mhalo_log - zparams["m_1"]
244+
dm2 = dm / zparams["delta"]
245+
logmstar = (
246+
zparams["sm_0"]
247+
- np.log10(10 ** (-zparams["alpha"] * dm) + 10 ** (-zparams["beta"] * dm))
248+
+ zparams["gamma"] * np.exp(-0.5 * (dm2 * dm2))
249+
)
250+
251+
return 10.0 ** logmstar

velociraptor/observations/objects.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def plot_on_axes(self, axes: Axes, errorbar_kwargs: Union[dict, None] = None):
539539
else:
540540
kwargs = {}
541541

542-
# Ensure correct units throughout, in case somebody chagned them
542+
# Ensure correct units throughout, in case somebody changed them
543543
if self.x_scatter is not None:
544544
self.x_scatter.convert_to_units(self.x.units)
545545

@@ -569,13 +569,16 @@ def plot_on_axes(self, axes: Axes, errorbar_kwargs: Union[dict, None] = None):
569569
elif self.plot_as == "line":
570570
kwargs["zorder"] = line_zorder
571571

572+
# Make both the data name and redshift appear in the legend
573+
data_label = f"{self.citation} ($z={self.redshift:.1f}$)"
574+
572575
axes.errorbar(
573576
self.x,
574577
self.y,
575578
yerr=self.y_scatter,
576579
xerr=self.x_scatter,
577580
**kwargs,
578-
label=self.citation
581+
label=data_label
579582
)
580583

581584
return

0 commit comments

Comments
 (0)