mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-13 06:01:13 +00:00
Add simple distance flow model (#114)
* Add imports * Add field LOS paths * Add basic flow model * Edit script * Add nb * Add nb * Update nb * Add some docs * Add RA reading * Add imoprts * Updates to the flow model * Update script * Bring back A2 * Update imports * Update imports * Add Carrick to ICs * Add Carrick boxsize * Add Carrick and fix minor bugs * Add Carrick box * Update script * Edit imports * Add fixed flow! * Update omega_m and add it * Update nb * Update nb * Update nb * Remove old print statements * Update params * Add thinning of chains * Add import * Add flow validation script * Add submit script * Add ksmooth * Update nb * Update params * Update script * Update string * Move where distributions are defined * Add density bias parameter * Add lognorm mean * Update scripts * Update script
This commit is contained in:
parent
fb93f85543
commit
a65e3cb15b
14 changed files with 1762 additions and 60 deletions
150
scripts_independent/A2_to_hdf5.ipynb
Normal file
150
scripts_independent/A2_to_hdf5.ipynb
Normal file
|
@ -0,0 +1,150 @@
|
|||
{
|
||||
"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",
|
||||
"# 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",
|
||||
"from os.path import join\n",
|
||||
"\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from h5py import File\n",
|
||||
"\n",
|
||||
"%matplotlib inline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Supernovae data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a2dir = \"/Users/richard/Data/PV/A2_paper_data/A2\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### LOSS data set"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"names = [\"z_CMB\", \"mB\", \"x1\", \"c\", \"e_mB\", \"e_x1\", \"e_c\", \"RA\", \"DEC\"]\n",
|
||||
"dtype = [(n, np.float32) for n in names]\n",
|
||||
"data = np.genfromtxt(join(a2dir, \"loss.csv\"), delimiter=\",\", skip_header=1,\n",
|
||||
" usecols=[5 + n for n in range(len(names))])\n",
|
||||
"\n",
|
||||
"loss_data = np.empty(len(data), dtype=dtype)\n",
|
||||
"for i, n in enumerate(names):\n",
|
||||
" loss_data[n] = data[:, i]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Foundation data set "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"names = [\"z_CMB\", \"RA\", \"DEC\", \"x1\", \"mB\", \"c\", \"peak\", \"e_peak\", \"e_x1\", \"e_mB\", \"e_c\"]\n",
|
||||
"dtype = [(n, np.float32) for n in names]\n",
|
||||
"data = np.genfromtxt(join(a2dir, \"foundation.csv\"), delimiter=\",\", skip_header=1,\n",
|
||||
" usecols=[3 + n for n in range(len(names))])\n",
|
||||
"\n",
|
||||
"foundation_data = np.empty(len(data), dtype=dtype)\n",
|
||||
"for i, n in enumerate(names):\n",
|
||||
" foundation_data[n] = data[:, i]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Write output as HDF5 file"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"outdir = \"/Users/richard/Downloads\"\n",
|
||||
"fname = \"PV_compilation_Supranta2019.hdf5\"\n",
|
||||
"\n",
|
||||
"with File(join(outdir, fname), 'w') as f:\n",
|
||||
" # Write LOSS\n",
|
||||
" grp = f.create_group(\"LOSS\")\n",
|
||||
" for name in loss_data.dtype.names:\n",
|
||||
" grp.create_dataset(name, data=loss_data[name])\n",
|
||||
"\n",
|
||||
" # Write Foundation\n",
|
||||
" grp = f.create_group(\"Foundation\")\n",
|
||||
" for name in foundation_data.dtype.names:\n",
|
||||
" grp.create_dataset(name, data=foundation_data[name])\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue