mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-14 06:31:11 +00:00
Overlap fixing and more (#107)
* Update README * Update density field reader * Update name of SDSSxALFAFA * Fix quick bug * Add little fixes * Update README * Put back fit_init * Add paths to initial snapshots * Add export * Remove some choices * Edit README * Add Jens' comments * Organize imports * Rename snapshot * Add additional print statement * Add paths to initial snapshots * Add masses to the initial files * Add normalization * Edit README * Update README * Fix bug in CSiBORG1 so that does not read fof_00001 * Edit README * Edit README * Overwrite comments * Add paths to init lag * Fix Quijote path * Add lagpatch * Edit submits * Update README * Fix numpy int problem * Update README * Add a flag to keep the snapshots open when fitting * Add a flag to keep snapshots open * Comment out some path issue * Keep snapshots open * Access directly snasphot * Add lagpatch for CSiBORG2 * Add treatment of x-z coordinates flipping * Add radial velocity field loader * Update README * Add lagpatch to Quijote * Fix typo * Add setter * Fix typo * Update README * Add output halo cat as ASCII * Add import * Add halo plot * Update README * Add evaluating field at radial distanfe * Add field shell evaluation * Add enclosed mass computation * Add BORG2 import * Add BORG boxsize * Add BORG paths * Edit run * Add BORG2 overdensity field * Add bulk flow clauclation * Update README * Add new plots * Add nbs * Edit paper * Update plotting * Fix overlap paths to contain simname * Add normalization of positions * Add default paths to CSiBORG1 * Add overlap path simname * Fix little things * Add CSiBORG2 catalogue * Update README * Add import * Add TNG density field constructor * Add TNG density * Add draft of calculating BORG ACL * Fix bug * Add ACL of enclosed density * Add nmean acl * Add galaxy bias calculation * Add BORG acl notebook * Add enclosed mass calculation * Add TNG300-1 dir * Add TNG300 and BORG1 dir * Update nb
This commit is contained in:
parent
0984191dc8
commit
9e4b34f579
30 changed files with 10037 additions and 248 deletions
|
@ -174,8 +174,7 @@ class CSiBORG1Reader:
|
|||
|
||||
if which_snapshot == "initial":
|
||||
self.nsnap = 1
|
||||
raise RuntimeError("TODO not implemented")
|
||||
self.source_dir = None
|
||||
self.source_dir = f"/mnt/extraspace/rstiskalek/csiborg1/initial/ramses_out_{nsim}_new/output_00001" # noqa
|
||||
elif which_snapshot == "final":
|
||||
sourcedir = join(base_dir, f"ramses_out_{nsim}")
|
||||
self.nsnap = max([int(basename(f).replace("output_", ""))
|
||||
|
@ -195,7 +194,7 @@ class CSiBORG1Reader:
|
|||
self.sph_file = f"/mnt/extraspace/rstiskalek/csiborg1/sph_temp/chain_{self.nsim}.hdf5" # noqa
|
||||
|
||||
def read_info(self):
|
||||
filename = glob(join(self.source_dir, "info_*"))
|
||||
filename = glob(join(self.source_dir, "info_*.txt"))
|
||||
if len(filename) > 1:
|
||||
raise ValueError("Found too many `info` files.")
|
||||
filename = filename[0]
|
||||
|
@ -675,6 +674,7 @@ def process_final_snapshot(nsim, simname):
|
|||
flush=True)
|
||||
|
||||
# Lastly, create the halo mapping and default catalogue.
|
||||
print(f"{now()}: writing `{reader.output_cat}`.")
|
||||
print(f"{datetime.now()}: creating `GroupOffset`...")
|
||||
halo_map, unique_halo_ids = make_offset_map(halo_ids)
|
||||
# Dump the halo mapping.
|
||||
|
@ -744,8 +744,9 @@ def process_initial_snapshot(nsim, simname):
|
|||
del sort_indxs_final
|
||||
collect()
|
||||
|
||||
print(f"{now()}: loading and sorting the initial particle position.")
|
||||
print(f"{now()}: loading and sorting the initial particle information.")
|
||||
pos = reader.read_snapshot("pos")[sort_indxs]
|
||||
mass = reader.read_snapshot("mass")[sort_indxs]
|
||||
|
||||
del sort_indxs
|
||||
collect()
|
||||
|
@ -764,6 +765,8 @@ def process_initial_snapshot(nsim, simname):
|
|||
with File(reader.output_snap, 'w') as f:
|
||||
f.create_dataset("Coordinates", data=pos,
|
||||
**hdf5plugin.Blosc(**BLOSC_KWARGS))
|
||||
f.create_dataset("Masses", data=mass,
|
||||
**hdf5plugin.Blosc(**BLOSC_KWARGS))
|
||||
|
||||
|
||||
def process_initial_snapshot_csiborg2(nsim, simname):
|
||||
|
@ -836,39 +839,6 @@ def process_initial_snapshot_csiborg2(nsim, simname):
|
|||
**hdf5plugin.Blosc(**BLOSC_KWARGS))
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Prepare CSiBORG1 RAMSES for SPH density field #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def prepare_csiborg1_for_sph(nsim):
|
||||
"""
|
||||
Prepare a RAMSES snapshot for cosmotool SPH density & velocity field
|
||||
calculation.
|
||||
"""
|
||||
reader = CSiBORG1Reader(nsim, "final")
|
||||
|
||||
print("------- Preparing CSiBORG1 for SPH -------")
|
||||
print(f"Simulation index: {nsim}")
|
||||
print(f"Output file: {reader.sph_file}")
|
||||
print("-------------------------------------------------")
|
||||
print(flush=True)
|
||||
|
||||
with File(reader.sph_file, 'w') as dest:
|
||||
# We need to read pos first to get the dataset size
|
||||
pos = reader.read_snapshot("pos")
|
||||
|
||||
dset = dest.create_dataset("particles", (len(pos), 7),
|
||||
dtype=numpy.float32)
|
||||
dset[:, :3] = pos
|
||||
|
||||
del pos
|
||||
collect()
|
||||
|
||||
dset[:, 3:6] = reader.read_snapshot("vel")
|
||||
dset[:, 6] = reader.read_snapshot("mass")
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Command line interface #
|
||||
###############################################################################
|
||||
|
@ -883,8 +853,8 @@ if __name__ == "__main__":
|
|||
"csiborg2_random", "csiborg2_varysmall"],
|
||||
help="Simulation name.")
|
||||
parser.add_argument("--mode", type=int, required=True,
|
||||
choices=[0, 1, 2, 3],
|
||||
help="0: process final snapshot, 1: process initial snapshot, 2: process both, 3: prepare CSiBORG1 for SPH.") # noqa
|
||||
choices=[0, 1, 2],
|
||||
help="0: process final snapshot, 1: process initial snapshot, 2: process both") # noqa
|
||||
args = parser.parse_args()
|
||||
|
||||
if "csiborg2" in args.simname and args.mode in [0, 2]:
|
||||
|
@ -897,8 +867,6 @@ if __name__ == "__main__":
|
|||
process_final_snapshot(args.nsim, args.simname)
|
||||
elif args.mode == 1:
|
||||
process_initial_snapshot(args.nsim, args.simname)
|
||||
elif args.mode == 2:
|
||||
else:
|
||||
process_final_snapshot(args.nsim, args.simname)
|
||||
process_initial_snapshot(args.nsim, args.simname)
|
||||
else:
|
||||
prepare_csiborg1_for_sph(args.nsim)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue