I wonder how to find all the subhalos's subhaloID residing in the same halo.
I have a subhalo with ID 1234 (a random number, just an example) at 99th snapshot, I know that I can get the haloID of the subhalo 1234 by the following code:
import illustris_python as il
basePath = "/home/tnguser/sims.TNG/TNG50-1/output/"
# snapNum and subhaloID should be given by the user
snapNum = 99
subhaloID = 1234
haloID = -1
subhalo = il.groupcat.loadSingle(basePath, snapNum, haloID, subhaloID)
# Deduce haloID from subhaloID and snapNum
haloID = subhalo['SubhaloGrNr']
I can find the subhaloID of the first subhalo by halo[GroupFirstSub]. However, it is just subhaloID of the first subhalo.
One of friend told me that you can load the next halo:
All the subhaloIDs of the same halo within the range that >=[halo[GroupFirstSub] but <halo_next[GroupFirstSub].
I have tested that
for i in range(halo['GroupFirstSub'], halo_next['GroupFirstSub']):
subhalo = il.groupcat.loadSingle(basePath, snapNum, -1, i)
if subhalo['SubhaloGrNr'] != haloID:
print(i, subhalo['SubhaloGrNr'])
which has no output, i.e., all the subhalos with ID lie in the range that >=[halo[GroupFirstSub] but <halo_next[GroupFirstSub] belong to the halo.
Did I find all of the subhalos?
Or equivalently, Do all the subhaloIDs of the same halo within the range that >=[halo[GroupFirstSub] but <halo_next[GroupFirstSub]?
Dylan Nelson
17 Mar
Instead of looking at the next halo, I would just look at GroupNsubs, for example in this thread.
Guan-Fu Liu
18 Mar
Thanks a lot! I also found that I could use
for i in range(halo['GroupFirstSub'], halo['GroupFirstSub']+halo['GroupNsubs']):
subhalo = il.groupcat.loadSingle(basePath, snapNum, -1, i)
I wonder how to find all the subhalos's subhaloID residing in the same halo.
I have a subhalo with ID 1234 (a random number, just an example) at 99th snapshot, I know that I can get the haloID of the subhalo 1234 by the following code:
Loading the halo:
I can find the subhaloID of the first subhalo by
halo[GroupFirstSub]
. However, it is just subhaloID of the first subhalo.One of friend told me that you can load the next halo:
All the subhaloIDs of the same halo within the range that >=
[halo[GroupFirstSub]
but <halo_next[GroupFirstSub]
.I have tested that
which has no output, i.e., all the subhalos with ID lie in the range that >=
[halo[GroupFirstSub]
but <halo_next[GroupFirstSub]
belong to the halo.Did I find all of the subhalos?
Or equivalently, Do all the subhaloIDs of the same halo within the range that >=
[halo[GroupFirstSub]
but <halo_next[GroupFirstSub]
?Instead of looking at the next halo, I would just look at GroupNsubs, for example in this thread.
Thanks a lot! I also found that I could use
Actually,
halo_next[GroupFirstSub]=halo['GroupFirstSub']+halo['GroupNsubs']
.