mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-07-12 08:53:04 +00:00
Add mock void
This commit is contained in:
parent
c84ab9e07b
commit
fa50e62fbe
1 changed files with 21 additions and 1 deletions
|
@ -20,6 +20,7 @@ from h5py import File
|
||||||
from ..params import SPEED_OF_LIGHT, simname2Omega_m
|
from ..params import SPEED_OF_LIGHT, simname2Omega_m
|
||||||
from ..utils import fprint, radec_to_galactic, radec_to_supergalactic
|
from ..utils import fprint, radec_to_galactic, radec_to_supergalactic
|
||||||
from .flow_model import PV_LogLikelihood
|
from .flow_model import PV_LogLikelihood
|
||||||
|
from .void_model import load_void_data, mock_void, select_void_h
|
||||||
|
|
||||||
H0 = 100 # km / s / Mpc
|
H0 = 100 # km / s / Mpc
|
||||||
|
|
||||||
|
@ -242,6 +243,25 @@ class DataLoader:
|
||||||
arr = np.empty(len(f["RA"]), dtype=dtype)
|
arr = np.empty(len(f["RA"]), dtype=dtype)
|
||||||
for key in f.keys():
|
for key in f.keys():
|
||||||
arr[key] = f[key][:]
|
arr[key] = f[key][:]
|
||||||
|
elif "IndranilVoidTFRMock" in catalogue:
|
||||||
|
# The name can be e.g. "IndranilVoidTFRMock_exp_34_0", where the
|
||||||
|
# first and second number are the LG observer index and random
|
||||||
|
# seed.
|
||||||
|
profile, rLG_index, seed = catalogue.split("_")[1:]
|
||||||
|
rLG_index = int(rLG_index)
|
||||||
|
seed = int(seed)
|
||||||
|
rLG, vrad_data = load_void_data(profile, "vrad")
|
||||||
|
h = select_void_h(profile)
|
||||||
|
print(f"Mock observed galaxies for LG observer with index "
|
||||||
|
f"{rLG_index} at {rLG[rLG_index] * h} Mpc / h and "
|
||||||
|
f"seed {seed}.")
|
||||||
|
mock_data = mock_void(vrad_data, rLG_index, profile, seed=seed)[0]
|
||||||
|
|
||||||
|
# Convert the dictionary to a structured array
|
||||||
|
dtype = [(key, np.float32) for key in mock_data.keys()]
|
||||||
|
arr = np.empty(len(mock_data["RA"]), dtype=dtype)
|
||||||
|
for key in mock_data.keys():
|
||||||
|
arr[key] = mock_data[key]
|
||||||
elif "UPGLADE" in catalogue:
|
elif "UPGLADE" in catalogue:
|
||||||
with File(catalogue_fpath, 'r') as f:
|
with File(catalogue_fpath, 'r') as f:
|
||||||
dtype = [(key, np.float32) for key in f.keys()]
|
dtype = [(key, np.float32) for key in f.keys()]
|
||||||
|
@ -459,7 +479,7 @@ def get_model(loader, zcmb_min=None, zcmb_max=None, mag_selection=None,
|
||||||
None, mag_selection, loader.rdist, loader._Omega_m, "SN",
|
None, mag_selection, loader.rdist, loader._Omega_m, "SN",
|
||||||
name=kind, void_kwargs=void_kwargs,
|
name=kind, void_kwargs=void_kwargs,
|
||||||
wo_num_dist_marginalisation=wo_num_dist_marginalisation)
|
wo_num_dist_marginalisation=wo_num_dist_marginalisation)
|
||||||
elif kind in ["SFI_gals", "2MTF", "SFI_gals_masked"]:
|
elif kind in ["SFI_gals", "2MTF", "SFI_gals_masked"] or "IndranilVoidTFRMock" in kind: # noqa
|
||||||
keys = ["RA", "DEC", "z_CMB", "mag", "eta", "e_mag", "e_eta"]
|
keys = ["RA", "DEC", "z_CMB", "mag", "eta", "e_mag", "e_eta"]
|
||||||
RA, dec, zCMB, mag, eta, e_mag, e_eta = (loader.cat[k] for k in keys)
|
RA, dec, zCMB, mag, eta, e_mag, e_eta = (loader.cat[k] for k in keys)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue