mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-06-08 18:01:11 +00:00
Mass enclosed in a sphere calculation (#5)
* rename nb * add merge func * rm bug.. * add static methods * save rmin, rmax * add properties for box units * move radial info to the clump * add Npart explicit * move where rmin, rmax obtained * add box cosmo * add __getattr__ * add comments in units * add enclosed spherical mass * rm unused variables * add clump mass setter * add the halo index * add enclosed overdensity * add enclosed_overdensity * simplify loss func * opt result to nan * change Rs to log10 * change back to attribs * add H0 and h props * add setattrs * Remove global constants * move Msuncgs above * add crit density * add dots * add r200c and r500c * add M200 and M500 * make lowercase * output r200, r500, m200, m500 * update TODO * update README * fit NFW only up to r200 * add r178, m178 * add m178, r178 * update TODO
This commit is contained in:
parent
88e2132232
commit
ba98ecc299
9 changed files with 540 additions and 188 deletions
|
@ -17,6 +17,7 @@ from .readsim import (get_csiborg_ids, get_sim_path, get_snapshots, # noqa
|
|||
get_snapshot_path, read_info, nparts_to_start_ind, # noqa
|
||||
open_particle, open_unbinding, read_particle, # noqa
|
||||
drop_zero_indx, # noqa
|
||||
read_clumpid, read_clumps, read_mmain) # noqa
|
||||
read_clumpid, read_clumps, read_mmain, # noqa
|
||||
merge_mmain_to_clumps) # noqa
|
||||
from .readobs import (read_planck2015, read_2mpp) # noqa
|
||||
from .outsim import (dump_split, combine_splits) # noqa
|
||||
|
|
|
@ -85,9 +85,6 @@ def combine_splits(Nsplits, Nsim, Nsnap, outdir, cols_add, remove_splits=False,
|
|||
out : structured array
|
||||
Clump array with appended results from the splits.
|
||||
"""
|
||||
# Will be grabbing these columns from each split
|
||||
cols_add = [("npart", I64), ("totpartmass", F64), ("logRs", F64),
|
||||
("rho0", F64)]
|
||||
# Load clumps to see how many there are and will add to this array
|
||||
simpath = get_sim_path(Nsim)
|
||||
clumps = read_clumps(Nsnap, simpath, cols=None)
|
||||
|
|
|
@ -23,7 +23,7 @@ from os.path import (join, isfile)
|
|||
from glob import glob
|
||||
from tqdm import tqdm
|
||||
|
||||
from ..utils import cols_to_structured
|
||||
from ..utils import (cols_to_structured, add_columns)
|
||||
|
||||
|
||||
F16 = numpy.float16
|
||||
|
@ -495,3 +495,30 @@ def read_mmain(n, srcdir, fname="Mmain_{}.npy"):
|
|||
out[name] = arr[:, i]
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def merge_mmain_to_clumps(clumps, mmain):
|
||||
"""
|
||||
Merge columns from the `mmain` files to the `clump` file, matches them
|
||||
by their halo index while assuming that the indices `index` in both arrays
|
||||
are sorted.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
clumps : structured array
|
||||
Clumps structured array.
|
||||
mmain : structured array
|
||||
Parent halo array whose information is to be merged into `clumps`.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : structured array
|
||||
Array with added columns.
|
||||
"""
|
||||
X = numpy.full((clumps.size, 2), numpy.nan)
|
||||
# Mask of which clumps have a mmain index
|
||||
mask = numpy.isin(clumps["index"], mmain["index"])
|
||||
|
||||
X[mask, 0] = mmain["mass_cl"]
|
||||
X[mask, 1] = mmain["sub_frac"]
|
||||
return add_columns(clumps, X, ["mass_mmain", "sub_frac"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue