mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-13 22:21:12 +00:00
More flow preparation & Olympics (#143)
* Add more comments * Add flow paths * Simplify paths * Update default arguemnts * Update paths * Update param names * Update some of scipts for reading files * Add the Mike method option * Update plotting * Update fnames * Simplify things * Make more default options * Add print * Update * Downsample CF4 * Update numpyro selection * Add selection fitting nb * Add coeffs * Update script * Add nb * Add label * Increase number of steps * Update default params * Add more labels * Improve file name * Update nb * Fix little bug * Remove import * Update scales * Update labels * Add script * Update script * Add more * Add more labels * Add script * Add submit * Update spacing * Update submit scrips * Update script * Update defaults * Update defaults * Update nb * Update test * Update imports * Add script * Add support for Indranil void * Add a dipole * Update nb * Update submit * Update Om0 * Add final * Update default params * Fix bug * Add option to fix to LG frame * Add Vext label * Add Vext label * Update script * Rm fixed LG * rm LG stuff * Update script * Update bulk flow plotting * Update nb * Add no field option * Update defaults * Update nb * Update script * Update nb * Update nb * Add names to plots * Update nb * Update plot * Add more latex names * Update default * Update nb * Update np * Add plane slicing * Add nb with slices * Update nb * Update script * Upddate nb * Update nb
This commit is contained in:
parent
3d1e1c0ae3
commit
2b938c112c
20 changed files with 3106 additions and 379 deletions
2
scripts/field_prop/clear.sh
Executable file
2
scripts/field_prop/clear.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
cm="rm *.out"
|
||||
$cm
|
|
@ -396,10 +396,17 @@ if __name__ == "__main__":
|
|||
parser.add_argument("--grid", type=int, help="Grid resolution.")
|
||||
args = parser.parse_args()
|
||||
|
||||
rmax = 300
|
||||
dr = 0.5
|
||||
rmax = 200
|
||||
if args.catalogue == "CF4_GroupAll":
|
||||
dr = 1
|
||||
else:
|
||||
dr = 0.75
|
||||
|
||||
# smooth_scales = [0, 2, 4, 6, 8]
|
||||
smooth_scales = [0]
|
||||
|
||||
print(f"Running catalogue {args.catalogue} for simulation {args.simname}.")
|
||||
|
||||
comm = MPI.COMM_WORLD
|
||||
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
||||
nsims = get_nsims(args, paths)
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
nthreads=1
|
||||
memory=64
|
||||
on_login=1
|
||||
on_login=${1}
|
||||
queue="berg"
|
||||
env="/mnt/users/rstiskalek/csiborgtools/venv_csiborg/bin/python"
|
||||
file="field_los.py"
|
||||
|
||||
nsims="-1"
|
||||
# These are only for CB
|
||||
MAS="SPH"
|
||||
grid=1024
|
||||
|
||||
|
||||
for simname in "Lilow2024"; do
|
||||
for catalogue in "CF4_TFR"; do
|
||||
if [ "$on_login" != "1" ] && [ "$on_login" != "0" ]
|
||||
then
|
||||
echo "'on_login' (1) must be either 0 or 1."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# for simname in "csiborg1" "csiborg2_main" "csiborg2X" "Lilow2024" "Carrick2015" "CF4"; do
|
||||
for simname in "csiborg2_main"; do
|
||||
for catalogue in "2MTF" "SFI_gals" "CF4_TFR"; do
|
||||
pythoncm="$env $file --catalogue $catalogue --nsims $nsims --simname $simname --MAS $MAS --grid $grid"
|
||||
if [ $on_login -eq 1 ]; then
|
||||
echo $pythoncm
|
||||
|
|
95
scripts/field_prop/field_los_indranil_void.py
Normal file
95
scripts/field_prop/field_los_indranil_void.py
Normal file
|
@ -0,0 +1,95 @@
|
|||
# Copyright (C) 2024 Richard Stiskalek
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
"""
|
||||
MPI script to interpolate the density and velocity fields along the line of
|
||||
sight.
|
||||
"""
|
||||
from os.path import join
|
||||
|
||||
import csiborgtools
|
||||
import numpy as np
|
||||
from astropy.coordinates import SkyCoord, angular_separation
|
||||
from h5py import File
|
||||
from mpi4py import MPI
|
||||
from scipy.interpolate import RegularGridInterpolator
|
||||
|
||||
from field_los import get_los
|
||||
|
||||
|
||||
def interpolate_indranil_void(kind, RA, dec, rmax, dr, dump_folder, catalogue):
|
||||
fdir = "/mnt/extraspace/rstiskalek/catalogs"
|
||||
if kind == "exp":
|
||||
fname = join(fdir, "v_pec_EXP_IndranilVoid.dat")
|
||||
elif kind == "gauss":
|
||||
fname = join(fdir, "v_pec_GAUSS_IndranilVoid.dat")
|
||||
else:
|
||||
raise ValueError("Invalid void kind.")
|
||||
|
||||
# These are only velocities.
|
||||
data = np.loadtxt(fname)
|
||||
fname_out = join(dump_folder, f"los_{catalogue}_IndranilVoid_{kind}.hdf5")
|
||||
|
||||
r_grid = np.arange(0, 251)
|
||||
phi_grid = np.arange(0, 181)
|
||||
r_eval = np.arange(0, rmax, dr).astype(float) / 0.674
|
||||
|
||||
model_axis = SkyCoord(l=117, b=4, frame='galactic', unit='deg').icrs
|
||||
coords = SkyCoord(ra=RA, dec=dec, unit='deg').icrs
|
||||
|
||||
# Get angular separation in degrees
|
||||
phi = angular_separation(coords.ra.rad, coords.dec.rad,
|
||||
model_axis.ra.rad, model_axis.dec.rad)
|
||||
phi *= 180 / np.pi
|
||||
|
||||
# Get the interpolator
|
||||
f = RegularGridInterpolator((r_grid, phi_grid), data.T)
|
||||
# Get the dummy x-values to evaluate for each LOS
|
||||
x_dummy = np.ones((len(r_eval), 2))
|
||||
x_dummy[:, 0] = r_eval
|
||||
|
||||
result = np.full((len(RA), len(r_eval)), np.nan)
|
||||
for i in range(len(RA)):
|
||||
x_dummy[:, 1] = phi[i]
|
||||
result[i] = f(x_dummy)
|
||||
|
||||
# Write the output, homogenous density.
|
||||
density = np.ones_like(result)
|
||||
print(f"Writing to `{fname_out}`.")
|
||||
with File(fname_out, 'w') as f_out:
|
||||
f_out.create_dataset("rdist_0", data=r_eval * 0.674)
|
||||
f_out.create_dataset("density_0", data=density)
|
||||
f_out.create_dataset("velocity_0", data=result)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Command line interface #
|
||||
###############################################################################
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
kind = "exp"
|
||||
rmax = 165
|
||||
dr = 1
|
||||
|
||||
comm = MPI.COMM_WORLD
|
||||
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
||||
|
||||
out_folder = "/mnt/extraspace/rstiskalek/csiborg_postprocessing/field_los"
|
||||
|
||||
for catalogue in ["LOSS", "Foundation", "2MTF", "SFI_gals", "CF4_TFR", "CF4_GroupAll"]: # noqa
|
||||
print(f"Running kind `{kind}` for catalogue `{catalogue}`.")
|
||||
|
||||
RA, dec = get_los(catalogue, "", comm).T
|
||||
interpolate_indranil_void(
|
||||
kind, RA, dec, rmax, dr, out_folder, catalogue)
|
Loading…
Add table
Add a link
Reference in a new issue