csiborgtools/scripts_plots/borg_acl.ipynb
Richard Stiskalek 9e4b34f579
Overlap fixing and more (#107)
* Update README

* Update density field reader

* Update name of SDSSxALFAFA

* Fix quick bug

* Add little fixes

* Update README

* Put back fit_init

* Add paths to initial snapshots

* Add export

* Remove some choices

* Edit README

* Add Jens' comments

* Organize imports

* Rename snapshot

* Add additional print statement

* Add paths to initial snapshots

* Add masses to the initial files

* Add normalization

* Edit README

* Update README

* Fix bug in CSiBORG1 so that does not read fof_00001

* Edit README

* Edit README

* Overwrite comments

* Add paths to init lag

* Fix Quijote path

* Add lagpatch

* Edit submits

* Update README

* Fix numpy int problem

* Update README

* Add a flag to keep the snapshots open when fitting

* Add a flag to keep snapshots open

* Comment out some path issue

* Keep snapshots open

* Access directly snasphot

* Add lagpatch for CSiBORG2

* Add treatment of x-z coordinates flipping

* Add radial velocity field loader

* Update README

* Add lagpatch to Quijote

* Fix typo

* Add setter

* Fix typo

* Update README

* Add output halo cat as ASCII

* Add import

* Add halo plot

* Update README

* Add evaluating field at radial distanfe

* Add field shell evaluation

* Add enclosed mass computation

* Add BORG2 import

* Add BORG boxsize

* Add BORG paths

* Edit run

* Add BORG2 overdensity field

* Add bulk flow clauclation

* Update README

* Add new plots

* Add nbs

* Edit paper

* Update plotting

* Fix overlap paths to contain simname

* Add normalization of positions

* Add default paths to CSiBORG1

* Add overlap path simname

* Fix little things

* Add CSiBORG2 catalogue

* Update README

* Add import

* Add TNG density field constructor

* Add TNG density

* Add draft of calculating BORG ACL

* Fix bug

* Add ACL of enclosed density

* Add nmean acl

* Add galaxy bias calculation

* Add BORG acl notebook

* Add enclosed mass calculation

* Add TNG300-1 dir

* Add TNG300 and BORG1 dir

* Update nb
2024-01-30 16:14:07 +00:00

50 KiB

In [1]:
import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt
try:
    import csiborgtools
except ModuleNotFoundError:
    import sys
    sys.path.append("../")
    import csiborgtools
import utils
%load_ext autoreload
%autoreload 2

import joblib
from os.path import join
from glob import glob
In [53]:
from astropy.cosmology import FlatLambdaCDM
In [ ]:

In [ ]:

In [54]:
cosmo = FlatLambdaCDM(H0=70.5, Om0=0.307, Tcmb0=2.728)
In [60]:
x = cosmo.Om0 - 1

18*np.pi**2 + 82 * x - 39 * x**2
Out[60]:
102.09716821960843
In [ ]:

In [ ]:

In [2]:
Nsim = 9844
simpath = csiborgtools.io.get_sim_path(Nsim)
Nsnap = 1016
In [40]:
fname = join(utils.dumpdir, "ramses_out_{}_{}.npy".format(str(Nsim).zfill(5), str(Nsnap).zfill(5)))
In [41]:
data = np.load(fname)
In [49]:
plt.figure()
plt.scatter(data["logRs"], data["rho0"], s=2.5, rasterized=True)
plt.yscale("log")

plt.ylabel(r"$\rho_0$")
plt.xlabel(r"$\log R_{\rm s}$")
# plt.savefig("../plots/rho0.png", dpi=450)
plt.show()
No description has been provided for this image
In [44]:
data["rho0"]
Out[44]:
array([287721.82008412, 249035.67807171,  69665.64384864, ...,
         2582.73496889,             nan,             nan])
In [ ]:

In [ ]:

In [24]:
out = csiborgtools.io.combine_splits(utils.Nsplits, Nsim, Nsnap, utils.dumpdir, )
100%|███████████████████████████████████████████████████████████████████████████████| 200/200 [00:24<00:00,  8.16it/s]
In [27]:
out.dtype.names
Out[27]:
('index',
 'level',
 'parent',
 'ncell',
 'peak_x',
 'peak_y',
 'peak_z',
 'rho-',
 'rho+',
 'rho_av',
 'mass_cl',
 'relevance',
 'npart',
 'totpartmass',
 'logRs')
In [36]:
plt.figure()

plt.scatter(out["mass_cl"], out["logRs"], s=3, rasterized=True)
# t = np.logspace(-8, -4, 1000)
# plt.plot(t, t, c="red", ls="--")


# plt.yscale("log")
plt.xscale("log")
plt.xlabel("mass_cl")
# plt.ylabel("summed mass of all particles")

plt.savefig("../plots/mass.png", dpi=400)
plt.show()
No description has been provided for this image
In [ ]:

In [22]:
mask = np.isin(out["index"], arr["index"])
In [23]:
mask
Out[23]:
array([ True,  True,  True, ..., False, False, False])
In [ ]:

In [ ]:
np.where()
In [ ]:

In [16]:

Out[16]:
array([       1,        2,        3, ..., 21795024, 21796985, 21797711])
In [ ]:

In [ ]:

In [ ]:
# clump_ids = csiborgtools.io.read_clumpid(Nsnap, simpath)
# clumps = csiborgtools.io.read_clumps(Nsnap, simpath, )

# particles = csiborgtools.io.read_particle(["x", "y", "z", "M", "level"], Nsnap, simpath)
# clump_ids, particles = csiborgtools.io.drop_zero_indx(clump_ids, particles)

# with_particles = csiborgtools.fits.clump_with_particles(clump_ids, clumps)
# clumps = clumps[with_particles]
In [ ]:
f = join(utils.dumpdir, "ramses_out_09844_01016_123.npy")
f = np.load(f)
In [ ]:
plt.figure()
plt.hist(f["logRs"], bins="auto")
plt.show()
In [ ]: