1
0
Fork 0
mirror of https://github.com/Findus23/halo_comparison.git synced 2024-09-19 16:03:50 +02:00
halo_comparison/ramses.py

28 lines
871 B
Python
Raw Normal View History

2022-07-28 00:42:44 +02:00
from pathlib import Path
import numpy as np
import pynbody
from pynbody.array import SimArray
from pynbody.snapshot.ramses import RamsesSnap
from readfiles import ParticlesMeta
def load_ramses_data(ramses_dir: Path):
s: RamsesSnap = pynbody.load(str(ramses_dir))
mass_array: SimArray = s.dm["mass"]
coord_array: SimArray = s.dm["pos"]
a = s.properties["a"]
print("RAMSES a", a)
2022-07-28 00:42:44 +02:00
masses = np.asarray(mass_array.in_units("1e10 Msol"))
high_res_mass = np.amin(np.unique(masses)) # get lowest mass of particles
is_high_res_particle = masses == high_res_mass
coordinates = np.asarray(coord_array.in_units("Mpc"))
hr_coordinates = coordinates[is_high_res_particle] / a
2022-07-28 00:42:44 +02:00
particles_meta = ParticlesMeta(particle_mass=high_res_mass)
center = np.median(hr_coordinates, axis=0)
return hr_coordinates, particles_meta, center