csiborgtools/notebooks/perseus.ipynb
Richard Stiskalek eb8d070fff
CSiBORG FoF switch (#75)
* Add moving FoF membership files

* add FoF membership path

* Add notes where its PHEW

* Add FoF catalogue path

* Correct typo

* Add more functionalities

* Make work with halo IDs from FoF

* Edit print statement

* Fix copy bug

* copy

* Add FoF catalogue reading

* Clean up script

* Fix typo

* Little edits

* Fix naming convention

* Rename key

* Remove loading substructure particles

* Rename CSiBORG Cat

* Rename clumps cat

* Rename cat

* Remove misplaced import

* Switch to halos

* rm import

* structfit of only halos

* Add FoF halo reading

* Add a short comment

* Fix __getitem__ to work with int

* Fix problems

* Improve __getitem__

* Add more conversion

* Fix indexing

* Fix __getitem__ assertion

* Fix numbers

* Rename

* Fix verbosity flags

* Add full Quijote HMF option

* Add plot of Quijote only

* Add quijote full paths

* Fix the fit_init script

* Renam arg

* Update .gitignore

* add default argument name

* Change default verbosity flag

* Modernise script structure

* Fix dictionary

* Fix reading to include m200c

* Modernise script

* Add args
2023-07-24 14:10:21 +02:00

25 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.HaloCatalogue(7468)
catxs = [csiborgtools.read.HaloCatalogue(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