Skip to content

Commit 50a2bdc

Browse files
fix-redshift-minus-one-lib_tools-gravwaves
1 parent 1929113 commit 50a2bdc

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

holodeck/gravwaves.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def _gws_harmonics_at_evo_fobs(fobs_gw, dlnf, evo, harm_range, nreals, box_vol,
273273

274274
if np.any(num_pois > 0):
275275
# Find the L loudest binaries in each realizations
276-
loud = np.sort(temp[:, np.newaxis] * (num_pois > 0), axis=0)[::-1, :]
276+
loud = np.sort(temp[:, np.newaxis] * (num_pois > 0) / dlnf, axis=0)[::-1, :]
277277
fore = loud[0, :]
278278
loud = loud[:loudest, :]
279279
else:
@@ -719,7 +719,9 @@ def char_strain_sq_from_bin_edges_redz(edges, redz):
719719

720720
# convert from observer-frame to rest-frame; still using frequency-bin centers
721721
fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)
722-
722+
# redz is set to -np.inf instead of -1, which makes fr negative and creates a nan error in hs calculation
723+
# so, to avoid nan, setting those fr to zero
724+
fr[fr<0] = 0.0
723725
hs = utils.gw_strain_source(mc, dc, fr)
724726
hc2 = (hs ** 2) * (fc / df)
725727
return hc2

holodeck/librarian/lib_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ def run_model(
836836
data['hc_bg'] = hc_bg
837837

838838
if gwb_flag:
839+
negative_mask = use_redz < 0.0 # galaxy mergers that stall
840+
use_redz[negative_mask] = -np.inf # set to -inf so they can't contribute to GWB
839841
gwb = holo.gravwaves._gws_from_number_grid_integrated_redz(edges, use_redz, number, nreals)
840842
data['gwb'] = gwb
841843

0 commit comments

Comments
 (0)