I have been trying to get the dark matter fraction of some satellite subhalos, but I am not sure that I am doing it correctly due to some doubts I have regarding how to get the subhalos IDs in order to work with them. I am using JupyterLab, so I have been using the load functions available over there.
I understand that the subhalos IDs are the same as their index in an array, but I want to be sure if I am getting this right. In order to work with the subhalos at z=0 using the TNG100-1 simulation, firstly I formed an array with the loadSubhalos function that contains the mass of all their particles within twice the stellar half mass radius (subhalos_mass = il.groupcat.loadSubhalos(basePath, 99, fields=['SubhaloMassInRad'])). Once I found out which where the IDs of the central halos (using the "GroupFirstSub" field), I selected the most massive central halo's satellite subhalos as it follows: subhalos_satelites = subhalos_mass[1:17185]. The indexes of this new array called "subhalos_satelites" shoud be the satellite subhalos' IDs, am I right?
Secondly, I tried to study their dark matter fraction, but it is here where I am having trouble: I tried doing this for the first 10 satellite subhalos and I am not sure I am reading the information correctly when I use the load functions. I am attaching an image where you can see what I did. In my opinion, the variables called "subhalos_satelites[i]" and "total_mass" should have the same value but, when I printed them out to check this, I found out that this was not the case. Maybe I am not using the load functions correctly or I am mixing up the satellite subhalos' information.
If my explanation was not clear enough, let me know and I will try to explain it in a different way.
Many thanks in advance,
Your subhalos_satelites contains masses (floating point numbers), not IDs (which are integers).
If you want to get the IDs of the satellite subhalos of a given halo, you don't need to load any arrays of subhalos. Rather, you just need the GroupFirstSub and GroupNsubs, then:
haloID = 1234
halo = il.groupcat.loadSingle(basePath, snapNum, haloID=haloID)
central_subhalo_ID = halo['GroupFirstSub']
all_subhalo_IDs = np.arange(halo['GroupFirstSub'], halo['GroupFirstSub']+halo['GroupNsubs'])
satellite_subhalo_IDs = np.arange(halo['GroupFirstSub']+1, halo['GroupFirstSub']+halo['GroupNsubs'])
I think I understand now, but I have two questions regarding those variables you defined. Firstly, how do you know which halo ID do you initially have to ask for? You wrote haloID = 1234 as an example, but where can I see which halo IDs are there in order for me to set that variable? Secondly, why are you adding halo['GroupFirstSub']+halo['GroupNsubs'] when you use them as inputs?
I'm not entirely sure what you mean by "how do you know which halo... to ask for"? You can pick any halo(s) you want - perhaps you can clarify.
Second, this is to set the stop parameter for np.arange().
What I wanted to ask is how do I know that the halo that I'm asking for exists. I know I can ask for any halo I want, but that request must be made from a "list" of available halos, must not it? So how can I be sure that the halo that I am choosing exists?
I am sorry if this sounds confusing, maybe I am making it more complicated than it actually is and there is no restriction to the halo IDs.
The halos which exist are 0, 1, 2, ..., Nhalos-1 where "Nhalos" can be found in the Header of the group catalog files. Any of those numbers is a valid halo.
0, 1, 2, ..., Nhalos-1
(Similarly for subhalos).
Oh I see, I did not know that! Thank you very much for all your help, Dylan!