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 sys
import numpy as np
import matplotlib.pyplot as plt
import joblib
# Local packages
try:
    import csiborgtools
except ModuleNotFoundError:
    print("not found")    
    sys.path.append("../")
    import csiborgtools


%matplotlib notebook
%load_ext autoreload
%autoreload 2
not found
In [2]:
cat0 = csiborgtools.read.ClumpsCatalogue(7468)
catxs = [csiborgtools.read.ClumpsCatalogue(nsim) for nsim in (7588, 8020, 8452, 8836)]
reader = csiborgtools.read.NPairsOverlap(cat0, catxs, max_dist=150 / 0.705)
In [10]:
xs = reader.summed_overlap(from_smoothed=True)
ks = xs[:, 0] > 0.5

fig, axs = plt.subplots(ncols=3, sharey=True, figsize=[1.5 * 6.4, 4.8 * 0.75])
fig.subplots_adjust(wspace=0)
fig.suptitle("Overlap with three other simulations")
for i in range(3):
    axs[i].scatter(reader.cat0("totpartmass", ks), xs[ks, i], s=1)

    axs[i].set_xscale("log")
    axs[i].set_xlabel(r"$M_{\rm tot} ~ [M_\odot]$")

axs[0].set_ylabel(r"Summed overlap $\sum_{b} \mathcal{O}^{\alpha \beta}_{a b}$")
plt.tight_layout()

plt.savefig("../plots/summed_overlap.png", dpi=300)
fig.show()
No description has been provided for this image
In [11]:
ks = xs[:, 0] > 0.5

fig, axs = plt.subplots(ncols=3, figsize=[1.5 * 6.4, 4.8 * 0.75])

axs[0].scatter(reader.cat0("totpartmass", ks), np.mean(xs[ks, :], axis=1), s=1)
axs[1].scatter(reader.cat0("totpartmass", ks), np.std(xs[ks, :], axis=1), s=1)
axs[2].scatter(np.mean(xs[ks, :], axis=1), np.std(xs[ks, :], axis=1), s=1)

for i in range(2):
    axs[i].set_xscale("log")
    axs[i].set_xlabel(r"$M_{\rm tot} ~ [M_\odot]$")

axs[0].set_ylabel(r"Realisation mean of $\sum_{b} \mathcal{O}^{\alpha \beta}_{a b}$")
axs[1].set_ylabel(r"Realisation std of $\sum_{b} \mathcal{O}^{\alpha \beta}_{a b}$")

axs[2].set_xlabel(r"Realisation mean of $\sum_{b} \mathcal{O}^{\alpha \beta}_{a b}$")
axs[2].set_ylabel(r"Realisation std of $\sum_{b} \mathcal{O}^{\alpha \beta}_{a b}$")
 
plt.tight_layout()
plt.savefig("../plots/averaged_summed_overlap.png", dpi=300)
fig.show()
No description has been provided for this image
In [20]:
mu, std, mu_full, std_full = reader.counterpart_mass(from_smoothed=True, overlap_threshold=0.01,
                                                     return_full=True)
probmatch = 1 - reader.prob_nomatch(from_smoothed=True)
../csiborgtools/read/summaries.py:717: RuntimeWarning: invalid value encountered in true_divide
  lambda x: x / numpy.sum(x), axis=1, arr=probmatch)
In [23]:
t = np.linspace(1e12, 5e15)

fig, axs = plt.subplots(ncols=3, figsize=[1.5 * 6.4, 4.8 * 0.75])
axs[0].scatter(reader.cat0("totpartmass"), mu_full[:, 0], c=probmatch[:, 0], s=5 * probmatch[:, 0],
            rasterized=True)


axs[1].scatter(reader.cat0("totpartmass"), mu, s=5 * np.mean(probmatch, axis=1), c=3 * np.mean(probmatch, axis=1))
axs[1].plot(t, t, c="red", ls="--")

axs[2].scatter(reader.cat0("totpartmass"), std / mu, s=5 * np.mean(probmatch, axis=1), c=3 * np.mean(probmatch, axis=1))

for i in range(3):
    axs[i].set_xlabel(r"$M_{\rm tot} ~ [M_\odot]$")
    axs[i].set_xscale("log")
    axs[i].set_yscale("log")

axs[0].set_ylabel(r"$\langle M_{\rm tot} \rangle ~ [M_\odot]$")
axs[0].set_title(r"$1 \rightarrow 1$ (col. by match prob.)")

axs[1].set_ylabel(r"$\langle M_{\rm tot} \rangle ~ [M_\odot]$")
axs[1].set_title(r"$1\rightarrow 4$ (col. by <match prob.>)")


axs[2].set_ylabel(r"$\delta(M_{\rm tot}) / \langle M_{\rm tot} \rangle$")
axs[2].set_title(r"$1\rightarrow 4$ (col. by <match prob.>)")

fig.tight_layout()
fig.savefig("../plots/exp_mass.png", dpi=300)
fig.show()
No description has been provided for this image
In [46]:
xs = reader.summed_overlap(from_smoothed=False)
ys = reader.summed_overlap(from_smoothed=True)
t = np.linspace(0, 1, 100)



fig, axs = plt.subplots(ncols=4, figsize=(6.4 * 3, 4.8), sharey=True)
fig.subplots_adjust(wspace=0)
for i in range(4):
    axs[i].hexbin(xs[:, i], ys[:, i], mincnt=1, bins="log", gridsize=30)
    axs[i].plot(t, t, c="red", ls="--")
    
    axs[i].set_xlabel("Original summed overlap")
axs[0].set_ylabel("Smoothed summer overlap")
fig.suptitle("Matching one simulation to four others")
plt.tight_layout(w_pad=0)
fig.savefig("../plots/ovelap_comp.png", dpi=450)
fig.show()
No description has been provided for this image