Skip to content

Commit

Permalink
safe division; decreasing number of randoms since at z ~ 1 becomes co…
Browse files Browse the repository at this point in the history
…mputationally expensive
  • Loading branch information
boryanah committed Jul 13, 2024
1 parent 5811cae commit 6f8098c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
12 changes: 9 additions & 3 deletions abacusnbody/hod/prepare_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def prepare_slab(

if len(index_bounds) > 0:
# factor of rands to generate
rand = 100 # to ensure 12 times more randoms than haloes in the octant.
rand = 50 # to ensure 6 times more randoms than haloes in the octant.
rand_N = allpos.shape[0] * rand

# generate randoms in L shape
Expand Down Expand Up @@ -591,8 +591,14 @@ def prepare_slab(
gc.collect()

if halo_lc and len(index_bounds) > 0:
Menv[index_bounds] /= rand_norm

mask = rand_norm == 0.0
rand_norm[mask] = 1.0
tmp = Menv[index_bounds]
tmp /= rand_norm # fixed (pull request #142)
tmp[mask] = 0.0
Menv[index_bounds] = tmp
del mask
gc.collect()
halos['fenv_rank'] = calc_fenv_opt(Menv, mbins, allmasses)

# compute delta concentration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
# - {name: vz, datatype: float64}
# - {name: mass, datatype: float64}
# - {name: id, datatype: int64}
# meta: {A_s: 1.0, Acent: 0, Asat: 0, Bcent: 0, Bsat: 0, Gal_type: ELG, Ncent: 7, Q: 100.0, alpha: 1.0, alpha_c: 0, alpha_s: 1, gamma: 4.12,
# meta: {A_s: 1.0, Acent: 0, Asat: 0, Bcent: 0, Bsat: 0, Gal_type: ELG, Ncent: 2, Q: 100.0, alpha: 1.0, alpha_c: 0, alpha_s: 1, gamma: 4.12,
# ic: 1.0, kappa: 1.0, logM1: 13.53, logM_cut: 11.75, p_max: 0.33, s: 0, s_p: 0, s_r: 0, s_v: 0, sigma: 0.58}
# schema: astropy-2.0
x y z vx vy vz mass id
-989.9376978993922 2271.8044883431635 814.4623365958757 -676.4788208007812 200.33482360839844 234.51451110839844 520943135551.90656 1337345
-989.797938586897 2393.4425817463325 900.0504605283132 -310.83984375 226.46484375 -10.9130859375 748723939760.8374 1347781
-989.9722399519769 2436.1243832394684 893.0100597725067 -244.4615020751953 21.344865798950195 -372.9910583496094 1060868004787.8907 1351697
-989.93851790025 2574.3917024073676 494.9816122572673 -60.2254753112793 245.01829528808594 -252.323974609375 1788501129344.1975 1362713
-989.8515106521996 2597.74790397846 4.456388275794544 416.015625 637.3980712890625 2.5475542545318604 700215064790.4169 1190110
-989.9779939780151 2595.872235514386 174.58946130616962 279.78515625 405.76171875 682.470703125 594760988767.7638 1364044
-989.8491016637607 2700.924001600403 128.59961886324763 192.24267578125 -99.3597640991211 -54.88894271850586 4730669850376.221 1374058
-989.9346596474115 2712.400836645169 79.9785797238952 346.61865234375 -133.11767578125 -166.9921875 491415994265.56366 1375036
-989.8232582237715 2546.1908703460344 572.2576660921198 618.0 278.25 -720.5 15543930805739.074 1360581
-989.4958507458637 2541.0769782689267 569.9216546495883 216.75 -925.75 644.5 15543930805739.074 1360581
-989.5793640317086 2663.630357230081 338.882715370822 -225.5625 -445.25 483.375 9446576130109.27 1370826
Binary file not shown.
Binary file not shown.

0 comments on commit 6f8098c

Please sign in to comment.