csiborgtools/notebooks/fits.ipynb
Richard Stiskalek c14be720b5
Particle dumping (#49)
* Add paths

* Add dumping script

* Remove snap from density fields

* Add progress statement

* Update import ordering

* Update nb
2023-04-28 13:57:23 +01:00

147 lines
3.2 KiB
Text

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5a38ed25",
"metadata": {
"ExecuteTime": {
"end_time": "2023-04-12T14:25:46.519408Z",
"start_time": "2023-04-12T14:25:03.003304Z"
},
"scrolled": true
},
"outputs": [],
"source": [
"import sys\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"sys.path.append(\"../\")\n",
"import csiborgtools\n",
"\n",
"%matplotlib widget \n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "312c96c9",
"metadata": {},
"outputs": [],
"source": [
"paths = csiborgtools.read.CSiBORGPaths(**csiborgtools.paths_glamdring)\n",
"nsim0 = 7444\n",
"nsimx = 7444 + 24\n",
"nsnap0 = max(paths.get_snapshots(nsim0))\n",
"nsnapx = max(paths.get_snapshots(nsimx))\n",
"overlapper = csiborgtools.match.ParticleOverlap()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b097637b",
"metadata": {},
"outputs": [],
"source": [
"halo0_archive = np.load(paths.split_path(nsnap0, nsim0))\n",
"halox_archive = np.load(paths.split_path(nsnapx, nsimx))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "c3cf4c91",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 204873/204873 [16:48<00:00, 203.15it/s]\n",
"100%|██████████| 204960/204960 [16:42<00:00, 204.55it/s]\n"
]
}
],
"source": [
"# delta_bckg = overlapper.make_bckg_delta(halo0_archive, verbose=True)\n",
"# delta_bckg = overlapper.make_bckg_delta(halox_archive, delta=delta_bckg, verbose=True)\n",
"# np.save(\"./bckg_{}_{}.npy\".format(nsim0, nsimx), delta_bckg)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "f2986dd2",
"metadata": {},
"outputs": [],
"source": [
"import h5py"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1d8ad8fe",
"metadata": {},
"outputs": [],
"source": [
"f = h5py.File(\"../data/particles_7444.h5\", \"r\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "020ac8e4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 4.42346358e-01, 7.09757663e-03, 4.64053304e-01, -1.96926287e-03,\n",
" -2.67177823e-03, -6.45721859e-04, 1.16415322e-10])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f[\"particles\"][0, :]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1eb74f46",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "venv_csiborg",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}