Add load void data

This commit is contained in:
rstiskalek 2024-09-26 11:56:02 +01:00
parent 52589a533f
commit b43d1fd74d

View file

@ -29,35 +29,46 @@ from tqdm import tqdm
############################################################################### ###############################################################################
def load_void_data(kind): def load_void_data(profile, kind):
""" """
Load the void velocities from Sergij & Indranil's files for a given kind Load the void velocities from Sergij & Indranil's files for a given kind
of void profile per observer. of void profile per observer.
Parameters Parameters
---------- ----------
profile : str
Void profile to load. One of "exp", "gauss", "mb".
kind : str kind : str
The kind of void profile to load. One of "exp", "gauss", "mb". Data kind, either "density" or "vrad".
Returns Returns
------- -------
velocities : 3-dimensional array of shape (nLG, nrad, nphi) velocities : 3-dimensional array of shape (nLG, nrad, nphi)
""" """
if kind not in ["exp", "gauss", "mb"]: if profile not in ["exp", "gauss", "mb"]:
raise ValueError("kind must be one of 'exp', 'gauss', 'mb'") raise ValueError("profile must be one of 'exp', 'gauss', 'mb'")
if kind not in ["density", "vrad"]:
raise ValueError("kind must be one of 'density', 'vrad'")
fdir = "/mnt/extraspace/rstiskalek/catalogs/IndranilVoid" fdir = "/mnt/extraspace/rstiskalek/catalogs/IndranilVoid"
kind = kind.upper() if kind == "density":
fdir = join(fdir, f"{kind}profile") fdir = join(fdir, "rho_data")
tag = "rho"
else:
tag = "v_pec"
profile = profile.upper()
fdir = join(fdir, f"{profile}profile")
files = glob(join(fdir, "*.dat")) files = glob(join(fdir, "*.dat"))
rLG = [int(search(rf'v_pec_{kind}profile_rLG_(\d+)', f).group(1)) rLG = [int(search(rf'{tag}_{profile}profile_rLG_(\d+)', f).group(1))
for f in files] for f in files]
rLG = np.sort(rLG) rLG = np.sort(rLG)
for i, ri in enumerate(tqdm(rLG, desc="Loading void observer data")): for i, ri in enumerate(tqdm(rLG, desc=f"Loading void `{kind}`observer data")): # noqa
f = join(fdir, f"v_pec_{kind}profile_rLG_{ri}.dat") f = join(fdir, f"{tag}_{profile}profile_rLG_{ri}.dat")
data_i = np.genfromtxt(f).T data_i = np.genfromtxt(f).T
if i == 0: if i == 0: