Box units conversion (#3)

* linting

* fix long line

* rename nb

* rename import

* add group catalog

* move imports out of functions

* add array_to_structured

* add references

* fix subsampling

* fix coord bug

* add 2M++ dists

* save nb

* fix comment

* add snapshot path

* add snapshot path

* add read_info

* Move transforms

* add import radec

* expand docs

* Move flipcols

* update nb

* add flip_cols

* create file

* add blank line

* Move units transfs

* add blank line

* add units import

* rm imports

* add import

* add box_units

* add comments
This commit is contained in:
Richard Stiskalek 2022-10-20 23:28:44 +01:00 committed by GitHub
parent c7665b8136
commit 942c36b142
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 6730 additions and 1574 deletions

1157
scripts/dist.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -12,8 +12,14 @@
# 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 functions.
"""
"""Notebook utility funnctions."""
import numpy
from tqdm import trange
from astropy.cosmology import FlatLambdaCDM
try:
import galomatch
@ -26,9 +32,9 @@ 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")
galomatch.utils.convert_mass_cols(arr, "mass_cl")
galomatch.utils.convert_position_cols(arr, ["peak_x", "peak_y", "peak_z"])
galomatch.utils.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"])
@ -36,20 +42,25 @@ def load_mmain_convert(n):
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.")
# If N less than num of CSiBORG, then radomly choose
if N == ids.size:
choices = numpy.arange(N)
else:
choices = numpy.random.choice(ids.size, N, replace=False)
out = [None] * N
iters = tqdm(range(N)) if verbose else range(N)
iters = trange(N) if verbose else range(N)
for i in iters:
out[i] = load_mmain_convert(ids[i])
j = choices[i]
out[i] = load_mmain_convert(ids[j])
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")
@ -57,4 +68,5 @@ def load_planck2015(max_comdist=214):
def load_2mpp():
return galomatch.io.read_2mpp("../data/2M++_galaxy_catalog.dat")
cosmo = FlatLambdaCDM(H0=70.5, Om0=0.307, Tcmb0=2.728)
return galomatch.io.read_2mpp("../data/2M++_galaxy_catalog.dat", cosmo)