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
This commit is contained in:
Richard Stiskalek 2023-04-18 11:02:36 +02:00 committed by GitHub
parent e0d3854277
commit fdb0df8d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 2152 additions and 1844 deletions

View file

@ -75,6 +75,17 @@
"wp3 = reader.mean_wp(wp3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c05b4db6",
"metadata": {},
"outputs": [],
"source": [
"\n",
"connect ECONNRFUSED"
]
},
{
"cell_type": "code",
"execution_count": 33,
@ -657,7 +668,7 @@
},
"outputs": [],
"source": [
"cat = csiborgtools.read.HaloCatalogue(7444, paths, min_mass=1e12, max_dist=155/0.705)"
"cat = csiborgtools.read.ClumpsCatalogue(7444, paths, min_mass=1e12, max_dist=155/0.705)"
]
},
{
@ -813,7 +824,7 @@
},
"outputs": [],
"source": [
"cat = csiborgtools.read.HaloCatalogue(7444, paths)"
"cat = csiborgtools.read.ClumpsCatalogue(7444, paths)"
]
},
{
@ -831,7 +842,7 @@
"from tqdm import trange\n",
"x = np.full((len(ics), 3), np.nan)\n",
"for i in trange(len(ics)):\n",
" cat = csiborgtools.read.HaloCatalogue(ics[i], paths, max_dist=155 / 0.705)\n",
" cat = csiborgtools.read.ClumpsCatalogue(ics[i], paths, max_dist=155 / 0.705)\n",
" for j, th in enumerate([1e12, 1e13, 1e14]):\n",
" mask = cat[\"totpartmass\"] > th\n",
" x[i, j] = np.nanmedian(cat[\"lambda200c\"][mask])"
@ -1149,8 +1160,8 @@
},
"outputs": [],
"source": [
"cat1 = csiborgtools.read.HaloCatalogue(7444, min_mass=1e13, max_dist=155 / 0.705)\n",
"cat2 = csiborgtools.read.HaloCatalogue(7468, min_mass=1e13, max_dist=155 / 0.705)"
"cat1 = csiborgtools.read.ClumpsCatalogue(7444, min_mass=1e13, max_dist=155 / 0.705)\n",
"cat2 = csiborgtools.read.ClumpsCatalogue(7468, min_mass=1e13, max_dist=155 / 0.705)"
]
},
{

View file

@ -62,8 +62,8 @@
},
"outputs": [],
"source": [
"cat0 = csiborgtools.read.HaloCatalogue(7468)\n",
"catx = csiborgtools.read.HaloCatalogue(7588)"
"cat0 = csiborgtools.read.ClumpsCatalogue(7468)\n",
"catx = csiborgtools.read.ClumpsCatalogue(7588)"
]
},
{

View file

@ -78,7 +78,7 @@
},
"outputs": [],
"source": [
"pkreader = csiborgtools.read.PKReader(paths.ic_ids, hw)\n",
"pkreader = csiborgtools.read.PKReader(paths.get_ics, hw)\n",
"\n",
"autoks, pks = pkreader.read_autos()\n",
"\n",
@ -1134,7 +1134,7 @@
"axs[0].set_title(\"hw = {}\".format(hw))\n",
"m = autoks < 40\n",
"mu = np.mean(pks, axis=0)\n",
"for i in range(len(paths.ic_ids)):\n",
"for i in range(len(paths.get_ics)):\n",
" axs[0].plot(autoks[m], pks[i, m], c=\"k\", lw=0.1)\n",
" axs[1].plot(autoks[m], pks[i, m] / mu[m], c=\"k\", lw=0.1)\n",
"axs[0].plot(autoks[m], mu[m], c=\"red\", lw=1, label=r\"$\\langle P(k) \\rangle$\")\n",
@ -2156,7 +2156,7 @@
"axs[0].set_title(r\"$\\mathrm{{hw}} = {}$\".format(hw))\n",
"m = autoks < 22\n",
"mu = np.mean(pks, axis=0)\n",
"for i in range(len(paths.ic_ids)):\n",
"for i in range(len(paths.get_ics)):\n",
" axs[0].plot(autoks[m], pks[i, m], c=\"k\", lw=0.1)\n",
" axs[1].plot(autoks[m], pks[i, m] / mu[m], c=\"k\", lw=0.1)\n",
"axs[0].plot(autoks[m], mu[m], c=\"red\", lw=1, label=r\"$\\langle P(k) \\rangle$\")\n",
@ -3242,13 +3242,13 @@
"fskel = \"/mnt/extraspace/rstiskalek/csiborg/crosspk/out_{}_{}_{}.p\"\n",
"\n",
"autoks, autopks = None, None\n",
"for i, nsim in enumerate(paths.ic_ids):\n",
"for i, nsim in enumerate(paths.get_ics):\n",
" pk = joblib.load(fskel.format(nsim, nsim, hw))\n",
" x = pk.k3D\n",
" y = pk.Pk[:, 0, 0]\n",
" sel = x < 20\n",
" if i == 0:\n",
" autoks = np.full((len(paths.ic_ids), np.sum(sel)), np.nan)\n",
" autoks = np.full((len(paths.get_ics), np.sum(sel)), np.nan)\n",
" autopks = np.full_like(autoks, np.nan)\n",
" \n",
" autoks[i, :] = x[sel]\n",
@ -3268,7 +3268,7 @@
"outputs": [],
"source": [
"plt.figure()\n",
"for i in range(len(paths.ic_ids)):\n",
"for i in range(len(paths.get_ics)):\n",
" plt.plot(autoks[i, :], autopks[i, :], c=\"k\", lw=0.1)\n",
"plt.plot(np.mean(autoks, axis=0), np.mean(autopks, axis=0), label=\"CSiBORG\", c=\"k\", lw=1)\n",
" \n",
@ -3308,10 +3308,10 @@
"source": [
"fskel = \"/mnt/extraspace/rstiskalek/csiborg/crosspk/out_{}_{}_{}.p\"\n",
"\n",
"ic0 = paths.ic_ids[25]\n",
"ic0 = paths.get_ics[25]\n",
"crossks, crosspks = None, None\n",
"i = 0\n",
"for ic in paths.ic_ids:\n",
"for ic in paths.get_ics:\n",
" if ic == ic0:\n",
" continue\n",
" ics = (ic0, ic)\n",
@ -3700,7 +3700,7 @@
"outputs": [],
"source": [
"paths = csiborgtools.read.CSiBORGPaths()\n",
"cat = csiborgtools.read.CombinedHaloCatalogue(paths, min_m500=1e13, max_dist=210)"
"cat = csiborgtools.read.CombinedCatalogue(paths, min_m500=1e13, max_dist=210)"
]
},
{
@ -4144,7 +4144,7 @@
},
"outputs": [],
"source": [
"cat = csiborgtools.io.HaloCatalogue(9844, 1016, minimum_m500=0)"
"cat = csiborgtools.io.Catalogue(9844, 1016, minimum_m500=0)"
]
},
{

View file

@ -515,7 +515,7 @@
}
],
"source": [
"len(paths.ic_ids(tonew=True))"
"len(paths.get_ics(tonew=True))"
]
},
{
@ -542,8 +542,8 @@
},
"outputs": [],
"source": [
"cat0 = csiborgtools.read.HaloCatalogue(7468)\n",
"catx = csiborgtools.read.HaloCatalogue(7588)"
"cat0 = csiborgtools.read.ClumpsCatalogue(7468)\n",
"catx = csiborgtools.read.ClumpsCatalogue(7588)"
]
},
{

322
notebooks/test_mmain.ipynb Normal file
View file

@ -0,0 +1,322 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5a38ed25",
"metadata": {
"ExecuteTime": {
"end_time": "2022-12-31T17:12:28.663839Z",
"start_time": "2022-12-31T17:12:25.134607Z"
}
},
"outputs": [],
"source": [
"import sys\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import joblib\n",
"import scienceplots\n",
"sys.path.append(\"../\")\n",
"import csiborgtools\n",
"\n",
"plt.style.use([\"science\", \"notebook\"])\n",
"%matplotlib widget\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "22130d0b",
"metadata": {},
"outputs": [],
"source": [
"d = np.load(\"/mnt/extraspace/rstiskalek/csiborg/split/clumps_07444_00951.npz\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "4d9d9d11",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"772 µs ± 4.01 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n"
]
}
],
"source": [
"%timeit d[\"232\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "66f32cef",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8a24c0fa",
"metadata": {},
"outputs": [],
"source": [
"paths = csiborgtools.read.CSiBORGPaths(**csiborgtools.paths_glamdring)\n",
"# cat = csiborgtools.read.ClumpsCatalogue(7444, paths)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6e3ba9f4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/mnt/extraspace/rstiskalek/csiborg/knn/auto/knncdf_07444_la.npz'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"paths.knn_path(7444, \"auto\", \"la\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "2f4793b9",
"metadata": {},
"outputs": [],
"source": [
"np.savez(\"test.npz\", a=np.random.rand(510, 510, 510), b=np.random.rand(510, 510, 510))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "041d80d8",
"metadata": {},
"outputs": [],
"source": [
"d = np.load(\"test.npz\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "dc320130",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['a', 'b']"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d.files"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "11231e20",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['a', 'b']"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d.files"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b6d02f8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 26,
"id": "4ae2a2a8",
"metadata": {},
"outputs": [],
"source": [
"np.save(\"test.npy\", np.array([]))"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "b675510f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([], dtype=float64)"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.load(\"test.npy\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f8f96b7",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4b63c20",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 21,
"id": "1cdcf448",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/mnt/extraspace/rstiskalek/csiborg/split/ic_00952/out_07444_123.npz'"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# paths.split_path(123, 7444, 952)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d07431f5",
"metadata": {},
"outputs": [],
"source": [
"nsim = 7444\n",
"nsnap = max(paths.get_snapshots(7444))\n",
"reader = csiborgtools.read.ParticleReader(paths)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "def3c21f",
"metadata": {},
"outputs": [],
"source": [
"\n",
"# clumpind = reader.read_clumps(nsnap, nsim, cols=\"index\")[\"index\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "832e82ce",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa69261b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"id": "105dd2e2",
"metadata": {},
"outputs": [],
"source": [
"parts = np.load(\"/mnt/extraspace/rstiskalek/csiborg/initmatch/clump_7468_particles.npy\", allow_pickle=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c49f174b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "38e9490d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "venv_galomatch",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}