mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-07-06 06:21:12 +00:00
Add new Manticore field support
This commit is contained in:
parent
45ef6046fa
commit
b88804ea84
1 changed files with 66 additions and 18 deletions
|
@ -771,42 +771,90 @@ class CSiBORG2Field(BaseField):
|
||||||
|
|
||||||
class CSiBORG2XField(BaseField):
|
class CSiBORG2XField(BaseField):
|
||||||
"""
|
"""
|
||||||
CSiBORG2X `z = 0` field class.
|
CSiBORG2X `z = 0` field class based on the Manticore ICs.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
nsim : int
|
nsim : int
|
||||||
Simulation index.
|
Simulation index.
|
||||||
|
version : str
|
||||||
|
Manticore version index.
|
||||||
paths : Paths, optional
|
paths : Paths, optional
|
||||||
Paths object. By default, the paths are set to the `glamdring` paths.
|
Paths object. By default, the paths are set to the `glamdring` paths.
|
||||||
"""
|
"""
|
||||||
def __init__(self, nsim, paths=None):
|
def __init__(self, nsim, version, paths=None):
|
||||||
|
self.version = version
|
||||||
|
if version == 0:
|
||||||
|
self.nametag = "csiborg2X"
|
||||||
|
elif version == 1:
|
||||||
|
self.nametag = "manticore_2MPP_N128_DES_V1"
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid Manticore version.")
|
||||||
|
|
||||||
super().__init__(nsim, paths, False)
|
super().__init__(nsim, paths, False)
|
||||||
|
|
||||||
def overdensity_field(self, **kwargs):
|
def overdensity_field(self, **kwargs):
|
||||||
fpath = self.paths.field(
|
if self.version == 0:
|
||||||
"overdensity", None, None, self.nsim, "csiborg2X")
|
fpath = self.paths.field(
|
||||||
with File(fpath, "r") as f:
|
"overdensity", None, None, self.nsim, self.nametag)
|
||||||
field = f["delta_cic"][...].astype(np.float32)
|
with File(fpath, "r") as f:
|
||||||
|
field = f["delta_cic"][...].astype(np.float32)
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid Manticore version to read the "
|
||||||
|
"overdensity field.")
|
||||||
|
|
||||||
return field
|
return field
|
||||||
|
|
||||||
def density_field(self, **kwargs):
|
def density_field(self, **kwargs):
|
||||||
field = self.overdensity_field()
|
if self.version == 0:
|
||||||
omega0 = simname2Omega_m("csiborg2X")
|
field = self.overdensity_field()
|
||||||
rho_mean = omega0 * 277.53662724583074 # Msun / kpc^3
|
omega0 = simname2Omega_m(self.nametag)
|
||||||
field += 1
|
rho_mean = omega0 * 277.53662724583074 # Msun / kpc^3
|
||||||
field *= rho_mean
|
field += 1
|
||||||
|
field *= rho_mean
|
||||||
|
elif self.version == 1:
|
||||||
|
MAS = kwargs["MAS"]
|
||||||
|
grid = kwargs["grid"]
|
||||||
|
fpath = self.paths.field(
|
||||||
|
"density", MAS, grid, self.nsim, self.nametag)
|
||||||
|
|
||||||
|
if MAS == "SPH":
|
||||||
|
with File(fpath, "r") as f:
|
||||||
|
field = f["density"][:]
|
||||||
|
|
||||||
|
field /= (681.1 * 1e3 / grid)**3 # Convert to h^2 Msun / kpc^3
|
||||||
|
else:
|
||||||
|
field = np.load(fpath)
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid Manticore version to read the "
|
||||||
|
"density field.")
|
||||||
|
|
||||||
return field
|
return field
|
||||||
|
|
||||||
def velocity_field(self, **kwargs):
|
def velocity_field(self, **kwargs):
|
||||||
fpath = self.paths.field(
|
if self.version == 0:
|
||||||
"velocity", None, None, self.nsim, "csiborg2X")
|
fpath = self.paths.field(
|
||||||
with File(fpath, "r") as f:
|
"velocity", None, None, self.nsim, "csiborg2X")
|
||||||
v0 = f["v_0"][...]
|
with File(fpath, "r") as f:
|
||||||
v1 = f["v_1"][...]
|
v0 = f["v_0"][...]
|
||||||
v2 = f["v_2"][...]
|
v1 = f["v_1"][...]
|
||||||
field = np.array([v0, v1, v2])
|
v2 = f["v_2"][...]
|
||||||
|
field = np.array([v0, v1, v2])
|
||||||
|
elif self.version == 1:
|
||||||
|
MAS = kwargs["MAS"]
|
||||||
|
grid = kwargs["grid"]
|
||||||
|
fpath = self.paths.field(
|
||||||
|
"velocity", MAS, grid, self.nsim, self.nametag)
|
||||||
|
|
||||||
|
if MAS:
|
||||||
|
with File(fpath, "r") as f:
|
||||||
|
density = f["density"][:]
|
||||||
|
v0 = f["p0"][:] / density
|
||||||
|
v1 = f["p1"][:] / density
|
||||||
|
v2 = f["p2"][:] / density
|
||||||
|
field = np.array([v0, v1, v2])
|
||||||
|
else:
|
||||||
|
field = np.load(fpath)
|
||||||
|
|
||||||
return field
|
return field
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue