csiborgtools/meetings/220317_comboverlap.ipynb
Richard Stiskalek fdb0df8d4c
Add mmain and other major updates (#44)
* Move paths to a separate file

* Add mmain reader

* Add a verbosity flag

* Fix imports

* Fix bug

* Rename files

* Return ultimate parents

* Add script to generate mmain

* Remove mmain path

* edit path

* Add mmain path

* Change function name

* Rename function

* Turn off verbose

* Fix list requirement

* Edit init match paths

* Fix init pathing

* Edit paths docs

* Edit dumpdir name

* Rename path

* Fix split paths

* Remove unused import

* Add comment

* Update readme

* remove read mmain

* Rename haloatalogue

* Fix minor bugs

* Update nbs

* Add create directory option

* Move split jobs

* Move spliot jobs

* Remove splitting

* Add import

* Edit script

* Deeper split folder

* Fix paths bug

* Rename catalogue

* Rename Catalogue

* Add new clumpread

* Edit paths

* add knn paths

* Update commenting

* Update imports

* Add more conversions

* Update temp file

* Add a note

* Add catalogue

* Cooment

* Update TODO

* Update script

* add nb

* Update

* pep8

* edit paths & pep8

* Fix knn auto paths

* add paths docs

* Add auto and cross knn paths

* Add new paths

* Simplify tpcf reading

* pep8 patch

* update readme

* Update progress

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* pep8

* Pep 8 and restructure

* add lambda spin

* add clump and halo

* add checks

* Edit halo profile fit

* Update gitignore

* backup script
2023-04-18 11:02:36 +02:00

1,001 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