csiborgtools/meetings/220317_comboverlap.ipynb
Richard Stiskalek 5dd8c668fa
Gaussian smoothing of density fields (#33)
* Simplify smoothing support and looping over nonzero

* Simplify comments

* add now()

* add cat length

* add smoothed calculation

* add smoothing

* Add sorting

* Edit what is ignored

* Move notebooks

* Add nonsymmetric smoothed overlap

* Update NB

* Add support for reading in the smoothed overlap

* Switch to the true overlap definition

* Reader of the true overlap

* rem occups

* Import moved to a class

* Move definition

* Edit submission script

* Update to account for the new definition

* backup nb

* Switch back to properly initialising arrays

* Fix addition bug

* Update NB

* Fix little bug

* Update nb
2023-03-27 09:22:03 +01:00

1001 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