mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 08:48:02 +00:00
145 lines
16 KiB
Text
145 lines
16 KiB
Text
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Copyright (C) 2024 Richard Stiskalek\n",
|
||
|
"# This program is free software; you can redistribute it and/or modify it\n",
|
||
|
"# under the terms of the GNU General Public License as published by the\n",
|
||
|
"# Free Software Foundation; either version 3 of the License, or (at your\n",
|
||
|
"# option) any later version.\n",
|
||
|
"#\n",
|
||
|
"# This program is distributed in the hope that it will be useful, but\n",
|
||
|
"# WITHOUT ANY WARRANTY; without even the implied warranty of\n",
|
||
|
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\n",
|
||
|
"# Public License for more details.\n",
|
||
|
"#\n",
|
||
|
"# You should have received a copy of the GNU General Public License along\n",
|
||
|
"# with this program; if not, write to the Free Software Foundation, Inc.,\n",
|
||
|
"# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n",
|
||
|
"import numpy as np\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from tqdm import trange\n",
|
||
|
"from joblib import dump\n",
|
||
|
"from h5py import File\n",
|
||
|
"\n",
|
||
|
"import csiborgtools\n",
|
||
|
"\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"%load_ext autoreload\n",
|
||
|
"%autoreload 2\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"fpath = \"/mnt/extraspace/rstiskalek/catalogs/PV_compilation.hdf5\"\n",
|
||
|
"\n",
|
||
|
"with File(fpath, 'r') as f:\n",
|
||
|
" RA_2MTF = f[\"2MTF/RA\"][...]\n",
|
||
|
" DEC_2MTF = f[\"2MTF/DEC\"][...]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 36,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Saving to /mnt/extraspace/rstiskalek/csiborg_postprocessing/flow_mock/Carrick2MTFmock_seed0.hdf5\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"!rm /mnt/extraspace/rstiskalek/csiborg_postprocessing/flow_mock/*\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"reader = csiborgtools.read.Carrick2015Field()\n",
|
||
|
"velocity = reader.velocity_field()\n",
|
||
|
"boxsize = csiborgtools.simname2boxsize(\"Carrick2015\")\n",
|
||
|
"\n",
|
||
|
"mean_mag = 10.31\n",
|
||
|
"std_mag = 0.83\n",
|
||
|
"\n",
|
||
|
"kmax = 1\n",
|
||
|
"seed = 53\n",
|
||
|
"\n",
|
||
|
"for k in trange(kmax):\n",
|
||
|
" mock, truths = csiborgtools.flow.mock_Carrick2MTF(\n",
|
||
|
" velocity, boxsize, RA_2MTF, DEC_2MTF,\n",
|
||
|
" mean_mag=mean_mag, std_mag=std_mag,\n",
|
||
|
" seed=seed, verbose=True)\n",
|
||
|
" seed += 1\n",
|
||
|
"\n",
|
||
|
" fname = f\"/mnt/extraspace/rstiskalek/csiborg_postprocessing/flow_mock/Carrick2MTFmock_seed{k}.hdf5\" # noqa\n",
|
||
|
" print(\"Saving to \", fname)\n",
|
||
|
" with File(fname, 'w') as f:\n",
|
||
|
" for key in mock.keys():\n",
|
||
|
" f.create_dataset(key, data=mock[key])\n",
|
||
|
"\n",
|
||
|
" fname_truths = fname.replace(\".hdf5\", \"_truths.pkl\")\n",
|
||
|
" dump(truths, fname_truths)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
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AOgQKAACwDoECAACsQ6AAAADrECgAAMA6BAoAALBOWLAHABpLl8mrArr/fTNGBnT/AHAx4QoKAACwDoECAACsQ6AAAADrECgAAMA6BAoAALAO7+IB/CTQ7xICgIsJV1AAAIB1CBQAAGAdAgUAAFiHQAEAANYhUAAAgHUIFAAAYB0CBQAAWIdAAQAA1iFQAACAdQgUAABgHb8HysmTJzVlyhQlJyerVatW6tq1q37/+9/LGOPdxhijqVOnqlOnTmrVqpXS0tK0Z88ef48CAACaKL8HynPPPaf58+frj3/8o3bv3q3nnntOM2fO1Ny5c73bzJw5U3PmzFFBQYFKSkrUpk0bpaenq6amxt/jAACAJsjvXxa4adMm3XrrrRo5cqQkqUuXLvrzn/+sLVu2SDp19WT27Nl64okndOutt0qS3njjDTmdTi1fvlyjRo3y90gAAKCJ8fsVlIEDB6qoqEifffaZJOnDDz/UP//5T/30pz+VJJWXl8vlciktLc37GIfDoZSUFBUXF/t7HAAA0AT5/QrK5MmT5fF41KNHD7Vo0UInT57UM888o6ysLEmSy+WSJDmdTp/HOZ1O77pvq62tVW1trfe+x+Px99gAAMAifr+C8pe//EWLFi3S4sWLtX37dr3++ut6/vnn9frrr1/wPvPz8+VwOLy3xMREP04MAABs4/dAefzxxzV58mSNGjVKV155pUaPHq3x48crPz9fkhQfHy9Jqqys9HlcZWWld9235eXlye12e28VFRX+HhsAAFjE74Fy7NgxhYb67rZFixaqr6+XJCU
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.figure()\n",
|
||
|
"plt.hist(mock[\"DEC\"], bins=\"auto\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"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.11.4"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|