I am looking to identify in which SubHalo a star was formed given its Particle ID.
Is there an efficient way to do so without having to iterate over all the SubHalos at every Snapshot and looking for the earliest appearance of the given Particle ID?
Stars know their formation time (GFM_StellarFormationTime), so this gives you the first snapshot in which the star exists.
You then need to load the IDs of all stars in that snapshot, and locate the index of the ID you are searching for. This index then immediately tells you which subhalo it belongs (using Offsets/Subhalo/SnapByType[:.4] and SubhaloLenType).
Thank you Dylan, I'm now able to obtain the ID of the Subhalo in which a star was born!
That being said, since I have multiple stars with different formation time, I end up having to load all the stars in multiple snapshots which takes quite a while (around 1 minute per snapshot). Is there a way to circumvent that?
You could plan to e.g. find this answer for all stars in the z=0 snapshot. As you say, it will require loading all previous snapshots once. Once done, however, you will have the answer for all stars.
I attempted to load all the stars at z=0, but encountered a memory issue. I'm working on the Illustris JupyterHub, which provides 10GB of memory. Unfortunately, this is insufficient to load all the stars beyond snapshot 32. Is there a method to bypass the memory constraints while staying on the hub, or would downloading all the data be my only option?
You could load them in a few chunks, if needed, no need to do them all at once.
But yes, if you need lots of memory for analysis, it would be good to download the (needed parts of the) data, to a local machine where you have more resources.