mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-12 05:38:42 +00:00
Basic matching (#2)
* add recarray manipulations * add cart to radec * add behav so x can be a list * add import * create empty files * ignore plots file * add planck data * add read_mmain file * add cols_to_structured import * use cols_to_structured * add cols_to_structued * add read_mmain import * add reading planck * add mass conversion * add brute force separation calculation * update nb * rename & int dtype * add func to get csiborg ids * add list to nd array conversion * add utils * rename file * add 2M++ * add read 2mpp * add 2mpp shortcut * add randoms generator * Change range of RA [0, 360] * fix ang wrapping * add code for sphere 2pcf * rm wrapping * optionally load only a few borgs * update nb
This commit is contained in:
parent
d2c1f3294a
commit
53a0629d90
17 changed files with 74697 additions and 37 deletions
File diff suppressed because one or more lines are too long
60
scripts/utils.py
Normal file
60
scripts/utils.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Copyright (C) 2022 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.
|
||||
|
||||
"""Notebook utility funnctions."""
|
||||
|
||||
try:
|
||||
import galomatch
|
||||
except ModuleNotFoundError:
|
||||
import sys
|
||||
sys.path.append("../")
|
||||
|
||||
|
||||
def load_mmain_convert(n):
|
||||
srcdir = "/users/hdesmond/Mmain"
|
||||
arr = galomatch.io.read_mmain(n, srcdir)
|
||||
|
||||
galomatch.io.convert_mass_cols(arr, "mass_cl")
|
||||
galomatch.io.convert_position_cols(arr, ["peak_x", "peak_y", "peak_z"])
|
||||
galomatch.io.flip_cols(arr, "peak_x", "peak_z")
|
||||
|
||||
d, ra, dec = galomatch.utils.cartesian_to_radec(arr)
|
||||
arr = galomatch.utils.add_columns(arr, [d, ra, dec], ["dist", "ra", "dec"])
|
||||
return arr
|
||||
|
||||
|
||||
def load_mmains(N=None, verbose=True):
|
||||
from tqdm import tqdm
|
||||
ids = galomatch.io.get_csiborg_ids("/mnt/extraspace/hdesmond")
|
||||
N = ids.size if N is None else N
|
||||
if N > ids.size:
|
||||
raise ValueError("`N` cannot be larger than 101.")
|
||||
out = [None] * N
|
||||
iters = tqdm(range(N)) if verbose else range(N)
|
||||
for i in iters:
|
||||
out[i] = load_mmain_convert(ids[i])
|
||||
return out
|
||||
|
||||
|
||||
def load_planck2015(max_comdist=214):
|
||||
from astropy.cosmology import FlatLambdaCDM
|
||||
cosmo = FlatLambdaCDM(H0=70.5, Om0=0.307, Tcmb0=2.728)
|
||||
fpath = ("/mnt/zfsusers/rstiskalek/galomatch/"
|
||||
+ "data/HFI_PCCS_SZ-union_R2.08.fits")
|
||||
return galomatch.io.read_planck2015(fpath, cosmo, max_comdist)
|
||||
|
||||
|
||||
def load_2mpp():
|
||||
return galomatch.io.read_2mpp("../data/2M++_galaxy_catalog.dat")
|
Loading…
Add table
Add a link
Reference in a new issue