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


%matplotlib notebook
%load_ext autoreload
%autoreload 2
not found
In [13]:
knnreader = csiborgtools.read.kNNCDFReader()

auto_files = glob("/mnt/extraspace/rstiskalek/csiborg/knn/auto/*")
ks = [0, 3, 7]
rs, cdf, mass_thresholds = knnreader.read(auto_files, ks, rmin=0.1)
100%|██████████| 101/101 [00:02<00:00, 38.07it/s]
In [14]:
mu = np.mean(cdf, axis=0)
std = np.std(cdf, axis=0)


cols = plt.rcParams["axes.prop_cycle"].by_key()["color"]
fig, axs = plt.subplots(ncols=3, figsize=(6.4 * 1.5, 4.8 * 0.75))

for ki, k in enumerate(ks):
    for n in list(range(3))[::-1]:
        label = r"$\log M_{{\rm tot}} / M_\odot \geq {}$".format(np.log10(mass_thresholds[n]))
        axs[ki].fill_between(rs, 1 - std[n, ki, :] / mu[n, ki, :], 1 + std[n, ki, :] / mu[n, ki, :],
                             color=cols[n], label=label)

    axs[ki].set_title(r"$k \leq {}$".format(k))
    axs[ki].axvline(2.65 / 0.705, c="red", ls="--", label="BORG constrained scale", alpha=0.5)
    axs[ki].set_xscale("log")
    axs[ki].set_xlabel(r"$r~\left[\mathrm{Mpc}\right]$")    
    
axs[0].set_ylabel(r"CDF ratio to mean")
axs[0].legend(frameon=False)

plt.tight_layout(w_pad=0)
fig.savefig("../plots/knn_auto.png", dpi=450)
fig.show()
No description has been provided for this image
In [16]:
knnreader = csiborgtools.read.kNNCDFReader()

cross_files = glob("/mnt/extraspace/rstiskalek/csiborg/knn/cross/knncdf_9004*")

cross_files = knnreader.cross_files(7444, "/mnt/extraspace/rstiskalek/csiborg/knn/cross/")

ks = [0, 3, 7]
rs, corr, mass_thresholds = knnreader.read(cross_files, ks, rmin=1)
100%|██████████| 100/100 [00:02<00:00, 42.21it/s]
In [17]:
cols = plt.rcParams["axes.prop_cycle"].by_key()["color"]


fig, axs = plt.subplots(ncols=3, figsize=(6.4 * 1.5, 4.8 * 0.75))
for ki, k in enumerate(ks):
    for n in range(3):
        for i in range(35):
            axs[ki].plot(rs, corr[i, n, ki, :], c=cols[n], lw=0.5)

        axs[ki].plot(rs, np.median(corr[:, n, ki, :], axis=0), c=cols[n],
                     label=r"$\log M_{{\rm tot}} / M_\odot \geq {}$".format(np.log10(mass_thresholds[n])))

    
    axs[ki].axvline(2.65 / 0.705, c="red", ls="--", label="BORG constrained scale", alpha=0.5)
    axs[ki].set_xscale("log")
    axs[ki].set_title(r"$k \leq {}$".format(k))
    axs[ki].set_xlabel(r"$r~\left[\mathrm{Mpc}\right]$")
    
axs[0].legend(frameon=False)
plt.tight_layout()
fig.savefig("../plots/knn_cross.png", dpi=450)
fig.show()
No description has been provided for this image
In [ ]:

In [ ]:

In [ ]: