forked from christopherlovell/ML-cosmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmo_download.py
77 lines (53 loc) · 2.75 KB
/
dmo_download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import sys
import pandas as pd
import eagle_IO.eagle_IO as E
from sim_details import mlcosmo
_config = str(sys.argv[1])
mlc = mlcosmo(ini=_config)
nthr = 16
dmo = bool(int(sys.argv[2]))
if dmo:
sim_type = mlc.sim_dmo
else:
sim_type = mlc.sim_hydro
print("Sim type:", sim_type)
Grp_DM = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/GroupNumber", numThreads=nthr)
data = pd.DataFrame()
data['FOF_Group_M_Crit200_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"FOF/Group_M_Crit200", numThreads=nthr, noH=True)[Grp_DM-1] * mlc.unitMass
# data['FOF_Group_R_Crit200_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
# "FOF/Group_R_Crit200", numThreads=nthr)[Grp_DM-1] * mlc.unitLength
data['M_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/Mass", noH=True) * mlc.unitMass
# data['MassTwiceHalfMassRad_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
# "Subhalo/MassTwiceHalfMassRad", numThreads=nthr)[:,1] * mlc.unitMass
data['halfMassRad_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag, "Subhalo/HalfMassRad",
numThreads=nthr, noH=True)[:,1] * mlc.unitLength
data['velocity_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/Velocity", numThreads=nthr, noH=True)[:,1]
data['Vmax_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/Vmax", numThreads=nthr, noH=True)
data['VmaxRadius_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/VmaxRadius", numThreads=nthr, noH=True)
# data['length_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
# "Subhalo/SubLength", numThreads=nthr)
# data['Subhalo_Mass_DM'] = 1.15*10**7 * data['length_DM']
data['Sub_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/SubGroupNumber", numThreads=nthr, noH=True)
data['KE_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/KineticEnergy", numThreads=nthr, noH=True)
data['TE_DM'] = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/TotalEnergy", numThreads=nthr, noH=True)
SubPos = E.read_array("SUBFIND", sim_type, mlc.tag,
"Subhalo/CentreOfPotential", numThreads=nthr, noH=True)
data['SubPos_x'] = SubPos[:,0]
data['SubPos_y'] = SubPos[:,1]
data['SubPos_z'] = SubPos[:,2]
data['PotentialEnergy_DM'] = data['TE_DM'] - data['KE_DM']
data['Satellite'] = (data['Sub_DM'] != 0).astype(int)
# data = data[data['M_DM'] > 1e9].reset_index()
if dmo:
data.to_csv('output/%s_%s_dmo.csv'%(mlc.sim_name, mlc.tag))
else:
data.to_csv('output/%s_%s_hydro.csv'%(mlc.sim_name, mlc.tag))