I'm trying to track the positions of all subhalos within a given halo for a specific Group_M_Crit200. I'm looking for halos of mass similar to Virgo-like clusters (~about 1e14 solar masses) and their subs embedded. My problem is when I plot the positions of all subhalos of a particular GroupFirstSub, I'm using the snapshots.loadSubhalo with the id = GroupFirstSub + i, with i = np.arange(GroupNsubs) to plot each of them and get a general view, however, when I plot the positions of the CM for each subhalo and I compare with the position of their host halo, the positions are not even similar! They look to be very far way from their host halo. What could be the cause? Maybe I'm not interpreting the problem in a proper way.
What you're doing sounds correct. The only issue which comes to mind is the periodic boundary conditions: is the GroupPos close to one of the edges of the box? E.g. 0 or 205000 (for TNG300, 75000 for TNG1000) in any coordinate? If so, I would (i) switch to a different halo for this first attempt, and (ii) implement the correct "wrapping" of relative positions/distances when they cross the periodic box.
yes, you were right. Some of the subhalos fall near the edges of the box. I solved it! Many thanks!